Skip to content

Instantly share code, notes, and snippets.

@Proteas
Created November 2, 2014 06:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Proteas/d3f4512c5fe113a82803 to your computer and use it in GitHub Desktop.
Save Proteas/d3f4512c5fe113a82803 to your computer and use it in GitHub Desktop.
DTrace Sample
#!/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