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:

Post a Comment:
Comments are closed for this entry.
About

* - Solaris and Network Domain, Technical Support Centre


Alan is a kernel and performance engineer based in Australia who tends to have the nasty calls gravitate towards him

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today
Links
Blogroll

No bookmarks in folder

Sun Folk

No bookmarks in folder

Non-Sun Folk
Non-Sun Folks

No bookmarks in folder