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 range(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)
55 except Exception as e:
57 print("0x%-17x %-22s" % (Addr(obd), ll.obd2str(obd)))
58 except Exception as e:
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),
86 print(rs.osc_rpc_stats_seq_show(Addr(obd.u.cli)))
87 print_separator(SEP_SIZE)
90 def print_devices(devices, stats_flag):
95 print_one_device(obd, stats_flag)
96 print_separator(SEP_SIZE)
100 devices = [readSU('struct obd_device', args.obd_device)]
102 devices = readSymbol('obd_devs')
103 print_devices(devices, args.stats_flag)
105 if __name__ == "__main__":
106 description = "Displays the contents of global 'obd_devs'"
107 parser = argparse.ArgumentParser(description=description)
108 parser.add_argument("obd_device", nargs="?", default = [], type=toint,
109 help = "print obd_device at argument address")
110 parser.add_argument("-r", dest="stats_flag", action="count",
111 help = "print the rpc_stats sequence for each client_obd")
112 args = parser.parse_args()