summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.examples/io/iodevstats.stp
diff options
context:
space:
mode:
authorWilliam Cohen <wcohen@redhat.com>2010-02-02 14:19:02 -0500
committerWilliam Cohen <wcohen@redhat.com>2010-02-02 14:19:02 -0500
commita4f3198f0b774528ef17dfb1ce5b3e70b6eb82fb (patch)
tree18a51685b92228af017a00232c81a939f4682154 /testsuite/systemtap.examples/io/iodevstats.stp
parent743757687f9c09bf9ef84b576bc0aa0fc19dea4c (diff)
downloadsystemtap-steved-a4f3198f0b774528ef17dfb1ce5b3e70b6eb82fb.tar.gz
systemtap-steved-a4f3198f0b774528ef17dfb1ce5b3e70b6eb82fb.tar.xz
systemtap-steved-a4f3198f0b774528ef17dfb1ce5b3e70b6eb82fb.zip
Add iodevstats.stp example
Diffstat (limited to 'testsuite/systemtap.examples/io/iodevstats.stp')
-rwxr-xr-xtestsuite/systemtap.examples/io/iodevstats.stp39
1 files changed, 39 insertions, 0 deletions
diff --git a/testsuite/systemtap.examples/io/iodevstats.stp b/testsuite/systemtap.examples/io/iodevstats.stp
new file mode 100755
index 00000000..8925945f
--- /dev/null
+++ b/testsuite/systemtap.examples/io/iodevstats.stp
@@ -0,0 +1,39 @@
+#! /usr/bin/env stap
+global reads, writes, totals
+
+probe begin { printf("starting probe\n") }
+
+probe vfs.read.return {
+ count = $return
+ if ( count >= 0 ) {
+ e=execname();
+ reads[e,dev] <<< count # statistics array
+ totals[e,dev] += count
+ }
+}
+
+probe vfs.write.return {
+ count = $return
+ if (count >= 0 ) {
+ e=execname();
+ writes[e,dev] <<< count # statistics array
+ totals[e,dev] += count
+ }
+}
+
+probe end {
+ printf("\n%16s %8s %8s %8s %8s %8s %8s %8s\n",
+ "", "", "", "read", "read", "", "write", "write")
+ printf("%16s %8s %8s %8s %8s %8s %8s %8s\n",
+ "name", "device", "read", "KB tot", "B avg", "write", "KB tot", "B avg")
+ foreach ([name,dev] in totals- limit 20) { # sort by total io
+ printf("%16s %3d, %4d %8d %8d %8d %8d %8d %8d\n",
+ name, _dev_major(dev), _dev_minor(dev),
+ @count(reads[name,dev]),
+ (@count(reads[name,dev]) ? @sum(reads[name,dev])>>10 : 0 ),
+ (@count(reads[name,dev]) ? @avg(reads[name,dev]) : 0 ),
+ @count(writes[name,dev]),
+ (@count(writes[name,dev]) ? @sum(writes[name,dev])>>10 : 0 ),
+ (@count(writes[name,dev]) ? @avg(writes[name,dev]) : 0 ))
+ }
+}