diff options
author | David Smith <dsmith@redhat.com> | 2008-08-08 12:26:02 -0500 |
---|---|---|
committer | David Smith <dsmith@redhat.com> | 2008-08-08 12:26:02 -0500 |
commit | a9a23c6ec198c08057989d6c3fc08b8865681bc4 (patch) | |
tree | 2d28417ab9a45f3200dcda7acdf84998c9c2b383 /testsuite/systemtap.examples/io/disktop.stp | |
parent | 9963b5fc7945ce939aaa8027ca71927cb77a55ff (diff) | |
parent | 751f828801e9bd4739d03a31a77e84c91e075b4e (diff) | |
download | systemtap-steved-a9a23c6ec198c08057989d6c3fc08b8865681bc4.tar.gz systemtap-steved-a9a23c6ec198c08057989d6c3fc08b8865681bc4.tar.xz systemtap-steved-a9a23c6ec198c08057989d6c3fc08b8865681bc4.zip |
Merge branch 'master' of ssh://sources.redhat.com/git/systemtap into work
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 +} |