This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
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:
socket-01-19-07.tgz
Description: application/compressed
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |