diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-04-28 14:10:31 -0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-04-28 14:10:31 -0300 |
commit | c2f3a5945bd4e2950f5c18c92c82034866a8252c (patch) | |
tree | 4f092b9986268c82526ca7ee3f0d544c8d5d4928 | |
parent | c5e2697b58e5a9da3ab24e6ee595cb7a8bb332b9 (diff) | |
download | python-inet_diag-c2f3a5945bd4e2950f5c18c92c82034866a8252c.tar.gz |
psk: show if timers are running and which
At the end of the line
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rwxr-xr-x | psk.py | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -18,7 +18,8 @@ import getopt, inet_diag, os, re, sys, procfs version="0.1" state_width = 10 -addr_width = 20 +addr_width = 15 +timer_width = 7 def load_sockets(): idiag = inet_diag.create() @@ -52,11 +53,15 @@ def thread_mapper(s): def print_sockets(pid, indent = 0): header_printed = False dirname = "/proc/%d/fd" % pid - for filename in os.listdir(dirname): + try: + filenames = os.listdir(dirname) + except: # Process died + return + for filename in filenames: pathname = os.path.join(dirname, filename) try: linkto = os.readlink(pathname) - except: + except: # Process died continue inode_match = inode_re.match(linkto) if not inode_match: @@ -72,11 +77,12 @@ def print_sockets(pid, indent = 0): return header_printed = True s = inodes[inode] - print " %-*s %-6d %-6d %*s:%-5d %*s:%-5d" % \ + print " %-*s %-6d %-6d %*s:%-5d %*s:%-5d %-*s" % \ (state_width, s.state(), s.receive_queue(), s.write_queue(), addr_width, s.saddr(), s.sport(), - addr_width, s.daddr(), s.dport()) + addr_width, s.daddr(), s.dport(), + timer_width, s.timer()) def usage(): print '''Usage: psk [ OPTIONS ] |