Alan Hargreaves' Weblog

The ramblings of an Australian SaND TSC* Principal Field Technologist

* Solaris and Network Domain Technology Support Centre - The group I work for

Tags

(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
pageicon 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: ,

Comments:

There is something "not quite right" in funcs.c # /export/home/dclarke/funcs.d dtrace: failed to compile script /export/home/dclarke/funcs.d: line 12: invalid probe description "pid$2:::entry": Undefined macro variable in probe description # # uname -a SunOS titan 5.10 Generic_118855-19 i86pc i386 i86pc

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

oops .. never mind # /export/home/dclarke/funcs.d 5 12834

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

Post a Comment:
Comments are closed for this entry.