Created
June 28, 2014 02:02
-
-
Save brendangregg/0bc9633b495523fd73b2 to your computer and use it in GitHub Desktop.
I CAN HAZ ARGV
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/bin/stap | |
/* | |
* rwtime.stp read/write syscalls by latency. | |
* | |
* USAGE: ./rwtime.stp [execname] | |
* | |
* An option argument of the program name, eg, "httpd", can be provided. Without | |
* this, all processes are traced. | |
* | |
* 24-Jun-2014 Brendan Gregg Created this. | |
*/ | |
global read, write, tproc = ""; | |
probe begin | |
{ | |
if ($#) { | |
tproc = argv_1; | |
printf("Tracing read/write syscalls for processes named \"%s\"", | |
tproc); | |
} else { | |
printf("Tracing read/write syscalls"); | |
} | |
printf("... Hit Ctrl-C to end.\n"); | |
} | |
probe nd_syscall.read.return | |
{ | |
if (!$# || execname() == tproc) { | |
read <<< gettimeofday_ns() - @entry(gettimeofday_ns()); | |
} | |
} | |
probe nd_syscall.write.return | |
{ | |
if (!$# || execname() == tproc) { | |
write <<< gettimeofday_ns() - @entry(gettimeofday_ns()); | |
} | |
} | |
probe end | |
{ | |
printf("\nsyscall read latency (ns):\n"); | |
if (@count(read)) { print(@hist_log(read)); } | |
printf("\nsyscall write latency (ns):\n"); | |
if (@count(write)) { print(@hist_log(write)); } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment