Skip to content

Commit

Permalink
Merge pull request ceph#18173 from gmayyyha/osd-status-21707
Browse files Browse the repository at this point in the history
mgr: fix "osd status" command exception if OSD not in pgmap stats

Reviewed-by: John Spray <[email protected]>
  • Loading branch information
John Spray authored Nov 20, 2017
2 parents bcf12a6 + f3475c9 commit 50412f7
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/pybind/mgr/status/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def handle_fs_status(self, cmd):
return 0, "", output

def handle_osd_status(self, cmd):
osd_table = PrettyTable(['id', 'host', 'used', 'avail', 'wr ops', 'wr data', 'rd ops', 'rd data'])
osd_table = PrettyTable(['id', 'host', 'used', 'avail', 'wr ops', 'wr data', 'rd ops', 'rd data', 'state'])
osdmap = self.get("osd_map")

filter_osds = set()
Expand All @@ -279,17 +279,26 @@ def handle_osd_status(self, cmd):
if bucket_filter and osd_id not in filter_osds:
continue

metadata = self.get_metadata('osd', "%s" % osd_id)
stats = osd_stats[osd_id]
hostname = ""
kb_used = 0
kb_avail = 0

osd_table.add_row([osd_id, metadata['hostname'],
self.format_bytes(stats['kb_used'] * 1024, 5),
self.format_bytes(stats['kb_avail'] * 1024, 5),
if osd_id in osd_stats:
metadata = self.get_metadata('osd', "%s" % osd_id)
stats = osd_stats[osd_id]
hostname = metadata['hostname']
kb_used = stats['kb_used'] * 1024
kb_avail = stats['kb_avail'] * 1024

osd_table.add_row([osd_id, hostname,
self.format_bytes(kb_used, 5),
self.format_bytes(kb_avail, 5),
self.format_dimless(self.get_rate("osd", osd_id.__str__(), "osd.op_w") +
self.get_rate("osd", osd_id.__str__(), "osd.op_rw"), 5),
self.format_bytes(self.get_rate("osd", osd_id.__str__(), "osd.op_in_bytes"), 5),
self.format_dimless(self.get_rate("osd", osd_id.__str__(), "osd.op_r"), 5),
self.format_bytes(self.get_rate("osd", osd_id.__str__(), "osd.op_out_bytes"), 5),
','.join(osd['state']),
])

return 0, "", osd_table.get_string()
Expand Down

0 comments on commit 50412f7

Please sign in to comment.