4 Copyright (c) 2015-2019 Cray Inc. All Rights Reserved.
5 Utility to display obd_devices
8 from pykdump.API import *
11 from crashlib.input import toint
12 import lustrelib as ll
13 import rpc_stats as rs
15 description_short = "Displays the contents of global 'obd_devs'"
18 def print_separator(count):
20 for idx in xrange(count):
25 print "%-19s %-22s \t%-22s %-19s %-19s %-12s %-10s %-7s %-10s" % \
35 print_separator(SEP_SIZE)
52 def print_one_device(obd, stats_flag):
54 nid = ll.obd2nidstr(obd)
57 print "0x%-17x %-22s" % (Addr(obd), ll.obd2str(obd))
67 if obd.u.cli.cl_import:
68 impstate=IMP_STATE.get(obd.u.cli.cl_import.imp_state)
69 index=obd.u.cli.cl_import.imp_state_hist_idx - 1
70 if index > 0 and index < 16:
71 ish_time=obd.u.cli.cl_import.imp_state_hist[index].ish_time
72 inflight=obd.u.cli.cl_import.imp_inflight.counter
73 connect_cnt = obd.u.cli.cl_import.imp_conn_cnt
75 print "0x%-17x %-22s\t%-22s\t 0x%-17x 0x%-17x %-10s %-10d %5d %5d" % \
80 Addr(obd.u.cli.cl_import),
87 rs.osc_rpc_stats_seq_show(Addr(obd.u.cli))
88 print_separator(SEP_SIZE)
91 def print_devices(devices, stats_flag):
96 print_one_device(obd, stats_flag)
97 print_separator(SEP_SIZE)
101 devices = [readSU('struct obd_device', args.obd_device)]
103 devices = readSymbol('obd_devs')
104 print_devices(devices, args.stats_flag)
106 if __name__ == "__main__":
107 description = "Displays the contents of global 'obd_devs'"
108 parser = argparse.ArgumentParser(description=description)
109 parser.add_argument("obd_device", nargs="?", default = [], type=toint,
110 help="print obd_device at argument address")
111 parser.add_argument("-r", dest="stats_flag", action="count",
112 help="print the rpc_stats sequence for each client_obd")
113 args = parser.parse_args()