From 60a140571ea3a4ad07772f1eedae6d4d1a6e4c67 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 11 May 2015 14:53:39 -0400 Subject: [PATCH] add network info to the worlddump This adds potentially helpful networking info to the world dump. It also refactors some of the output mechanisms into reusable functions for cleanliness in the code. Change-Id: I39f95bd487c152925f8fadd1799149db35cffd52 --- tools/worlddump.py | 49 +++++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/tools/worlddump.py b/tools/worlddump.py index cb32510526..7f2614dcaa 100755 --- a/tools/worlddump.py +++ b/tools/worlddump.py @@ -41,12 +41,24 @@ def warn(msg): print "WARN: %s" % msg +def _dump_cmd(cmd): + print cmd + print "-" * len(cmd) + print + print os.popen(cmd).read() + + +def _header(name): + print + print name + print "=" * len(name) + print + + def disk_space(): # the df output - print """ -File System Summary -=================== -""" + _header("File System Summary") + dfraw = os.popen("df -Ph").read() df = [s.split() for s in dfraw.splitlines()] for fs in df: @@ -63,22 +75,26 @@ File System Summary def iptables_dump(): tables = ['filter', 'nat', 'mangle'] - print """ -IP Tables Dump -=============== -""" + _header("IP Tables Dump") + for table in tables: - print os.popen("sudo iptables --line-numbers -L -nv -t %s" - % table).read() + _dump_cmd("sudo iptables --line-numbers -L -nv -t %s" % table) + + +def network_dump(): + _header("Network Dump") + + _dump_cmd("brctl show") + _dump_cmd("arp -n") + _dump_cmd("ip addr") + _dump_cmd("ip link") + _dump_cmd("ip route") def process_list(): - print """ -Process Listing -=============== -""" - psraw = os.popen("ps axo user,ppid,pid,pcpu,pmem,vsz,rss,tty,stat,start,time,args").read() - print psraw + _header("Process Listing") + _dump_cmd("ps axo " + "user,ppid,pid,pcpu,pmem,vsz,rss,tty,stat,start,time,args") def main(): @@ -90,6 +106,7 @@ def main(): os.dup2(f.fileno(), sys.stdout.fileno()) disk_space() process_list() + network_dump() iptables_dump()