From: Sage Weil Date: Tue, 27 Jun 2017 13:32:44 +0000 (-0400) Subject: mon: make service summary string customizable; simple default X-Git-Tag: v12.1.1~98^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ee5835dfb53c8f6cb892990e802ac3fd2cfa493f;p=ceph.git mon: make service summary string customizable; simple default Eventually the mgr can populate this field with something tailored to the service. Signed-off-by: Sage Weil --- diff --git a/src/mgr/ServiceMap.cc b/src/mgr/ServiceMap.cc index fc3a775f53af..9074e2f8716f 100644 --- a/src/mgr/ServiceMap.cc +++ b/src/mgr/ServiceMap.cc @@ -56,6 +56,7 @@ void ServiceMap::Service::encode(bufferlist& bl, uint64_t features) const { ENCODE_START(1, 1, bl); ::encode(daemons, bl, features); + ::encode(summary, bl); ENCODE_FINISH(bl); } @@ -63,12 +64,14 @@ void ServiceMap::Service::decode(bufferlist::iterator& p) { DECODE_START(1, p); ::decode(daemons, p); + ::decode(summary, p); DECODE_FINISH(p); } void ServiceMap::Service::dump(Formatter *f) const { f->open_object_section("daemons"); + f->dump_string("summary", summary); for (auto& p : daemons) { f->dump_object(p.first.c_str(), p.second); } diff --git a/src/mgr/ServiceMap.h b/src/mgr/ServiceMap.h index d9121c664f9f..5137f9f84f26 100644 --- a/src/mgr/ServiceMap.h +++ b/src/mgr/ServiceMap.h @@ -6,6 +6,7 @@ #include #include #include +#include #include "include/utime.h" #include "include/buffer.h" @@ -31,11 +32,25 @@ struct ServiceMap { struct Service { map daemons; + std::string summary; ///< summary status string for 'ceph -s' void encode(bufferlist& bl, uint64_t features) const; void decode(bufferlist::iterator& p); void dump(Formatter *f) const; static void generate_test_instances(std::list& ls); + + std::string get_summary() const { + if (summary.size()) { + return summary; + } + if (daemons.empty()) { + return "no daemons active"; + } + std::ostringstream ss; + ss << daemons.size() << (daemons.size() > 1 ? "daemonss" : "daemon") + << " active"; + return ss.str(); + } }; epoch_t epoch = 0; diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 0cb35b7e79a6..0df54bc965d5 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -2657,13 +2657,8 @@ void Monitor::get_cluster_status(stringstream &ss, Formatter *f) 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"; + << p.second.get_summary() << "\n"; } }