From 338e2309ef67c7b0d1ac3df852502e55bc316c8a Mon Sep 17 00:00:00 2001 From: ddomingo Date: Mon, 29 Sep 2008 16:08:53 +1000 Subject: added sections to Useful Scripts (graphs, disktop) --- .../en-US/Author_Group.xml | 2 +- .../en-US/Useful_Scripts-Disk.xml | 124 ++++++++++++++++++++- .../en-US/Useful_Scripts-disktop.xml | 77 ------------- .../en-US/Useful_SystemTap_Scripts.xml | 7 ++ .../en-US/Using_SystemTap.xml | 27 ++++- 5 files changed, 155 insertions(+), 82 deletions(-) (limited to 'doc/SystemTap_Beginners_Guide') diff --git a/doc/SystemTap_Beginners_Guide/en-US/Author_Group.xml b/doc/SystemTap_Beginners_Guide/en-US/Author_Group.xml index c19ae8f0..676af712 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Author_Group.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Author_Group.xml @@ -6,7 +6,7 @@ Red Hat Enterprise Linux Documentation Don - Domingo + Domingo Engineering Services and Operations Content Services diff --git a/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-Disk.xml b/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-Disk.xml index a5df51b6..a7c16b25 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-Disk.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-Disk.xml @@ -3,8 +3,9 @@ ]> -
- Disk +
+ Real-Time Graphing of Disk and CPU Utilization + http://sourceware.org/systemtap/examples/subsystem-index.html @@ -12,10 +13,127 @@ Graphing Disk and CPU Utilization - http://sourceware.org/systemtap/examples/general/graphs.stp + + This section describes how you can graph disk and CPU utilization in real-time, i.e. in samples of 1 second each. + + + disk-usage-graph.stp + + +#! stap +# 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") +} + + + + + outputs raw statistics on both CPU and disk usage per second. I/O usage is tracked through the events ioblock.request and ioblock.request.end, which track each request (and request completion) for a generic block I/O. CPU usage is tracked through scheduler.cpu_on and scheduler.cpu_off, which are activated whenever a process begins (and ends) a command execution on a CPU. + +
+ gnuplot +Running by itself hardly presents any data that is useful, as in . + +Raw disk-usage-graph.stp Output + +[...] +62 +5 +3 +4 +6 +4 +4 +5 +5 +3 +6 +5 +e +pause 1 + + + +However, refining the output of through gnuplot presents us with a more useful result. gnuplot is a lightweight, command-line driven plotting program that helps you display data in a graphical format. + +By piping output to gnuplot (as in stap disk-usage-gr + http://sourceware.org/systemtap/examples/subsystem-index.html + + + Graphing Disk and CPU Utilization - http://sourceware.org/systemtap/examples/general/graphs.stp + aph.stp | gnuplot), we get a graphical output similar to the following: + +
+ Graphical Output Sample + + + + + + Sample output + + + + Sample output of when piped through gnuplot + + + +
+ + presents a cleaner, more useful graphical output. This graph can show you the level of utilization for both I/O and CPU, in real time. + + + question: does this script also capture stap process? i.e. does the graph also include CPU utilization by systemtap while the script is running? + + + + + +
diff --git a/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-disktop.xml b/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-disktop.xml index df6477de..a3e3d8a7 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-disktop.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-disktop.xml @@ -130,83 +130,6 @@ UID PID PPID CMD DEVICE T BYTES - - - - - - - - - - - outputs raw statistics on both CPU and disk usage per second. I/O usage is tracked through the events ioblock.request and ioblock.request.end, which track each request (and request completion) for a generic block I/O. CPU usage is tracked through scheduler.cpu_on and scheduler.cpu_off, which are activated whenever a process begins (and ends) a command execution on a CPU. - -
- gnuplot -Running by itself hardly presents any data that is useful, as in . - -Raw disk-usage-graph.stp Output - -[...] -62 -5 -3 -4 -6 -4 -4 -5 -5 -3 -6 -5 -e -pause 1 - - -However, refining the output of through gnuplot presents us with a more useful result. gnuplot is a lightweight, command-line driven plotting program that helps you display data in a graphical format. - -By piping output to gnuplot (as in stap disk-usage-graph.stp | gnuplot), we get a graphical output similar to the following: - -
- Graphical Output Sample - - - - - - Sample output - - - - Sample output of when piped through gnuplot - - - -
- - presents a cleaner, more useful graphical output. This graph can show you the level of utilization for both I/O and CPU, in real time. - - - question: does this script also capture stap process? i.e. does the graph also include CPU utilization by systemtap while the script is running? - - - - - http://sourceware.org/systemtap/examples/subsystem-index.html - - - - Graphing Disk and CPU Utilization - http://sourceware.org/systemtap/examples/general/graphs.stp - - - - - Summarize Disk Read/Write Traffic - http://sourceware.org/systemtap/examples/io/disktop.stp - -
diff --git a/doc/SystemTap_Beginners_Guide/en-US/Useful_SystemTap_Scripts.xml b/doc/SystemTap_Beginners_Guide/en-US/Useful_SystemTap_Scripts.xml index d3cfb897..51fef276 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Useful_SystemTap_Scripts.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Useful_SystemTap_Scripts.xml @@ -4,6 +4,12 @@ Useful SystemTap Scripts + + This chapter enumerates several SystemTap scripts you can use to monitor and investigate different subsystems. All of these scripts are available at the following link: + + http://sourceware.org/systemtap/examples/subsystem-index.html + + short intro, reference to online source (http://sourceware.org/systemtap/examples/subsystem-index.html); "always updated" @@ -13,6 +19,7 @@ case studies and more info on some scripts here - http://sourceware.org/systemtap/wiki/WarStories + diff --git a/doc/SystemTap_Beginners_Guide/en-US/Using_SystemTap.xml b/doc/SystemTap_Beginners_Guide/en-US/Using_SystemTap.xml index 30c8500f..01e30fc7 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Using_SystemTap.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Using_SystemTap.xml @@ -43,7 +43,7 @@ uname -r You will also need to configure yum to point to a repository that houses the necessary debug RPMs. One such repository is: - + ftp://ftp.redhat.com/pub/redhat/linux/enterprise/5Client/en/os/i386/Debuginfo/ find any other such repository, if only for RHEL @@ -146,6 +146,13 @@ uname -r + + -e "[script] + + Run given [script]. + + + +You can also instruct stap to run scripts from standard input using the switch -. To illustrate: + + + Running Scripts From Standard Input + +echo "probe timer.s(1) {exit()}" | stap - + + + + instructs stap to run the script passed by echo to standard input. Any stap options you wish to use should be inserted before the - switch; for instance, to make the example in more verbose, the command would be: + +echo "probe timer.s(1) {exit()}" | stap -v - + any other useful options worth noting here for beginners? For more information about stap, refer to man stap. To run SystemTap instrumentation (i.e. the kernel module built from SystemTap scripts during a cross-instrumentation), use staprun instead. For more information about staprun and cross-instrumentation, refer to . + + Note + The stap options -v and -o also work for staprun. For more information about staprun, refer to man staprun. + + -- cgit