diff options
Diffstat (limited to 'testsuite/systemtap.examples/general')
-rwxr-xr-x | testsuite/systemtap.examples/general/ansi_colors.stp | 21 | ||||
-rw-r--r-- | testsuite/systemtap.examples/general/click.wav | bin | 0 -> 1290 bytes | |||
-rw-r--r-- | testsuite/systemtap.examples/general/graphs.meta | 13 | ||||
-rw-r--r-- | testsuite/systemtap.examples/general/graphs.stp | 60 | ||||
-rw-r--r-- | testsuite/systemtap.examples/general/helloworld.meta | 13 | ||||
-rwxr-xr-x | testsuite/systemtap.examples/general/helloworld.stp | 2 | ||||
-rwxr-xr-x | testsuite/systemtap.examples/general/key.stp | 22 | ||||
-rwxr-xr-x | testsuite/systemtap.examples/general/keyhack.stp | 15 | ||||
-rw-r--r-- | testsuite/systemtap.examples/general/para-callgraph.meta | 13 | ||||
-rw-r--r-- | testsuite/systemtap.examples/general/para-callgraph.stp | 20 | ||||
-rw-r--r-- | testsuite/systemtap.examples/general/return.wav | bin | 0 -> 6584 bytes |
11 files changed, 179 insertions, 0 deletions
diff --git a/testsuite/systemtap.examples/general/ansi_colors.stp b/testsuite/systemtap.examples/general/ansi_colors.stp new file mode 100755 index 00000000..0d9d7c47 --- /dev/null +++ b/testsuite/systemtap.examples/general/ansi_colors.stp @@ -0,0 +1,21 @@ +#! /usr/bin/env stap + +probe begin { + printf("a \\ b |"); + for (c = 40; c < 48; c++) + printf(" %d ", c); + printf("\12"); + for (l = 0; l < 71; l++) + printf("-"); + printf("\12"); + + for (r = 30; r < 38; r++) + for (t = 0; t < 2; t++) { + printf("%d |", r); + for (c = 40; c < 48; c++) + printf("\033[%d;%d%s %s \033[0;0m", + r, c, !t ? "m" : ";1m", !t ? "Normal" : "Bold "); + printf("\12"); + } + exit(); +} diff --git a/testsuite/systemtap.examples/general/click.wav b/testsuite/systemtap.examples/general/click.wav Binary files differnew file mode 100644 index 00000000..8214b229 --- /dev/null +++ b/testsuite/systemtap.examples/general/click.wav diff --git a/testsuite/systemtap.examples/general/graphs.meta b/testsuite/systemtap.examples/general/graphs.meta new file mode 100644 index 00000000..60a522b3 --- /dev/null +++ b/testsuite/systemtap.examples/general/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/general/graphs.stp b/testsuite/systemtap.examples/general/graphs.stp new file mode 100644 index 00000000..0c8e3796 --- /dev/null +++ b/testsuite/systemtap.examples/general/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") +} diff --git a/testsuite/systemtap.examples/general/helloworld.meta b/testsuite/systemtap.examples/general/helloworld.meta new file mode 100644 index 00000000..60bc53f2 --- /dev/null +++ b/testsuite/systemtap.examples/general/helloworld.meta @@ -0,0 +1,13 @@ +title: SystemTap "Hello World" Program +name: helloworld.stp +version: 1.0 +keywords: simple +author: anonymous +subsystem: none +status: production +exit: fixed +output: text +scope: system-wide +description: A basic "Hello World" program implemented in SystemTap script. It prints out "hello world" message and then immediately exits. +test_check: stap -p4 helloworld.stp +test_installcheck: stap helloworld.stp diff --git a/testsuite/systemtap.examples/general/helloworld.stp b/testsuite/systemtap.examples/general/helloworld.stp new file mode 100755 index 00000000..efe45b79 --- /dev/null +++ b/testsuite/systemtap.examples/general/helloworld.stp @@ -0,0 +1,2 @@ +#! /usr/bin/env stap +probe begin { println("hello world") exit () } diff --git a/testsuite/systemtap.examples/general/key.stp b/testsuite/systemtap.examples/general/key.stp new file mode 100755 index 00000000..6d2d6c3f --- /dev/null +++ b/testsuite/systemtap.examples/general/key.stp @@ -0,0 +1,22 @@ +#! /usr/bin/env stap + +# Useless, but amusing. Based on an idea I saw on a +# dtrace site. (wav files are from emacs). + +// KEY_ENTER = 28 +probe kernel.function("kbd_event") { + if ($event_type == 1 && $value) { + if ($event_code == 28) + system("play return.wav &> /dev/null") + else + system("play click.wav &> /dev/null") + } +} + +probe begin { + printf("TYPEWRITER ON\n") +} + +probe end { + printf("DONE\n") +} diff --git a/testsuite/systemtap.examples/general/keyhack.stp b/testsuite/systemtap.examples/general/keyhack.stp new file mode 100755 index 00000000..3137baad --- /dev/null +++ b/testsuite/systemtap.examples/general/keyhack.stp @@ -0,0 +1,15 @@ +#! /usr/bin/env stap + +# This is not useful, but it demonstrates that +# Systemtap can modify variables in a running kernel. + +# Usage: ./keyhack.stp -g + +probe kernel.function("kbd_event") { + # Changes 'm' to 'b' . + if ($event_code == 50) $event_code = 48 +} + +probe end { + printf("\nDONE\n") +} diff --git a/testsuite/systemtap.examples/general/para-callgraph.meta b/testsuite/systemtap.examples/general/para-callgraph.meta new file mode 100644 index 00000000..3ce4b648 --- /dev/null +++ b/testsuite/systemtap.examples/general/para-callgraph.meta @@ -0,0 +1,13 @@ +title: Tracing Calls for Sections of Code +name: para-callgraph.stp +version: 1.0 +author: anonymous +keywords: trace callgraph +subsystem: kernel +status: production +exit: user-controlled +output: trace +scope: system-wide +description: The script takes two arguments: the first argument is the function to starts/stops the per thread call graph traces and the second argument is the list of functions to generate trace information on. The script prints out a timestap for the thread, the function name and pid, followed by entry or exit symboly and function name. +test_check: stap -p4 para-callgraph.stp sys_read "*@fs/*.c" +test_installcheck: stap para-callgraph.stp sys_read "*@fs/*.c" -c "sleep 1" diff --git a/testsuite/systemtap.examples/general/para-callgraph.stp b/testsuite/systemtap.examples/general/para-callgraph.stp new file mode 100644 index 00000000..1afb8837 --- /dev/null +++ b/testsuite/systemtap.examples/general/para-callgraph.stp @@ -0,0 +1,20 @@ +function trace(entry_p) { + if(tid() in trace) + printf("%s%s%s\n",thread_indent(entry_p), + (entry_p>0?"->":"<-"), + probefunc()) +} + +global trace +probe kernel.function(@1).call { + if (execname() == "stapio") next # skip our own helper process + trace[tid()] = 1 + trace(1) +} +probe kernel.function(@1).return { + trace(-1) + delete trace[tid()] +} + +probe kernel.function(@2).call { trace(1) } +probe kernel.function(@2).return { trace(-1) } diff --git a/testsuite/systemtap.examples/general/return.wav b/testsuite/systemtap.examples/general/return.wav Binary files differnew file mode 100644 index 00000000..20f978cc --- /dev/null +++ b/testsuite/systemtap.examples/general/return.wav |