diff options
author | William Cohen <wcohen@redhat.com> | 2008-05-20 16:07:50 -0400 |
---|---|---|
committer | William Cohen <wcohen@redhat.com> | 2008-05-20 16:07:50 -0400 |
commit | d15495ebff9e91135ae0923f4a36b2d2538bab54 (patch) | |
tree | c3a4a7bd1f5b9749bf58f3fd199d2bf787904f24 /testsuite/systemtap.examples/disktop.stp | |
parent | fc5a2d42b6cc46a9d4f7f3919ddc74ce70ad2a66 (diff) | |
download | systemtap-steved-d15495ebff9e91135ae0923f4a36b2d2538bab54.tar.gz systemtap-steved-d15495ebff9e91135ae0923f4a36b2d2538bab54.tar.xz systemtap-steved-d15495ebff9e91135ae0923f4a36b2d2538bab54.zip |
Add some scripts and descriptions to the systemtap.examples.
Diffstat (limited to 'testsuite/systemtap.examples/disktop.stp')
-rw-r--r-- | testsuite/systemtap.examples/disktop.stp | 69 |
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..24b1e331 --- /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 +} |