From 30da9b76810bcce4ca284fe36708360c143172b8 Mon Sep 17 00:00:00 2001 From: John Spray Date: Wed, 31 May 2017 17:51:52 -0400 Subject: [PATCH] mon: revise "ceph status" output Signed-off-by: John Spray --- src/mds/FSMap.cc | 7 ++-- src/mon/MgrMap.h | 6 ++- src/mon/Monitor.cc | 38 +++++++++++++----- src/mon/PGMap.cc | 99 +++++++++++++++++++++++++++++----------------- src/osd/OSDMap.cc | 5 +-- 5 files changed, 100 insertions(+), 55 deletions(-) diff --git a/src/mds/FSMap.cc b/src/mds/FSMap.cc index 5d04bc65fff92..098436861d93e 100644 --- a/src/mds/FSMap.cc +++ b/src/mds/FSMap.cc @@ -124,16 +124,15 @@ void FSMap::print_summary(Formatter *f, ostream *out) const f->dump_unsigned("max", fs->mds_map.max_mds); } } else { - *out << "e" << get_epoch() << ":"; if (filesystems.size() == 1) { auto fs = filesystems.begin()->second; - *out << " " << fs->mds_map.up.size() << "/" << fs->mds_map.in.size() << "/" + *out << fs->mds_map.up.size() << "/" << fs->mds_map.in.size() << "/" << fs->mds_map.max_mds << " up"; } else { for (auto i : filesystems) { auto fs = i.second; - *out << " " << fs->mds_map.fs_name << "-" << fs->mds_map.up.size() << "/" - << fs->mds_map.in.size() << "/" << fs->mds_map.max_mds << " up"; + *out << fs->mds_map.fs_name << "-" << fs->mds_map.up.size() << "/" + << fs->mds_map.in.size() << "/" << fs->mds_map.max_mds << " up "; } } } diff --git a/src/mon/MgrMap.h b/src/mon/MgrMap.h index e522ab4ba0f1a..9d30c953c7206 100644 --- a/src/mon/MgrMap.h +++ b/src/mon/MgrMap.h @@ -126,10 +126,12 @@ public: dump(f); } else { if (get_active_gid() != 0) { - *ss << "active: " << get_active_name(); + *ss << get_active_name(); if (!available) { // If the daemon hasn't gone active yet, indicate that. - *ss << "(starting)"; + *ss << "(active, starting)"; + } else { + *ss << "(active)"; } *ss << " "; } else { diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index bc8f4fb79fcb1..d4b4f87133ec9 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -2587,23 +2587,41 @@ void Monitor::get_cluster_status(stringstream &ss, Formatter *f) f->close_section(); f->close_section(); } else { - ss << " cluster " << monmap->get_fsid() << "\n"; - ss << " health " << joinify(health.begin(), health.end(), - string("\n ")) << "\n"; - ss << " monmap " << *monmap << "\n"; - ss << " election epoch " << get_epoch() - << ", quorum " << get_quorum() << " " << get_quorum_names() << "\n"; - if (mdsmon()->get_fsmap().filesystem_count() > 0) { - ss << " fsmap " << mdsmon()->get_fsmap() << "\n"; + + ss << " cluster:\n"; + ss << " id: " << monmap->get_fsid() << "\n"; + 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]); + } + } + ss << ", out of quorum: " << joinify(out_of_q.begin(), + out_of_q.end(), std::string(", ")); } + ss << "\n"; if (mgrmon()->in_use()) { - ss << " mgr "; + ss << " mgr: "; mgrmon()->get_map().print_summary(nullptr, &ss); ss << "\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"; pgmon()->pg_map.print_summary(NULL, &ss); + ss << "\n "; } } diff --git a/src/mon/PGMap.cc b/src/mon/PGMap.cc index 5b7243fc5f163..89073d9fa7acc 100644 --- a/src/mon/PGMap.cc +++ b/src/mon/PGMap.cc @@ -1615,7 +1615,6 @@ void PGMap::clear_delta() void PGMap::print_summary(Formatter *f, ostream *out) const { - std::stringstream ss; if (f) f->open_array_section("pgs_by_state"); @@ -1626,19 +1625,15 @@ void PGMap::print_summary(Formatter *f, ostream *out) const ++p) { state_by_count.insert(make_pair(p->second, p->first)); } - for (multimap::reverse_iterator p = state_by_count.rbegin(); - p != state_by_count.rend(); - ++p) { - if (f) { + if (f) { + for (multimap::reverse_iterator p = state_by_count.rbegin(); + p != state_by_count.rend(); + ++p) + { f->open_object_section("pgs_by_state_element"); f->dump_string("state_name", pg_state_string(p->second)); f->dump_unsigned("count", p->first); f->close_section(); - } else { - ss.setf(std::ios::right); - ss << " " << std::setw(7) << p->first - << " " << pg_state_string(p->second) << "\n"; - ss.unsetf(std::ios::right); } } if (f) @@ -1654,57 +1649,89 @@ void PGMap::print_summary(Formatter *f, ostream *out) const f->dump_unsigned("bytes_avail", osd_sum.kb_avail * 1024ull); f->dump_unsigned("bytes_total", osd_sum.kb * 1024ull); } else { - *out << " pgmap v" << version << ": " - << pg_stat.size() << " pgs, " << pg_pool_sum.size() << " pools, " - << prettybyte_t(pg_sum.stats.sum.num_bytes) << " data, " - << si_t(pg_sum.stats.sum.num_objects) << " objects\n"; - *out << " " + *out << " pools: " << pg_pool_sum.size() << " pools, " + << pg_stat.size() << " pgs\n"; + *out << " objects: " << si_t(pg_sum.stats.sum.num_objects) << " objects, " + << prettybyte_t(pg_sum.stats.sum.num_bytes) << "\n"; + *out << " usage: " << kb_t(osd_sum.kb_used) << " used, " << kb_t(osd_sum.kb_avail) << " / " << kb_t(osd_sum.kb) << " avail\n"; + *out << " pgs: "; } + bool pad = false; if (num_pg_active < num_pg) { float p = (float)num_pg_active / (float)num_pg; if (f) { f->dump_float("active_pgs_ratio", p); } else { char b[20]; - snprintf(b, sizeof(b), "%.3lf", (1.0 - p) * 100.0); - *out << " " << b << "% pgs inactive\n"; + snprintf(b, sizeof(b), "%.3f", (1.0 - p) * 100.0); + *out << b << "% pgs inactive\n"; + pad = true; } } list sl; overall_recovery_summary(f, &sl); if (!f && !sl.empty()) { - for (list::iterator p = sl.begin(); p != sl.end(); ++p) - *out << " " << *p << "\n"; + for (list::iterator p = sl.begin(); p != sl.end(); ++p) { + if (pad) { + *out << " "; + } + *out << *p << "\n"; + pad = true; + } } sl.clear(); - if (!f) - *out << ss.str(); // pgs by state - - ostringstream ssr; - overall_recovery_rate_summary(f, &ssr); - if (!f && ssr.str().length()) - *out << "recovery io " << ssr.str() << "\n"; + if (!f) { + unsigned max_width = 1; + for (multimap::reverse_iterator p = state_by_count.rbegin(); + p != state_by_count.rend(); + ++p) + { + std::stringstream ss; + ss << p->first; + max_width = MAX(ss.str().size(), max_width); + } - ssr.clear(); - ssr.str(""); + for (multimap::reverse_iterator p = state_by_count.rbegin(); + p != state_by_count.rend(); + ++p) + { + if (pad) { + *out << " "; + } + pad = true; + out->setf(std::ios::left); + *out << std::setw(max_width) << p->first + << " " << pg_state_string(p->second) << "\n"; + out->unsetf(std::ios::left); + } + } - overall_client_io_rate_summary(f, &ssr); - if (!f && ssr.str().length()) - *out << " client io " << ssr.str() << "\n"; + ostringstream ss_rec_io; + overall_recovery_rate_summary(f, &ss_rec_io); + ostringstream ss_client_io; + overall_client_io_rate_summary(f, &ss_client_io); + ostringstream ss_cache_io; + overall_cache_io_rate_summary(f, &ss_cache_io); - ssr.clear(); - ssr.str(""); + if (!f && (ss_client_io.str().length() || ss_rec_io.str().length() + || ss_cache_io.str().length())) { + *out << "\n \n"; + *out << " io:\n"; + } - overall_cache_io_rate_summary(f, &ssr); - if (!f && ssr.str().length()) - *out << " cache io " << ssr.str() << "\n"; + if (!f && ss_client_io.str().length()) + *out << " client: " << ss_client_io.str() << "\n"; + if (!f && ss_rec_io.str().length()) + *out << " recovery: " << ss_rec_io.str() << "\n"; + if (!f && ss_cache_io.str().length()) + *out << " cache: " << ss_cache_io.str() << "\n"; } void PGMap::print_oneline_summary(Formatter *f, ostream *out) const diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc index 0f121291da376..396aa56ec4f05 100644 --- a/src/osd/OSDMap.cc +++ b/src/osd/OSDMap.cc @@ -3076,8 +3076,7 @@ void OSDMap::print_summary(Formatter *f, ostream& out) const f->dump_unsigned("num_remapped_pgs", get_num_pg_temp()); f->close_section(); } else { - out << " osdmap e" << get_epoch() << ": " - << get_num_osds() << " osds: " + out << get_num_osds() << " osds: " << get_num_up_osds() << " up, " << get_num_in_osds() << " in"; if (get_num_pg_temp()) @@ -3092,7 +3091,7 @@ void OSDMap::print_summary(Formatter *f, ostream& out) const void OSDMap::print_oneline_summary(ostream& out) const { out << "e" << get_epoch() << ": " - << get_num_osds() << " osds: " + << get_num_osds() << " total, " << get_num_up_osds() << " up, " << get_num_in_osds() << " in"; if (test_flag(CEPH_OSDMAP_FULL)) -- 2.39.5