From: Sage Weil Date: Mon, 26 Jun 2017 17:21:35 +0000 (-0400) Subject: mon: include services in 'ceph -s' X-Git-Tag: v12.1.1~98^2~9 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e084f594ee0c31834ef97e89548151dadeca1c1f;p=ceph.git mon: include services in 'ceph -s' Signed-off-by: Sage Weil --- diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 5a22db7a8e33..0cb35b7e79a6 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -2601,7 +2601,7 @@ void Monitor::get_cluster_status(stringstream &ss, Formatter *f) monmap->dump(f); f->close_section(); f->open_object_section("osdmap"); - osdmon()->osdmap.print_summary(f, cout); + osdmon()->osdmap.print_summary(f, cout, string(12, ' ')); f->close_section(); f->open_object_section("pgmap"); pgservice->print_summary(f, NULL); @@ -2613,6 +2613,8 @@ void Monitor::get_cluster_status(stringstream &ss, Formatter *f) f->open_object_section("mgrmap"); mgrmon()->get_map().print_summary(f, nullptr); f->close_section(); + + f->dump_object("servicemap", mgrstatmon()->get_service_map()); f->close_section(); } else { @@ -2621,31 +2623,49 @@ void Monitor::get_cluster_status(stringstream &ss, Formatter *f) ss << " health: " << joinify(health.begin(), health.end(), string("\n ")) << "\n"; ss << "\n \n services:\n"; - const auto quorum_names = get_quorum_names(); - const auto mon_count = monmap->mon_info.size(); - ss << " mon: " << mon_count << " daemons, quorum " - << quorum_names; - if (quorum_names.size() != mon_count) { - std::list out_of_q; - for (size_t i = 0; i < monmap->ranks.size(); ++i) { - if (quorum.count(i) == 0) { - out_of_q.push_back(monmap->ranks[i]); - } + { + size_t maxlen = 3; + auto& service_map = mgrstatmon()->get_service_map(); + for (auto& p : service_map.services) { + maxlen = std::max(maxlen, p.first.size()); + } + string spacing(maxlen - 3, ' '); + const auto quorum_names = get_quorum_names(); + const auto mon_count = monmap->mon_info.size(); + ss << " mon: " << spacing << mon_count << " daemons, quorum " + << quorum_names; + if (quorum_names.size() != mon_count) { + std::list out_of_q; + for (size_t i = 0; i < monmap->ranks.size(); ++i) { + if (quorum.count(i) == 0) { + out_of_q.push_back(monmap->ranks[i]); + } + } + ss << ", out of quorum: " << joinify(out_of_q.begin(), + out_of_q.end(), std::string(", ")); } - ss << ", out of quorum: " << joinify(out_of_q.begin(), - out_of_q.end(), std::string(", ")); - } - ss << "\n"; - if (mgrmon()->in_use()) { - ss << " mgr: "; - mgrmon()->get_map().print_summary(nullptr, &ss); ss << "\n"; + if (mgrmon()->in_use()) { + ss << " mgr: " << spacing; + mgrmon()->get_map().print_summary(nullptr, &ss); + ss << "\n"; + } + if (mdsmon()->get_fsmap().filesystem_count() > 0) { + ss << " mds: " << spacing << mdsmon()->get_fsmap() << "\n"; + } + ss << " osd: " << spacing; + osdmon()->osdmap.print_summary(NULL, ss, string(maxlen + 6, ' ')); + ss << "\n"; + for (auto& p : service_map.services) { + set active; + for (auto& q : p.second.daemons) { + active.insert(q.first); + } + ss << " " << p.first << ": " << string(maxlen - p.first.size(), ' ') + << p.second.daemons.size() << " active: " + << active << "\n"; + } } - if (mdsmon()->get_fsmap().filesystem_count() > 0) { - ss << " mds: " << mdsmon()->get_fsmap() << "\n"; - } - ss << " osd: "; - osdmon()->osdmap.print_summary(NULL, ss); ss << "\n \n data:\n"; pgservice->print_summary(NULL, &ss); diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index d998d7264934..cacfbefe454e 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -3842,7 +3842,7 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op) boost::scoped_ptr f(Formatter::create(format)); if (prefix == "osd stat") { - osdmap.print_summary(f.get(), ds); + osdmap.print_summary(f.get(), ds, ""); if (f) f->flush(rdata); else diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc index 4055dd160094..898981d10017 100644 --- a/src/osd/OSDMap.cc +++ b/src/osd/OSDMap.cc @@ -3185,7 +3185,8 @@ void OSDMap::print_tree(Formatter *f, ostream *out, unsigned filter) const } } -void OSDMap::print_summary(Formatter *f, ostream& out) const +void OSDMap::print_summary(Formatter *f, ostream& out, + const string& prefix) const { if (f) { f->open_object_section("osdmap"); @@ -3206,7 +3207,7 @@ void OSDMap::print_summary(Formatter *f, ostream& out) const out << "\n"; uint64_t important_flags = flags & ~CEPH_OSDMAP_SEMIHIDDEN_FLAGS; if (important_flags) - out << " flags " << get_flag_string(important_flags) << "\n"; + out << prefix << "flags " << get_flag_string(important_flags) << "\n"; } } diff --git a/src/osd/OSDMap.h b/src/osd/OSDMap.h index 8e065ac58e6a..b6301f1fdc3c 100644 --- a/src/osd/OSDMap.h +++ b/src/osd/OSDMap.h @@ -1337,7 +1337,7 @@ private: public: void print(ostream& out) const; void print_pools(ostream& out) const; - void print_summary(Formatter *f, ostream& out) const; + void print_summary(Formatter *f, ostream& out, const string& prefix) const; void print_oneline_summary(ostream& out) const; enum {