diff options
author | Frank Ch. Eigler <fche@elastic.org> | 2008-08-07 16:47:18 -0400 |
---|---|---|
committer | Frank Ch. Eigler <fche@elastic.org> | 2008-08-07 16:47:18 -0400 |
commit | 384c5fe974abe35ab11dce4446dc5eed86585a3b (patch) | |
tree | 9bbdc8206d4a9c08866dc2251e40f4f7249696d4 /testsuite/systemtap.examples/io/disktop.stp | |
parent | 9b3f22a9b83c4fd5e66874d78f4d35ad742ff802 (diff) | |
download | systemtap-steved-384c5fe974abe35ab11dce4446dc5eed86585a3b.tar.gz systemtap-steved-384c5fe974abe35ab11dce4446dc5eed86585a3b.tar.xz systemtap-steved-384c5fe974abe35ab11dce4446dc5eed86585a3b.zip |
samples: separate into subdirectories by subsystem
Diffstat (limited to 'testsuite/systemtap.examples/io/disktop.stp')
-rw-r--r-- | testsuite/systemtap.examples/io/disktop.stp | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/testsuite/systemtap.examples/io/disktop.stp b/testsuite/systemtap.examples/io/disktop.stp new file mode 100644 index 00000000..2637d735 --- /dev/null +++ b/testsuite/systemtap.examples/io/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 +} |