summaryrefslogtreecommitdiffstats
path: root/stap_tutorial-1.0/examples/top-cs.stp
diff options
context:
space:
mode:
authorSteve Dickson <steved@redhat.com>2008-01-29 15:02:30 -0500
committerSteve Dickson <steved@redhat.com>2008-01-29 15:02:30 -0500
commita0630d519e87f5c5d851d3127085a50592bb20b4 (patch)
tree589aff766c2131f715b595de40ed19b57719b0cb /stap_tutorial-1.0/examples/top-cs.stp
downloadsystemtap-a0630d519e87f5c5d851d3127085a50592bb20b4.tar.gz
systemtap-a0630d519e87f5c5d851d3127085a50592bb20b4.tar.xz
systemtap-a0630d519e87f5c5d851d3127085a50592bb20b4.zip
Initial Commit
Diffstat (limited to 'stap_tutorial-1.0/examples/top-cs.stp')
-rwxr-xr-xstap_tutorial-1.0/examples/top-cs.stp29
1 files changed, 29 insertions, 0 deletions
diff --git a/stap_tutorial-1.0/examples/top-cs.stp b/stap_tutorial-1.0/examples/top-cs.stp
new file mode 100755
index 0000000..efe5769
--- /dev/null
+++ b/stap_tutorial-1.0/examples/top-cs.stp
@@ -0,0 +1,29 @@
+#!/usr/bin/env stap
+#
+# Continuously list the top context switchers
+#
+
+global processes
+
+probe begin {
+ printf("Collecting data...\n")
+}
+
+function print_top () {
+ printf("Process\t\t\t\tCount\n")
+ printf("--------------------------------------\n")
+ foreach (name in processes- limit 20)
+ printf("%-20s\t\t%5d\n",name, processes[name])
+ printf("--------------------------------------\n\n")
+ delete processes
+}
+
+probe scheduler.cpu_on {
+ processes[execname()]++
+}
+
+# print top context switchers every 10 seconds
+probe timer.s(10) {
+ print_top ()
+}
+