Created
June 27, 2014 23:28
-
-
Save brendangregg/dc75f69a2cb6fa87005a to your computer and use it in GitHub Desktop.
I CAN HAZ SYSTEMTAP
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 | |
{ | |
%( $# > 0 %? | |
tproc = @1 | |
printf("Tracing read/write syscalls for processes named \"%s\"", | |
tproc); | |
%: | |
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