diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index 627546b4f05..10c0e01e920 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -352,6 +352,9 @@ COMMAND("osd perf", \ "osd", \ "r", \ "cli,rest") +COMMAND("osd blocked-by", \ + "print histogram of which OSDs are blocking their peers", \ + "osd", "r", "cli,rest") COMMAND("osd getmaxosd", "show largest OSD id", "osd", "r", "cli,rest") COMMAND("osd find " \ "name=id,type=CephInt,range=0", \ diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 6047cb15c43..8f0d437bd36 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -2201,6 +2201,18 @@ bool OSDMonitor::preprocess_command(MMonCommand *m) } rdata.append(ds); } + else if (prefix == "osd blocked-by") { + const PGMap &pgm = mon->pgmon()->pg_map; + if (f) { + f->open_object_section("osd_blocked_by"); + pgm.dump_osd_blocked_by_stats(f.get()); + f->close_section(); + f->flush(ds); + } else { + pgm.print_osd_blocked_by_stats(&ds); + } + rdata.append(ds); + } else if (prefix == "osd dump" || prefix == "osd tree" || prefix == "osd ls" || diff --git a/src/mon/PGMap.cc b/src/mon/PGMap.cc index dbe78e400ec..4c5c6ba3c59 100644 --- a/src/mon/PGMap.cc +++ b/src/mon/PGMap.cc @@ -843,6 +843,34 @@ void PGMap::print_osd_perf_stats(std::ostream *ss) const (*ss) << tab; } +void PGMap::dump_osd_blocked_by_stats(Formatter *f) const +{ + f->open_array_section("osd_blocked_by_infos"); + for (ceph::unordered_map::const_iterator i = blocked_by_sum.begin(); + i != blocked_by_sum.end(); + ++i) { + f->open_object_section("osd"); + f->dump_int("id", i->first); + f->dump_int("num_blocked", i->second); + f->close_section(); + } + f->close_section(); +} +void PGMap::print_osd_blocked_by_stats(std::ostream *ss) const +{ + TextTable tab; + tab.define_column("osd", TextTable::LEFT, TextTable::RIGHT); + tab.define_column("num_blocked", TextTable::LEFT, TextTable::RIGHT); + for (ceph::unordered_map::const_iterator i = blocked_by_sum.begin(); + i != blocked_by_sum.end(); + ++i) { + tab << i->first; + tab << i->second; + tab << TextTable::endrow; + } + (*ss) << tab; +} + void PGMap::recovery_summary(Formatter *f, ostream *out, const pool_stat_t& delta_sum) const {