diff --git a/src/mon/HealthMonitor.cc b/src/mon/HealthMonitor.cc index 7c51e025baa..18600acbe25 100644 --- a/src/mon/HealthMonitor.cc +++ b/src/mon/HealthMonitor.cc @@ -459,20 +459,8 @@ health_status_t HealthMonitor::get_health_status( f->open_object_section("checks"); for (auto& p : all.checks) { f->open_object_section(p.first.c_str()); - f->dump_stream("severity") << p.second.severity; + p.second.dump(f, want_detail); f->dump_bool("muted", mutes.count(p.first)); - f->open_object_section("summary"); - f->dump_string("message", p.second.summary); - f->close_section(); - if (want_detail) { - f->open_array_section("detail"); - for (auto& d : p.second.detail) { - f->open_object_section("detail_item"); - f->dump_string("message", d); - f->close_section(); - } - f->close_section(); - } f->close_section(); } f->close_section(); diff --git a/src/mon/health_check.h b/src/mon/health_check.h index 93b9e62f9b0..4215a8bdbca 100644 --- a/src/mon/health_check.h +++ b/src/mon/health_check.h @@ -34,20 +34,22 @@ struct health_check_t { return !(l == r); } - void dump(ceph::Formatter *f) const { + void dump(ceph::Formatter *f, bool want_detail=true) const { f->dump_stream("severity") << severity; f->open_object_section("summary"); f->dump_string("message", summary); f->close_section(); - f->open_array_section("detail"); - for (auto& p : detail) { - f->open_object_section("detail_item"); - f->dump_string("message", p); + if (want_detail) { + f->open_array_section("detail"); + for (auto& p : detail) { + f->open_object_section("detail_item"); + f->dump_string("message", p); + f->close_section(); + } f->close_section(); } - f->close_section(); } static void generate_test_instances(std::list& ls) {