~devstack-core/devstack/github

« back to all changes in this revision

Viewing changes to tools/worlddump.py

  • Committer: Gerrit Code Review
  • Author(s): Jenkins
  • Date: 2015-05-12 18:48:31 UTC
  • mfrom: (3178.1.1)
  • Revision ID: git-v1:a51db5503e07345452eba1b1e1bc7097bc9b0e51
Merge "add network info to the worlddump"

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
75
 
64
76
def iptables_dump():
65
77
    tables = ['filter', 'nat', 'mangle']
66
 
    print """
67
 
IP Tables Dump
68
 
===============
69
 
"""
 
78
    _header("IP Tables Dump")
 
79
 
70
80
    for table in tables:
71
 
        print os.popen("sudo iptables --line-numbers -L -nv -t %s"
72
 
                       % table).read()
 
81
        _dump_cmd("sudo iptables --line-numbers -L -nv -t %s" % table)
 
82
 
 
83
 
 
84
def network_dump():
 
85
    _header("Network Dump")
 
86
 
 
87
    _dump_cmd("brctl show")
 
88
    _dump_cmd("arp -n")
 
89
    _dump_cmd("ip addr")
 
90
    _dump_cmd("ip link")
 
91
    _dump_cmd("ip route")
73
92
 
74
93
 
75
94
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
 
95
    _header("Process Listing")
 
96
    _dump_cmd("ps axo "
 
97
              "user,ppid,pid,pcpu,pmem,vsz,rss,tty,stat,start,time,args")
82
98
 
83
99
 
84
100
def main():
90
106
        os.dup2(f.fileno(), sys.stdout.fileno())
91
107
        disk_space()
92
108
        process_list()
 
109
        network_dump()
93
110
        iptables_dump()
94
111
 
95
112