diff options
Diffstat (limited to 'stap_tutorial-1.0/examples/read-write-2.stp')
| -rwxr-xr-x | stap_tutorial-1.0/examples/read-write-2.stp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/stap_tutorial-1.0/examples/read-write-2.stp b/stap_tutorial-1.0/examples/read-write-2.stp new file mode 100755 index 0000000..d6a647b --- /dev/null +++ b/stap_tutorial-1.0/examples/read-write-2.stp @@ -0,0 +1,27 @@ +#!/usr/bin/env stap + +global reads, writes + +probe begin { + printf("Collecting data...\n") +} + +probe syscall.read.return { + if ($return > 0) + reads[execname()] += $return +} + +probe syscall.write.return { + if ($return > 0) + writes[execname()] += $return +} + +probe end { + printf("Bytes read by process name:\n") + foreach (name in reads-) + printf("%10d %s\n", reads[name], name) + + printf("Bytes written by process name:\n") + foreach (name in writes-) + printf("%10d %s\n", writes[name], name) +} |
