From 1c0f18a9730f1fa5990c79debfc1960b08c8b7cf Mon Sep 17 00:00:00 2001 From: William Cohen Date: Wed, 10 Dec 2008 14:49:46 -0500 Subject: Edit useful script examples. Clean up formating para-call-graph-simple.stp --- .../en-US/Useful_Scripts-iotime.xml | 15 +++++---- .../en-US/Useful_Scripts-nettop.xml | 13 +++++--- .../en-US/extras/para-callgraph-simple.stp | 36 +++++++++++----------- 3 files changed, 33 insertions(+), 31 deletions(-) (limited to 'doc/SystemTap_Beginners_Guide/en-US') diff --git a/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-iotime.xml b/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-iotime.xml index 21b6db9d..7a1633aa 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-iotime.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-iotime.xml @@ -68,13 +68,12 @@ <xref linkend="iotime"/> Sample Output [...] -3123380 2460 (pcscd) access /dev/bus/usb/005/001 read: 0 write: 0 -825946 3364 (NetworkManager) access /sys/class/net/eth0/carrier read: 8190 write: 0 -825955 3364 (NetworkManager) iotime /sys/class/net/eth0/carrier time: 9 -117061 2460 (pcscd) access /dev/bus/usb/003/001 read: 43 write: 0 -117065 2460 (pcscd) iotime /dev/bus/usb/003/001 time: 7 -3973737 2886 (sendmail) access /proc/loadavg read: 4096 write: 0 -3973744 2886 (sendmail) iotime /proc/loadavg time: 11 +825946 3364 (NetworkManager) access /sys/class/net/eth0/carrier read: 8190 write: 0 +825955 3364 (NetworkManager) iotime /sys/class/net/eth0/carrier time: 9 +117061 2460 (pcscd) access /dev/bus/usb/003/001 read: 43 write: 0 +117065 2460 (pcscd) iotime /dev/bus/usb/003/001 time: 7 +3973737 2886 (sendmail) access /proc/loadavg read: 4096 write: 0 +3973744 2886 (sendmail) iotime /proc/loadavg time: 11 [...] @@ -137,4 +136,4 @@ print("\n") } --> - \ No newline at end of file + diff --git a/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-nettop.xml b/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-nettop.xml index c51d4b66..2d7e3595 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-nettop.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-nettop.xml @@ -63,20 +63,23 @@ if/else conditionals, alternative syntax examples of SystemTap scripts -Note that function print_activity() uses the following constructs: +Note that function print_activity() uses the following +expressions: -n_xmit ? @sum(ifxmit[pid, dev, exec, uid])/1024 : 0, +n_xmit ? @sum(ifxmit[pid, dev, exec, uid])/1024 : 0 n_recv ? @sum(ifrecv[pid, dev, exec, uid])/1024 : 0 -These constructs are if/else conditionals. The first statement is simply a more concise way of writing: +These expressions are if/else conditionals. +The first statement is simply a more concise way of writing the following +psuedo code: if n_recv != 0 then - @sum(ifrecv[pid, dev, exec, uid])/1024 + @sum(ifrecv[pid, dev, exec, uid])/1024 else - 0 + 0 tracks which processes are generating network traffic on the system, and provides the following information about each process: diff --git a/doc/SystemTap_Beginners_Guide/en-US/extras/para-callgraph-simple.stp b/doc/SystemTap_Beginners_Guide/en-US/extras/para-callgraph-simple.stp index 17cf50a5..1a3e2e03 100755 --- a/doc/SystemTap_Beginners_Guide/en-US/extras/para-callgraph-simple.stp +++ b/doc/SystemTap_Beginners_Guide/en-US/extras/para-callgraph-simple.stp @@ -1,39 +1,39 @@ function trace(entry_p) { - if(tid() in trace) - printf("%s%s%s\n",thread_indent(entry_p), - (entry_p>0?"->":"<-"), - probefunc()) + 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) + if (execname() == "stapio") next # skip our own helper process + trace[tid()] = 1 + trace(1) } probe kernel.function(@1).return { - trace(-1) - delete trace[tid()] + trace(-1) + delete trace[tid()] } probe kernel.function(@2).call { trace(1) } probe kernel.function(@2).return { trace(-1) } function trace(entry_p) { - if(tid() in trace) - printf("%s%s%s\n",thread_indent(entry_p), - (entry_p>0?"->":"<-"), - probefunc()) + 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) + if (execname() == "stapio") next # skip our own helper process + trace[tid()] = 1 + trace(1) } probe kernel.function(@1).return { - trace(-1) - delete trace[tid()] + trace(-1) + delete trace[tid()] } probe kernel.function(@2).call { trace(1) } -- cgit