about summary refs log tree commit homepage
path: root/tapset/ioq_wait.awk
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-08-07 20:03:34 +0000
committerEric Wong <normalperson@yhbt.net>2013-08-26 20:41:08 +0000
commit37a5071021601480384c2abe20f2d33ad974579d (patch)
treeb0cc006c9cac9da7002e44adcfba2737bc0ce83f /tapset/ioq_wait.awk
parentfe1e1200c1541676e6b8402b7972a16105a76a63 (diff)
downloadcmogstored-37a5071021601480384c2abe20f2d33ad974579d.tar.gz
Our "all.stp" tapset now generates awk-friendly output for feeding
some sample awk scripts.

Using awk (and gawk) was necessary to avoid reimplementing strftime
in guru mode for generating CLF (Common Log Format) HTTP access logs.

Using awk also gives us several advantages:

* floating point number support (for time differences)

* a more familiar language to systems administrators
  (given this is for MogileFS, perhaps Perl would be even
   more familiar...).

* fast edit/run cycle, so the slowness of using stap to
  rebuild/reload the kernel module for all.stp changes can
  be avoided when output must be customized.
Diffstat (limited to 'tapset/ioq_wait.awk')
-rwxr-xr-xtapset/ioq_wait.awk53
1 files changed, 53 insertions, 0 deletions
diff --git a/tapset/ioq_wait.awk b/tapset/ioq_wait.awk
new file mode 100755
index 0000000..ba3913e
--- /dev/null
+++ b/tapset/ioq_wait.awk
@@ -0,0 +1,53 @@
+#!/usr/bin/awk -f
+/ ioq_blocked / {
+        pid = $1
+        fd = $2
+        time = $4
+        ioq_blocked[pid, fd] = time
+}
+
+/ ioq_reschedule / {
+        pid = $1
+        fd = $2
+        time = $4
+        ioq_reschedule[pid, fd] = time
+}
+
+/ http_req_start / {
+        pid = $1
+        fd = $2
+        method = $4
+        path = $5
+
+        now = ioq_unblocked[pid, fd]
+        if (now) {
+                blocked = (now - ioq_blocked[pid, fd]) / 1000000
+                resched = (now - ioq_reschedule[pid, fd]) / 1000000
+
+                printf("% 6d % 6d %0.4f %0.4f %s %s\n",
+                        pid, fd, blocked, resched, method, path)
+        }
+}
+
+/ mgmt_dig_start / {
+        pid = $1
+        fd = $2
+        alg = $4
+        path = $5
+
+        now = ioq_unblocked[pid, fd]
+        if (now) {
+                blocked = (now - ioq_blocked[pid, fd]) / 1000000
+                resched = (now - ioq_reschedule[pid, fd]) / 1000000
+
+                printf("% 6d % 6d %0.4f %0.4f %s %s\n",
+                        pid, fd, blocked, resched, alg, path)
+        }
+}
+
+/ ioq_unblocked / {
+        pid = $1
+        fd = $2
+        now = $4
+        ioq_unblocked[pid, fd] = now
+}