From 74939defa679347fdd0b32d804b24b9976cb7cf3 Mon Sep 17 00:00:00 2001 From: ddomingo Date: Mon, 13 Oct 2008 14:37:11 +1000 Subject: added Useful_Scripts-nettop.xml --- .../en-US/Useful_Scripts-disktop.xml | 14 +-- .../en-US/Useful_Scripts-nettop.xml | 131 +++++++++++++++++++++ .../en-US/Useful_SystemTap_Scripts.xml | 1 + 3 files changed, 139 insertions(+), 7 deletions(-) create mode 100644 doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-nettop.xml (limited to 'doc/SystemTap_Beginners_Guide') 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 0c191cff..69877c5b 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-disktop.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-disktop.xml @@ -95,19 +95,19 @@ probe end{ outputs the top ten processes responsible for the heaviest reads/writes to disk. displays a sample output for this script, and includes the following data per listed process: - UID — user ID. A user ID of 0 refers to the root user. + UID — user ID. A user ID of 0 refers to the root user. - PID — the ID of the listed process. + PID — the ID of the listed process. - PPID — the process ID of the listed process's parent process. + PPID — the process ID of the listed process's parent process. - CMD — the name of the listed process. + CMD — the name of the listed process. - DEVICE — which storage device the listed process is reading from or writing to. + DEVICE — which storage device the listed process is reading from or writing to. - T — the type of action performed by the listed process; W refers to write, while R refers to read. + T — the type of action performed by the listed process; W refers to write, while R refers to read. - BYTES — the amount of data read to or written from disk. + BYTES — the amount of data read to or written from disk. diff --git a/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-nettop.xml b/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-nettop.xml new file mode 100644 index 00000000..d56cbfc1 --- /dev/null +++ b/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-nettop.xml @@ -0,0 +1,131 @@ + + + + +
+ Kernel Profiling + + + + WAR STORY: Top network users by PID http://sourceware.org/systemtap/wiki/WSNetTop?highlight=((WarStories)) + + + + probably http://sourceware.org/systemtap/examples/network/nettop.stp + + + +This section describes how to profile network activity. provides a glimpse into how much network traffic each process is generating on a machine. + + + nettop.stp + + +global ifxmit, ifrecv, ifdevs, ifpid, execname, user + +probe netdev.transmit +{ + p = pid() + execname[p] = execname() + user[p] = uid() + ifdevs[p, dev_name] = dev_name + ifxmit[p, dev_name] <<< length + ifpid[p, dev_name] ++ +} + +probe netdev.receive +{ + p = pid() + execname[p] = execname() + user[p] = uid() + ifdevs[p, dev_name] = dev_name + ifrecv[p, dev_name] <<< length + ifpid[p, dev_name] ++ +} + + +function print_activity() +{ + printf("%5s %5s %-7s %7s %7s %7s %7s %-15s\n", + "PID", "UID", "DEV", "XMIT_PK", "RECV_PK", + "XMIT_KB", "RECV_KB", "COMMAND") + + foreach ([pid, dev] in ifpid-) { + n_xmit = @count(ifxmit[pid, dev]) + n_recv = @count(ifrecv[pid, dev]) + printf("%5d %5d %-7s %7d %7d %7d %7d %-15s\n", + pid, user[pid], dev, n_xmit, n_recv, + n_xmit ? @sum(ifxmit[pid, dev])/1024 : 0, + n_recv ? @sum(ifrecv[pid, dev])/1024 : 0, + execname[pid]) + } + + print("\n") + + delete execname + delete user + delete ifdevs + delete ifxmit + delete ifrecv + delete ifpid +} + +probe timer.ms(5000) +{ + print_activity() +} + + + + + tracks which processes are generating network traffic on the system, and provides the following information about each process: + + + PID — the ID of the listed process. + + UID — user ID. A user ID of 0 refers to the root user. + + DEV — which ethernet device the process used to send / receive data (e.g. eth0, eth1) + XMIT_PK — number of packets transmitted by the process + RECV_PK — number of packets received by the process + XMIT_KB — amount of data sent by the process, in kilobytes + RECV_KB — amount of data received by the service, in kilobytes + + + provides network profile sampling every 5 seconds. You can change this setting by editing probe timer.ms(5000) accordingly. contains an excerpt of the output from over a 20-second period: + + + + <xref linkend="nettop"/> Sample Output + +[...] + PID UID DEV XMIT_PK RECV_PK XMIT_KB RECV_KB COMMAND + 0 0 eth0 0 5 0 0 swapper +11178 0 eth0 2 0 0 0 synergyc + + PID UID DEV XMIT_PK RECV_PK XMIT_KB RECV_KB COMMAND + 2886 4 eth0 79 0 5 0 cups-polld +11362 0 eth0 0 61 0 5 firefox + 0 0 eth0 3 32 0 3 swapper + 2886 4 lo 4 4 0 0 cups-polld +11178 0 eth0 3 0 0 0 synergyc + + PID UID DEV XMIT_PK RECV_PK XMIT_KB RECV_KB COMMAND + 0 0 eth0 0 6 0 0 swapper + 2886 4 lo 2 2 0 0 cups-polld +11178 0 eth0 3 0 0 0 synergyc + 3611 0 eth0 0 1 0 0 Xorg + + PID UID DEV XMIT_PK RECV_PK XMIT_KB RECV_KB COMMAND + 0 0 eth0 3 42 0 2 swapper +11178 0 eth0 43 1 3 0 synergyc +11362 0 eth0 0 7 0 0 firefox + 3897 0 eth0 0 1 0 0 multiload-apple +[...] + + + + +
+ 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 03cb6b40..ecfc2341 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Useful_SystemTap_Scripts.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Useful_SystemTap_Scripts.xml @@ -31,6 +31,7 @@ +