Alan Hargreaves' Weblog
The ramblings of an Australian SaND TSC* Principal Field Technologist
* Solaris and Network Domain Technology Support Centre - The group I work forTags
(update 1) acoustic bind birthday blues bugs cec cec2007 cec2008 china cmt contention cringley debugging dogs dtrace earthquake encumbered-binaries extra flash funny google guitar halloween huron install kids linux liveupgrade locking mdb music mysql newyear niagra openjava opensolaris oracle patches patents percussion performance redhat secondlife security solaris sru sun support sxcr t2 t2000 timeslider ufs upgrade virtualbox windows youtube zfs
Wednesday Nov 22, 2006
Some DTrace scripts I found useful last week
Last week I spent some time looking at applications that a customer was using to perform a data migration. It occurs to me that folks might be interested in a couple of the "one liner" type scripts that I found useful after turning them into 'stat' type tools. So, here they are.
funcs.d
#!/usr/sbin/dtrace -s
#pragma D option quiet
/*
* Count all user space function calls
*
* $1 - time to run (eg 10s)
* $2 - pid to monitor
*/
pid$2:::entry {
@[probefunc] = count();}
tick-$1 {
printa(@);
clear(@);
printf("--------\n");}
syscalls.d
#!/usr/sbin/dtrace -s
#pragma D option quiet
/*
* Count the syscalls a process is making as a stat tool
*
* $1 time to wait (eg 10s)
* $2 target pid
*/
syscall:::entry /pid == $2/ {
@[probefunc] = count();}
tick-$1 {
printa(@);
printf("--------\n");
clear(@);}
systimes.d
#!/usr/sbin/dtrace -s
#pragma D option quiet
/*
* Count the syscalls a process is making as a stat tool
*
* $1 time to wait (eg 10s)
* $2 target pid
*/
syscall:::entry /pid == $2/ {
self->start = vtimestamp;}
syscall:::return /self->start/ {
@[probefunc] = quantize((vtimestamp - self->start)/1000);}
tick-$1 {
printa(@);
printf("--------\n");
clear(@);}
ustk.d
#!/usr/sbin/dtrace -s
#pragma D option quiet
/*
* Aggregate user stacks calling a function in user space
*
* $1 - time to run (eg 10s)
* $2 - pid to monitor
* $3 - function to look for
*/
pid$2::$3:entry {
@[ustack(30)] = count();}
tick-$1 {
printa(@);
clear(@);
printf("--------\n");}
Technorati Tags: Solaris, DTrace
Posted at 04:06PM Nov 22, 2006 by Alan Hargreaves in Solaris | Comments[2]


Posted by Dennis Clarke on January 15, 2007 at 01:37 PM EST #
Posted by Dennis Clarke on January 15, 2007 at 01:41 PM EST #