From: Mike Mason <mmlnx@us.ibm.com>
To: systemtap@sources.redhat.com
Subject: Sockets tapset and script
Date: Fri, 17 Nov 2006 23:19:00 -0000 [thread overview]
Message-ID: <455E3718.8030202@us.ibm.com> (raw)
[-- 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 --]
next reply other threads:[~2006-11-17 22:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-17 23:19 Mike Mason [this message]
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
2006-11-22 0:45 Sockets tapset and script Stone, Joshua I
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=455E3718.8030202@us.ibm.com \
--to=mmlnx@us.ibm.com \
--cc=systemtap@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).