summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.examples/disktop.stp
diff options
context:
space:
mode:
authorFrank Ch. Eigler <fche@elastic.org>2008-05-21 13:37:07 -0400
committerFrank Ch. Eigler <fche@elastic.org>2008-05-21 13:37:07 -0400
commite3339150b3c04f50b0abdc4a6d132a6b75b22cb6 (patch)
treec80892afd79625f95ff0a2543728804464c2961a /testsuite/systemtap.examples/disktop.stp
parent332ddc9f7354fe51c32c504087575b3ea2b70990 (diff)
parentaa8a3b1797da54a14d04cd57758a65064056376e (diff)
downloadsystemtap-steved-e3339150b3c04f50b0abdc4a6d132a6b75b22cb6.tar.gz
systemtap-steved-e3339150b3c04f50b0abdc4a6d132a6b75b22cb6.tar.xz
systemtap-steved-e3339150b3c04f50b0abdc4a6d132a6b75b22cb6.zip
Merge commit 'origin/master' into pr6429-comp-unwindsyms
* commit 'origin/master': Fix assignment optimization expected results. PR6538: more testsuite tweaks for read-only warnings PR6538: more tapset fixes PR6538: explain why absentstats.stp logs will contain warnings PR6538: fix treatment of initialized globals Use pointer_arg to fetch arguments for syscall.utime and compat_utime. Optimize compound and binary expression assignments. Check new (sub) functions of _struct_utimbuf_* and _struct_compat_utimbuf_*. PR6538: tapset changes PR6538: testsuite changes PR5001: fix test suite collateral damage PR6538: warn about read-only variables Add some scripts and descriptions to the systemtap.examples. PR5001: Remove _stp_ctime and always use ctime. Use tr1/unordered_map instead of the deprecated ext/hash_map. PR6524: ctime() on bad values hangs system. Optimize away assignments in other contexts. Optimize away assignments in other contexts. dummy commit for testing systemtap-cvs notification Remove sa_restorer initialization.
Diffstat (limited to 'testsuite/systemtap.examples/disktop.stp')
-rw-r--r--testsuite/systemtap.examples/disktop.stp69
1 files changed, 69 insertions, 0 deletions
diff --git a/testsuite/systemtap.examples/disktop.stp b/testsuite/systemtap.examples/disktop.stp
new file mode 100644
index 00000000..2637d735
--- /dev/null
+++ b/testsuite/systemtap.examples/disktop.stp
@@ -0,0 +1,69 @@
+#!/usr/bin/env stap
+#
+# Copyright (C) 2007 Oracle Corp.
+#
+# Get the status of reading/writing disk every 5 seconds, output top ten entries
+#
+# This is free software,GNU General Public License (GPL); either version 2, or (at your option) any
+# later version.
+#
+# Usage:
+# ./disktop.stp
+#
+
+global io_stat,device
+global read_bytes,write_bytes
+
+probe kernel.function("vfs_read").return {
+ if ($return>0) {
+ dev = __file_dev($file)
+ devname = __find_bdevname(dev,__file_bdev($file))
+
+ if (devname!="N/A") {/*skip read from cache*/
+ io_stat[pid(),execname(),uid(),ppid(),"R"] += $return
+ device[pid(),execname(),uid(),ppid(),"R"] = devname
+ read_bytes += $return
+ }
+ }
+}
+
+probe kernel.function("vfs_write").return {
+ if ($return>0) {
+ dev = __file_dev($file)
+ devname = __find_bdevname(dev,__file_bdev($file))
+
+ if (devname!="N/A") { /*skip update cache*/
+ io_stat[pid(),execname(),uid(),ppid(),"W"] += $return
+ device[pid(),execname(),uid(),ppid(),"W"] = devname
+ write_bytes += $return
+ }
+ }
+}
+
+probe timer.ms(5000) {
+ /* skip non-read/write disk */
+ if (read_bytes+write_bytes) {
+
+ printf("\n%-25s, %-8s%4dKb/sec, %-7s%6dKb, %-7s%6dKb\n\n",ctime(gettimeofday_s()),"Average:",
+ ((read_bytes+write_bytes)/1024)/5,"Read:",read_bytes/1024,"Write:",write_bytes/1024)
+
+ /* print header */
+ printf("%8s %8s %8s %25s %8s %4s %12s\n","UID","PID","PPID","CMD","DEVICE","T","BYTES")
+ }
+ /* print top ten I/O */
+ foreach ([process,cmd,userid,parent,action] in io_stat- limit 10)
+ printf("%8d %8d %8d %25s %8s %4s %12d\n",userid,process,parent,cmd,device[process,cmd,userid,parent,action],action,io_stat[process,cmd,userid,parent,action])
+
+ /* clear data */
+ delete io_stat
+ delete device
+ read_bytes = 0
+ write_bytes = 0
+}
+
+probe end{
+ delete io_stat
+ delete device
+ delete read_bytes
+ delete write_bytes
+}