mon/HealthMonitor: simplify health alert dump

Use dump() member instead of duplicating!  The only reason we had this
before was because the detail portion was optinoal

Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Sage Weil 2019-07-31 03:24:45 -05:00
parent 164de7d69b
commit 7834cd8146
2 changed files with 9 additions and 19 deletions

View File

@ -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();

View File

@ -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<health_check_t*>& ls) {