summaryrefslogtreecommitdiffstats
path: root/stap_tutorial-1.0/examples/read-write-3.stp
diff options
context:
space:
mode:
Diffstat (limited to 'stap_tutorial-1.0/examples/read-write-3.stp')
-rwxr-xr-xstap_tutorial-1.0/examples/read-write-3.stp35
1 files changed, 35 insertions, 0 deletions
diff --git a/stap_tutorial-1.0/examples/read-write-3.stp b/stap_tutorial-1.0/examples/read-write-3.stp
new file mode 100755
index 0000000..fef85a5
--- /dev/null
+++ b/stap_tutorial-1.0/examples/read-write-3.stp
@@ -0,0 +1,35 @@
+#!/usr/bin/env stap
+
+global reads, writes
+
+probe begin {
+ printf("Collecting data...\n")
+}
+
+probe syscall.read.return {
+ if ($return > 0)
+ reads <<< $return
+}
+
+probe syscall.write.return {
+ if ($return > 0)
+ writes <<< $return
+}
+
+probe end {
+ printf("Read sizes summary:\n")
+
+ printf("\tcount:%d, sum:%d, avg:%d, min:%d, max:%d\n",
+ @count(reads), @sum(reads), @avg(reads),
+ @min(reads), @max(reads))
+
+ print(@hist_log(reads))
+
+ printf("Write sizes summary:\n")
+
+ printf("\tcount:%d, sum:%d, avg:%d, min:%d, max:%d\n",
+ @count(writes), @sum(writes), @avg(writes),
+ @min(writes), @max(writes))
+
+ print(@hist_log(writes))
+}