summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.examples/general
diff options
context:
space:
mode:
authorTim Moore <timoore@redhat.com>2009-04-15 18:43:23 +0200
committerTim Moore <timoore@redhat.com>2009-04-15 19:00:00 +0200
commit2d45e339f3287cf0b4805ea91b3aa9f17b6d4752 (patch)
treeabd4c3faf3c774702b85a0ff6fb50da184fd5023 /testsuite/systemtap.examples/general
parent7a51212ca1895b85f400fafe0e5198525996af1d (diff)
downloadsystemtap-steved-2d45e339f3287cf0b4805ea91b3aa9f17b6d4752.tar.gz
systemtap-steved-2d45e339f3287cf0b4805ea91b3aa9f17b6d4752.tar.xz
systemtap-steved-2d45e339f3287cf0b4805ea91b3aa9f17b6d4752.zip
graphing widget and test harness
Diffstat (limited to 'testsuite/systemtap.examples/general')
-rw-r--r--testsuite/systemtap.examples/general/grapher.stp32
1 files changed, 32 insertions, 0 deletions
diff --git a/testsuite/systemtap.examples/general/grapher.stp b/testsuite/systemtap.examples/general/grapher.stp
new file mode 100644
index 00000000..04463979
--- /dev/null
+++ b/testsuite/systemtap.examples/general/grapher.stp
@@ -0,0 +1,32 @@
+#! /usr/bin/stap
+
+probe begin
+{
+printf ("%s\n", "%Title:CPU utilization");
+printf ("%s\n", "%XAxisTitle:Time");
+printf ("%s\n", "%YAxisTitle:Percent");
+printf ("%s\n", "%DataSet:cpu 100 00ff00 bar");
+printf ("%s\n", "%DataSet:kbd 100 ff0000 dot");
+}
+
+# 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") }
+
+global qnames
+
+function qsq_util_reset(q) {
+ u=qsq_utilization (q, 100)
+ qsq_start (q)
+ return u
+}
+
+probe timer.ms(100) { # collect utilization percentages frequently
+ foreach (q in qnames)
+ printf("cpu %d %d\n", gettimeofday_ms(), qsq_util_reset(q))
+}
+
+probe kernel.function("kbd_event") {
+ printf("kbd %d %d\n", gettimeofday_ms(), 75)
+}