4 Copyright (c) 2015-2018 Cray Inc. All Rights Reserved.
5 Utility to display rpc stats for a client_obd
8 from pykdump.API import *
11 import lustrelib as ll
12 from crashlib.input import toint
14 description_short = 'Dumps the rpc stats for a given client_obd'
18 def get_cli_obd(client_obd):
21 cli = readSU('struct client_obd', client_obd)
23 for dev in readSymbol('obd_devs'):
25 if ll.obd2str(dev, 4) == client_obd:
33 return 100 * a / b if b else 0
35 def lprocfs_oh_sum(oh):
37 for i in range(OBD_HIST_MAX):
38 ret += oh.oh_buckets[i]
41 def osc_rpc_stats_seq_show(client_obd):
43 print "invalid input for field 'client_obd'"
45 cli = readSU('struct client_obd', client_obd)
46 print "read RPCs in flight: %d" % cli.cl_r_in_flight
47 print "write RPCs in flight: %d" % cli.cl_w_in_flight
48 print "pending write pages: %d" % cli.cl_pending_w_pages.counter
49 print "pending read pages: %d" % cli.cl_pending_r_pages.counter
51 print "\n\t\t\tread\t\t\twrite"
52 print "pages per rpc rpcs % cum % | rpcs % cum %\n"
54 read_tot = lprocfs_oh_sum(cli.cl_read_page_hist)
55 write_tot = lprocfs_oh_sum(cli.cl_write_page_hist)
59 for i in range(OBD_HIST_MAX):
60 r = cli.cl_read_page_hist.oh_buckets[i]
61 w = cli.cl_write_page_hist.oh_buckets[i]
65 print "%d:\t\t%10d %3d %3d | %10d %3d %3d" % \
66 (1 << i, r, pct(r, read_tot),
67 pct(read_cum, read_tot), w,
69 pct(write_cum, write_tot))
70 if read_cum == read_tot and write_cum == write_tot:
73 print "\n\t\t\tread\t\t\twrite"
74 print "rpcs in flight rpcs % cum % | rpcs % cum %\n"
76 read_tot = lprocfs_oh_sum(cli.cl_read_rpc_hist)
77 write_tot = lprocfs_oh_sum(cli.cl_write_rpc_hist)
81 for i in range(OBD_HIST_MAX):
82 r = cli.cl_read_rpc_hist.oh_buckets[i]
83 w = cli.cl_write_rpc_hist.oh_buckets[i]
87 print "%d:\t\t%10d %3d %3d | %10d %3d %3d" % \
88 (i, r, pct(r, read_tot),
89 pct(read_cum, read_tot), w,
91 pct(write_cum, write_tot))
92 if read_cum == read_tot and write_cum == write_tot:
95 print "\n\t\t\tread\t\t\twrite"
96 print "offset rpcs % cum % | rpcs % cum %\n"
98 read_tot = lprocfs_oh_sum(cli.cl_read_offset_hist)
99 write_tot = lprocfs_oh_sum(cli.cl_write_offset_hist)
103 for i in range(OBD_HIST_MAX):
104 r = cli.cl_read_offset_hist.oh_buckets[i]
105 w = cli.cl_write_offset_hist.oh_buckets[i]
109 offset = 0 if i == 0 else 1 << (i - 1)
110 print "%d: \t%10d %3d %3d | %10d %3d %3d" % \
111 (offset, r, pct(r, read_tot),
112 pct(read_cum, read_tot), w,
114 pct(write_cum, write_tot))
115 if read_cum == read_tot and write_cum == write_tot:
120 if __name__ == "__main__":
121 parser = argparse.ArgumentParser(description=description_short)
122 parser.add_argument("client_obd", nargs="?", default=[], type=toint,
123 help="address of client_obd structure whose stats will be dumped")
124 args = parser.parse_args()
125 cli = get_cli_obd(args.client_obd)
126 osc_rpc_stats_seq_show(cli)