ceph time-sync-status
ceph node ls
- for t in mon osd mds ; do
+ for t in mon osd mds mgr ; do
ceph node ls $t
done
f->close_section();
}
+void dump_services(Formatter* f, const map<string, list<string> >& services, const char* type)
+{
+ assert(f);
+
+ f->open_object_section(type);
+ for (const auto& host : services) {
+ f->open_array_section(host.first.c_str());
+ const auto& hosted = host.second;
+ for (const auto& s : hosted) {
+ f->dump_string(type, s);
+ }
+ f->close_section();
+ }
+ f->close_section();
+}
// If non-printable characters found then convert bufferlist to
// base64 encoded string indicating whether it did.
/// @param services a map from hostname to a list of service id hosted by this host
/// @param type the service type of given @p services, for example @p osd or @p mon.
void dump_services(Formatter* f, const map<string, list<int> >& services, const char* type);
+/// dump service names grouped by their host to the specified formatter
+/// @param f formatter for the output
+/// @param services a map from hostname to a list of service name hosted by this host
+/// @param type the service type of given @p services, for example @p osd or @p mon.
+void dump_services(Formatter* f, const map<string, list<string> >& services, const char* type);
string cleanbin(bufferlist &bl, bool &b64);
string cleanbin(string &str);
}
int MgrMonitor::load_metadata(const string& name, std::map<string, string>& m,
- ostream *err)
+ ostream *err) const
{
bufferlist bl;
int r = mon->store->get(MGR_METADATA_PREFIX, name, bl);
return 0;
}
+void MgrMonitor::print_nodes(Formatter *f) const
+{
+ assert(f);
+
+ std::map<string, list<string> > mgrs; // hostname => mgr
+ auto ls = map.get_all_names();
+ for (auto& name : ls) {
+ std::map<string,string> meta;
+ if (load_metadata(name, meta, nullptr)) {
+ continue;
+ }
+ auto hostname = meta.find("hostname");
+ if (hostname == meta.end()) {
+ // not likely though
+ continue;
+ }
+ mgrs[hostname->second].push_back(name);
+ }
+
+ dump_services(f, mgrs, "mgr");
+}
+
const std::vector<MonCommand> &MgrMonitor::get_command_descs() const
{
if (command_descs.empty()) {
const std::vector<MonCommand> &get_command_descs() const;
int load_metadata(const string& name, std::map<string, string>& m,
- ostream *err);
+ ostream *err) const;
int dump_metadata(const string& name, Formatter *f, ostream *err);
+ void print_nodes(Formatter *f) const;
void count_metadata(const string& field, Formatter *f);
void count_metadata(const string& field, std::map<string,int> *out);
FLAG(NOFORWARD))
COMMAND("node ls " \
- "name=type,type=CephChoices,strings=all|osd|mon|mds,req=false",
+ "name=type,type=CephChoices,strings=all|osd|mon|mds|mgr,req=false",
"list all nodes in cluster [type]", "mon", "r", "cli,rest")
/*
* Monitor-specific commands under module 'mon'
print_nodes(f.get(), ds);
osdmon()->print_nodes(f.get());
mdsmon()->print_nodes(f.get());
+ mgrmon()->print_nodes(f.get());
f->close_section();
} else if (node_type == "mon") {
print_nodes(f.get(), ds);
osdmon()->print_nodes(f.get());
} else if (node_type == "mds") {
mdsmon()->print_nodes(f.get());
+ } else if (node_type == "mgr") {
+ mgrmon()->print_nodes(f.get());
}
f->flush(ds);
rdata.append(ds);