From f8068cd438002743a39300efc1f198684951236c Mon Sep 17 00:00:00 2001 From: John Spray Date: Fri, 28 Jul 2017 11:18:07 -0400 Subject: [PATCH] mon: extensible output format for health checks The summary field can be extended with the fields used to construct the message (e.g. including the down osd count in the message about osds being down). The detail entries, similarly, can be extended with machine-readable fields like the PG ID for a damaged PG. For the moment all the internal stuff is just strings still, but we change the output format so that we don't break it later when we add things. Signed-off-by: John Spray --- src/mon/health_check.h | 20 ++++++++++++++++---- src/pybind/mgr/dashboard/health.html | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/mon/health_check.h b/src/mon/health_check.h index 51f0e1095d8..a8971ce4424 100644 --- a/src/mon/health_check.h +++ b/src/mon/health_check.h @@ -35,10 +35,16 @@ struct health_check_t { void dump(Formatter *f) const { f->dump_stream("severity") << severity; - f->dump_string("summary", summary); + + f->open_object_section("summary"); + f->dump_string("message", summary); + f->close_section(); + f->open_array_section("detail"); for (auto& p : detail) { - f->dump_string("item", p); + f->open_object_section("detail_item"); + f->dump_string("message", p); + f->close_section(); } f->close_section(); } @@ -138,11 +144,17 @@ struct health_check_map_t { if (f) { f->open_object_section(p.first.c_str()); f->dump_stream("severity") << p.second.severity; - f->dump_string("message", p.second.summary); + + f->open_object_section("summary"); + f->dump_string("message", p.second.summary); + f->close_section(); + if (detail) { f->open_array_section("detail"); for (auto& d : p.second.detail) { - f->dump_string("item", d); + f->open_object_section("detail_item"); + f->dump_string("message", d); + f->close_section(); } f->close_section(); } diff --git a/src/pybind/mgr/dashboard/health.html b/src/pybind/mgr/dashboard/health.html index 70cc7f8efe7..59dc312d9fa 100644 --- a/src/pybind/mgr/dashboard/health.html +++ b/src/pybind/mgr/dashboard/health.html @@ -235,7 +235,7 @@ -- 2.39.5