]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: include services in 'ceph -s'
authorSage Weil <sage@redhat.com>
Mon, 26 Jun 2017 17:21:35 +0000 (13:21 -0400)
committerSage Weil <sage@redhat.com>
Sun, 9 Jul 2017 02:30:28 +0000 (22:30 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
src/mon/Monitor.cc
src/mon/OSDMonitor.cc
src/osd/OSDMap.cc
src/osd/OSDMap.h

index 5a22db7a8e338db383564fa61c4638fab3ef69b5..0cb35b7e79a65b18a405d1f23a9c672e5f946e58 100644 (file)
@@ -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<std::string> 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<std::string> 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<string> 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);
index d998d72649348a1078a716fde0d27b48fd60ec8e..cacfbefe454e45176032dfadcc3429d9068653fb 100644 (file)
@@ -3842,7 +3842,7 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op)
   boost::scoped_ptr<Formatter> 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
index 4055dd160094487c003d421939072b3ca2945f27..898981d10017f613703615eb722b9abede4fadc9 100644 (file)
@@ -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";
   }
 }
 
index 8e065ac58e6aeeac36dc95771477c008d2ddde84..b6301f1fdc3c4b6b94d25963864eb84e93c5fb5c 100644 (file)
@@ -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 {