Browse code

Merge "add network info to the worlddump"

Jenkins authored on 2015/05/13 03:48:31
Showing 1 changed files
... ...
@@ -41,12 +41,24 @@ def warn(msg):
41 41
     print "WARN: %s" % msg
42 42
 
43 43
 
44
+def _dump_cmd(cmd):
45
+    print cmd
46
+    print "-" * len(cmd)
47
+    print
48
+    print os.popen(cmd).read()
49
+
50
+
51
+def _header(name):
52
+    print
53
+    print name
54
+    print "=" * len(name)
55
+    print
56
+
57
+
44 58
 def disk_space():
45 59
     # the df output
46
-    print """
47
-File System Summary
48
-===================
49
-"""
60
+    _header("File System Summary")
61
+
50 62
     dfraw = os.popen("df -Ph").read()
51 63
     df = [s.split() for s in dfraw.splitlines()]
52 64
     for fs in df:
... ...
@@ -63,22 +75,26 @@ File System Summary
63 63
 
64 64
 def iptables_dump():
65 65
     tables = ['filter', 'nat', 'mangle']
66
-    print """
67
-IP Tables Dump
68
-===============
69
-"""
66
+    _header("IP Tables Dump")
67
+
70 68
     for table in tables:
71
-        print os.popen("sudo iptables --line-numbers -L -nv -t %s"
72
-                       % table).read()
69
+        _dump_cmd("sudo iptables --line-numbers -L -nv -t %s" % table)
70
+
71
+
72
+def network_dump():
73
+    _header("Network Dump")
74
+
75
+    _dump_cmd("brctl show")
76
+    _dump_cmd("arp -n")
77
+    _dump_cmd("ip addr")
78
+    _dump_cmd("ip link")
79
+    _dump_cmd("ip route")
73 80
 
74 81
 
75 82
 def process_list():
76
-    print """
77
-Process Listing
78
-===============
79
-"""
80
-    psraw = os.popen("ps axo user,ppid,pid,pcpu,pmem,vsz,rss,tty,stat,start,time,args").read()
81
-    print psraw
83
+    _header("Process Listing")
84
+    _dump_cmd("ps axo "
85
+              "user,ppid,pid,pcpu,pmem,vsz,rss,tty,stat,start,time,args")
82 86
 
83 87
 
84 88
 def main():
... ...
@@ -90,6 +106,7 @@ def main():
90 90
         os.dup2(f.fileno(), sys.stdout.fileno())
91 91
         disk_space()
92 92
         process_list()
93
+        network_dump()
93 94
         iptables_dump()
94 95
 
95 96