Created
November 2, 2014 06:38
-
-
Save Proteas/d3f4512c5fe113a82803 to your computer and use it in GitHub Desktop.
DTrace Sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/sbin/dtrace -s | |
#pragma D option flowindent | |
/* monitor file open */ | |
syscall::open:entry | |
{ | |
printf("%s %s", execname, copyinstr(arg0)); | |
} | |
/* monitor process fork*/ | |
syscall::fork*: | |
{ | |
trace(pid); | |
} | |
syscall::exec*: | |
{ | |
trace(execname); | |
} | |
syscall::posix_spawn*: | |
{ | |
trace(execname); | |
} | |
/* monitor syscall of process */ | |
syscall:::entry | |
/execname == "Google Chrome" || execname == "Google Chrome Helper"/ | |
{ | |
@[probefunc] = count(); | |
} | |
/* show read bytes */ | |
syscall::read:return | |
{ | |
@[execname] = quantize(arg0); | |
} | |
/* profilling process names*/ | |
profile-997 | |
{ | |
@[execname] = count(); | |
} | |
tick-1s | |
{ | |
printa(@); | |
trunc(@); | |
} | |
/* timing system call */ | |
syscall::write:entry | |
{ | |
self->s = timestamp; | |
} | |
syscall::write:return | |
/self->s/ | |
{ | |
@["ns"] = quantize(timestamp - self->s); | |
self->s = 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment