summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2009-04-28 14:10:31 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2009-04-28 14:10:31 -0300
commitc2f3a5945bd4e2950f5c18c92c82034866a8252c (patch)
tree4f092b9986268c82526ca7ee3f0d544c8d5d4928
parentc5e2697b58e5a9da3ab24e6ee595cb7a8bb332b9 (diff)
downloadpython-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-xpsk.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/psk.py b/psk.py
index 42d6574..dbe2d9b 100755
--- a/psk.py
+++ b/psk.py
@@ -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 ]