From c8d2388060f23e92305f271b341c00e2c03ed335 Mon Sep 17 00:00:00 2001 From: John Spray Date: Mon, 1 Sep 2014 18:43:11 +0100 Subject: [PATCH] mon: add MDS metric metadata to health detail This is a bit wonky because the mon health structure expects a string, and we have a key-val structure, but it's better to output this somehow than to have it rot as a purely internal thing. Signed-off-by: John Spray --- src/mon/MDSMonitor.cc | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index c066e4904af8d..870a9e63c654f 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -13,6 +13,7 @@ */ #include +#include #include "MDSMonitor.h" #include "Monitor.h" @@ -581,7 +582,27 @@ void MDSMonitor::get_health(list >& summary, health.decode(bl_i); for (std::list::iterator j = health.metrics.begin(); j != health.metrics.end(); ++j) { - summary.push_back(std::make_pair(j->sev, j->message)); + int const rank = i->second.rank; + std::ostringstream message; + message << "mds" << rank << ": " << j->message; + summary.push_back(std::make_pair(j->sev, message.str())); + + // There is no way for us to clealy associate detail entries with summary entries (#7192), so + // we duplicate the summary message in the detail string and tag the metadata on. + std::ostringstream detail_message; + detail_message << message.str(); + if (j->metadata.size()) { + detail_message << "("; + std::map::iterator k = j->metadata.begin(); + while (k != j->metadata.end()) { + detail_message << k->first << ": " << k->second; + if (boost::next(k) != j->metadata.end()) { + detail_message << ", "; + } + } + detail_message << ")"; + } + detail->push_back(std::make_pair(j->sev, detail_message.str())); } } } -- 2.39.5