list<pair<health_status_t,string> > *detail)
{
dout(10) << __func__ << dendl;
- assert(f != NULL);
-
- f->open_object_section("data_health");
- f->open_array_section("mons");
+ if (f) {
+ f->open_object_section("data_health");
+ f->open_array_section("mons");
+ }
health_status_t overall_status = HEALTH_OK;
detail->push_back(make_pair(health_status, ss.str()));
}
- f->open_object_section(mon_name.c_str());
- f->dump_string("name", mon_name.c_str());
- f->dump_int("kb_total", stats.kb_total);
- f->dump_int("kb_used", stats.kb_used);
- f->dump_int("kb_avail", stats.kb_avail);
- f->dump_int("avail_percent", stats.latest_avail_percent);
- f->dump_stream("last_updated") << stats.last_update;
- f->dump_stream("health") << health_status;
- if (health_status != HEALTH_OK)
- f->dump_string("health_detail", health_detail);
- f->close_section();
+ if (f) {
+ f->open_object_section(mon_name.c_str());
+ f->dump_string("name", mon_name.c_str());
+ f->dump_int("kb_total", stats.kb_total);
+ f->dump_int("kb_used", stats.kb_used);
+ f->dump_int("kb_avail", stats.kb_avail);
+ f->dump_int("avail_percent", stats.latest_avail_percent);
+ f->dump_stream("last_updated") << stats.last_update;
+ f->dump_stream("health") << health_status;
+ if (health_status != HEALTH_OK)
+ f->dump_string("health_detail", health_detail);
+ f->close_section();
+ }
+ }
+
+ if (f) {
+ f->close_section(); // mons
+ f->close_section(); // data_health
}
-
- f->close_section(); // mons
- f->close_section(); // data_health
return overall_status;
}
}
health_status_t HealthMonitor::get_health(Formatter *f,
- list<pair<health_status_t,string> > *detail) {
- assert(f != NULL);
- f->open_object_section("health");
- f->open_array_section("health_services");
+ list<pair<health_status_t,string> > *detail)
+{
+ health_status_t overall = HEALTH_OK;
+ if (f) {
+ f->open_object_section("health");
+ f->open_array_section("health_services");
+ }
for (map<int,HealthServiceRef>::iterator it = services.begin();
it != services.end(); ++it) {
- it->second->get_health(f, detail);
+ health_status_t h = it->second->get_health(f, detail);
+ if (overall > h)
+ overall = h;
+ }
+
+ if (f) {
+ f->close_section(); // health_services
+ f->close_section(); // health
}
- f->close_section(); // health_services
- f->close_section(); // health
+ return overall;
}