public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* Sockets tapset and script
@ 2006-11-17 23:19 Mike Mason
  2006-11-21 17:23 ` Martin Hunt
  2007-01-19 18:09 ` Sockets tapset and script - UPDATE Mike Mason
  0 siblings, 2 replies; 6+ messages in thread
From: Mike Mason @ 2006-11-17 23:19 UTC (permalink / raw)
  To: systemtap

[-- Attachment #1: Type: text/plain, Size: 4731 bytes --]

Attached is a sockets tapset and a script that uses the tapset.  I thought I'd post them for review even though they're not done.  The tapset just contains what I needed to write the script.  More comments, probes and helper functions are needed.  I also need to write some tests.

The tapset contains functions to map numbers to strings and strings to numbers for:

- protocols
- protocol families
- socket types
- socket states
- socket flags
- message flags

Mapping functions are something I think script writers need, not just for sockets, but in a lot of other areas. Some of these functions using mapping arrays.  What do people think of this approach?

The script (socktop) prints socket traffic for the top n processes and, optionally, network device traffic. Besides being a useful script (I hope), it demonstrates a few methods that should be applicable to many scripts:

- using a shell script to process command line options
- filtering on multiple categories (in this case, process ID and name, user name, protocol, protocol family and socket type)
- passing array-like data from a shell script to a systemtap script and tokenizing that data in systemtap
- passing in a timezone adjustment

Also, note the sign bit hack in the return probes. This is something I'd like to remove before posting the script on the wiki (hint, hint :-).

Here's some example output from socktop:

[root@localhost probes]# ./socktop -P TCP -P UDP -d
======================= Fri Nov 17 14:10:57 2006 ========================
------------------------------- PROCESSES -------------------------------
PID   UID     #SEND   #RECV SEND_KB RECV_KB PROT FAMILY   COMMAND
14668 0           0    2546       0    3635 TCP  INET     firefox-bin
6765  0          10      10      31       0 TCP  INET     Xvnc
-------------------------------- DEVICES --------------------------------
DEV             #XMIT         #RECV         XMIT_KB         RECV_KB
eth0             1396          2643             121            3769
=========================================================================

======================= Fri Nov 17 14:11:02 2006 ========================
------------------------------- PROCESSES -------------------------------
PID   UID     #SEND   #RECV SEND_KB RECV_KB PROT FAMILY   COMMAND
14668 0           0    2457       0    3487 TCP  INET     firefox-bin
6765  0          11      11      14       0 TCP  INET     Xvnc
29852 0           2       0       0       0 TCP  INET6    sshd
-------------------------------- DEVICES --------------------------------
DEV             #XMIT         #RECV         XMIT_KB         RECV_KB
eth0             1309          2533              98            3620
=========================================================================

======================= Fri Nov 17 14:11:07 2006 ========================
------------------------------- PROCESSES -------------------------------
PID   UID     #SEND   #RECV SEND_KB RECV_KB PROT FAMILY   COMMAND
14668 0           0    1886       0    2676 TCP  INET     firefox-bin
6765  0          83     292     532       2 TCP  INET     Xvnc
29852 0           1       0       0       0 TCP  INET6    sshd
-------------------------------- DEVICES --------------------------------
DEV             #XMIT         #RECV         XMIT_KB         RECV_KB
eth0             1501          2478             624            2797
=========================================================================


[root@localhost probes]# ./socktop -d
======================= Fri Nov 17 14:09:45 2006 ========================
------------------------------- PROCESSES -------------------------------
PID   UID     #SEND   #RECV SEND_KB RECV_KB PROT FAMILY   COMMAND
14668 0           0    2796       0    3969 TCP  INET     firefox-bin
6765  0         221     284     535     429 IP   LOCAL    Xvnc
6909  0          77     139     277     276 IP   LOCAL    wnck-applet
14668 0          53      79     103     220 IP   LOCAL    firefox-bin
6840  0          61     125      26      17 IP   LOCAL    metacity
6902  0          21      27      21      21 IP   LOCAL    nautilus
6765  0          11      11      32       0 TCP  INET     Xvnc
6900  0           3       7       0       0 IP   LOCAL    gnome-panel
6820  0           0       8       0       0 IP   LOCAL    gnome-settings-
1610  0           1       3       0       0 IP   NETLINK  ifconfig
-------------------------------- DEVICES --------------------------------
DEV             #XMIT         #RECV         XMIT_KB         RECV_KB
eth0             1516          2888             129            4115
=========================================================================


All comments are welcome.

Mike Mason


 





[-- Attachment #2: sockets.tgz --]
[-- Type: application/x-compressed, Size: 7633 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-01-19 18:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-17 23:19 Sockets tapset and script Mike Mason
2006-11-21 17:23 ` Martin Hunt
2006-11-22  0:05   ` David Smith
2006-11-28  2:23   ` Mike Mason
2006-11-28 23:57     ` David Smith
2007-01-19 18:09 ` Sockets tapset and script - UPDATE Mike Mason

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).