summaryrefslogtreecommitdiffstats
path: root/testsuite
diff options
context:
space:
mode:
authorWilliam Cohen <wcohen@redhat.com>2008-06-17 14:36:34 -0400
committerWilliam Cohen <wcohen@redhat.com>2008-06-17 14:36:34 -0400
commit5006800b3f71d4e82ecce0b33b700601ba8c412c (patch)
tree77e9f87bedecd9d1bef22503923dc69e67ce9574 /testsuite
parent6ebf08661086e6739b9fd58ddae336a91113306e (diff)
downloadsystemtap-steved-5006800b3f71d4e82ecce0b33b700601ba8c412c.tar.gz
systemtap-steved-5006800b3f71d4e82ecce0b33b700601ba8c412c.tar.xz
systemtap-steved-5006800b3f71d4e82ecce0b33b700601ba8c412c.zip
Add the graphs.stp example from War Stories.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/systemtap.examples/ChangeLog4
-rw-r--r--testsuite/systemtap.examples/graphs.meta13
-rw-r--r--testsuite/systemtap.examples/graphs.stp60
3 files changed, 77 insertions, 0 deletions
diff --git a/testsuite/systemtap.examples/ChangeLog b/testsuite/systemtap.examples/ChangeLog
index adaf2e03..b337493c 100644
--- a/testsuite/systemtap.examples/ChangeLog
+++ b/testsuite/systemtap.examples/ChangeLog
@@ -1,3 +1,7 @@
+2008-06-17 William Cohen <wcohen@redhat.com>
+
+ * graphs.stp, graphs.meta: New.
+
2008-06-12 William Cohen <wcohen@redhat.com>
* thread-times.stp, thread-times.meta: New.
diff --git a/testsuite/systemtap.examples/graphs.meta b/testsuite/systemtap.examples/graphs.meta
new file mode 100644
index 00000000..60a522b3
--- /dev/null
+++ b/testsuite/systemtap.examples/graphs.meta
@@ -0,0 +1,13 @@
+title: Graphing Disk and CPU Utilization
+name: graphs.stp
+version: 1.0
+author: anonymous
+keywords: disk cpu use graph
+subsystem: disk cpu
+status: production
+exit: user-controlled
+output: plot data
+scope: system-wide
+description: The script tracks the disk and CPU utilization. The resulting output of the script can be piped into gnuplot to generate a graph of disk and CPU USE.
+test_check: stap -p4 graphs.stp
+test_installcheck: stap graphs.stp -c "sleep 1"
diff --git a/testsuite/systemtap.examples/graphs.stp b/testsuite/systemtap.examples/graphs.stp
new file mode 100644
index 00000000..0c8e3796
--- /dev/null
+++ b/testsuite/systemtap.examples/graphs.stp
@@ -0,0 +1,60 @@
+#! stap
+
+# ------------------------------------------------------------------------
+# data collection
+
+# disk I/O stats
+probe begin { qnames["ioblock"] ++; qsq_start ("ioblock") }
+probe ioblock.request { qs_wait ("ioblock") qs_run("ioblock") }
+probe ioblock.end { qs_done ("ioblock") }
+
+# CPU utilization
+probe begin { qnames["cpu"] ++; qsq_start ("cpu") }
+probe scheduler.cpu_on { if (!idle) {qs_wait ("cpu") qs_run ("cpu") }}
+probe scheduler.cpu_off { if (!idle) qs_done ("cpu") }
+
+
+# ------------------------------------------------------------------------
+# utilization history tracking
+
+global N
+probe begin { N = 50 }
+
+global qnames, util, histidx
+
+function qsq_util_reset(q) {
+ u=qsq_utilization (q, 100)
+ qsq_start (q)
+ return u
+}
+
+probe timer.ms(100) { # collect utilization percentages frequently
+ histidx = (histidx + 1) % N # into circular buffer
+ foreach (q in qnames)
+ util[histidx,q] = qsq_util_reset(q)
+}
+
+
+# ------------------------------------------------------------------------
+# general gnuplot graphical report generation
+
+probe timer.ms(1000) {
+ # emit gnuplot command to display recent history
+
+ printf ("set yrange [0:100]\n")
+ printf ("plot ")
+ foreach (q in qnames+)
+ {
+ if (++nq >= 2) printf (", ")
+ printf ("'-' title \"%s\" with lines", q)
+ }
+ printf ("\n")
+
+ foreach (q in qnames+) {
+ for (i = (histidx + 1) % N; i != histidx; i = (i + 1) % N)
+ printf("%d\n", util[i,q])
+ printf ("e\n")
+ }
+
+ printf ("pause 1\n")
+}