{
ENCODE_START(1, 1, bl);
::encode(daemons, bl, features);
+ ::encode(summary, bl);
ENCODE_FINISH(bl);
}
{
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);
}
#include <string>
#include <map>
#include <list>
+#include <sstream>
#include "include/utime.h"
#include "include/buffer.h"
struct Service {
map<std::string,Daemon> 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<Service*>& 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;
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";
+ << p.second.get_summary() << "\n";
}
}