diff options
author | Gregory Farnum <greg@inktank.com> | 2013-04-19 14:28:18 -0700 |
---|---|---|
committer | Gregory Farnum <greg@inktank.com> | 2013-04-19 14:28:18 -0700 |
commit | f114fdc40a0aac9f38745c50dce18d186e657acd (patch) | |
tree | 6f96c583b1b50f289e8adbf5ad705b150d92ebda | |
parent | d395aa521e8a4b295ed2b08dd7cfb7d9f995fcf7 (diff) | |
parent | 9a7d1f5197cd1e7e9225d24dc2682f1de475a29c (diff) | |
download | ceph-f114fdc40a0aac9f38745c50dce18d186e657acd.tar.gz |
Merge pull request #227 from ceph/wip-4574
Reviewed-by: Greg Farnum <greg@inktank.com>
-rw-r--r-- | src/mon/ConfigKeyService.h | 7 | ||||
-rw-r--r-- | src/mon/DataHealthService.cc | 48 | ||||
-rw-r--r-- | src/mon/DataHealthService.h | 2 | ||||
-rw-r--r-- | src/mon/HealthMonitor.cc | 25 | ||||
-rw-r--r-- | src/mon/HealthMonitor.h | 2 | ||||
-rw-r--r-- | src/mon/HealthService.h | 2 | ||||
-rw-r--r-- | src/mon/Monitor.cc | 8 | ||||
-rw-r--r-- | src/mon/QuorumService.h | 2 |
8 files changed, 61 insertions, 35 deletions
diff --git a/src/mon/ConfigKeyService.h b/src/mon/ConfigKeyService.h index aee85bc0859..49e15acdfc6 100644 --- a/src/mon/ConfigKeyService.h +++ b/src/mon/ConfigKeyService.h @@ -58,8 +58,11 @@ public: * @{ */ virtual void init() { } - virtual void get_health(Formatter *f, - list<pair<health_status_t,string> > *detail) { } + virtual health_status_t get_health( + Formatter *f, + list<pair<health_status_t,string> > *detail) { + return HEALTH_OK; + } virtual bool service_dispatch(Message *m); virtual void start_epoch() { } diff --git a/src/mon/DataHealthService.cc b/src/mon/DataHealthService.cc index 2410cbc4d68..949e1e2efe3 100644 --- a/src/mon/DataHealthService.cc +++ b/src/mon/DataHealthService.cc @@ -54,14 +54,17 @@ void DataHealthService::start_epoch() last_warned_percent = 0; } -void DataHealthService::get_health(Formatter *f, - list<pair<health_status_t,string> > *detail) +health_status_t DataHealthService::get_health( + Formatter *f, + list<pair<health_status_t,string> > *detail) { dout(10) << __func__ << dendl; - assert(f != NULL); + if (f) { + f->open_object_section("data_health"); + f->open_array_section("mons"); + } - f->open_object_section("data_health"); - f->open_array_section("mons"); + health_status_t overall_status = HEALTH_OK; for (map<entity_inst_t,DataStats>::iterator it = stats.begin(); it != stats.end(); ++it) { @@ -78,6 +81,9 @@ void DataHealthService::get_health(Formatter *f, health_detail = "low disk space!"; } + if (overall_status > health_status) + overall_status = health_status; + if (detail && health_status != HEALTH_OK) { stringstream ss; ss << "mon." << mon_name << " addr " << it->first.addr @@ -86,21 +92,27 @@ void DataHealthService::get_health(Formatter *f, 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; } int DataHealthService::update_stats() diff --git a/src/mon/DataHealthService.h b/src/mon/DataHealthService.h index de7ab0ac258..c94327f3129 100644 --- a/src/mon/DataHealthService.h +++ b/src/mon/DataHealthService.h @@ -75,7 +75,7 @@ public: start_tick(); } - virtual void get_health(Formatter *f, + virtual health_status_t get_health(Formatter *f, list<pair<health_status_t,string> > *detail); virtual int get_type() { diff --git a/src/mon/HealthMonitor.cc b/src/mon/HealthMonitor.cc index cf3d962b2c4..6239d32a873 100644 --- a/src/mon/HealthMonitor.cc +++ b/src/mon/HealthMonitor.cc @@ -78,18 +78,27 @@ void HealthMonitor::service_shutdown() services.clear(); } -void 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"); +health_status_t HealthMonitor::get_health(Formatter *f, + 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; } diff --git a/src/mon/HealthMonitor.h b/src/mon/HealthMonitor.h index 85581edde9b..e0255d20081 100644 --- a/src/mon/HealthMonitor.h +++ b/src/mon/HealthMonitor.h @@ -47,7 +47,7 @@ public: * @{ */ virtual void init(); - virtual void get_health(Formatter *f, + virtual health_status_t get_health(Formatter *f, list<pair<health_status_t,string> > *detail); virtual bool service_dispatch(Message *m); diff --git a/src/mon/HealthService.h b/src/mon/HealthService.h index b62ed5991eb..1e041f5739e 100644 --- a/src/mon/HealthService.h +++ b/src/mon/HealthService.h @@ -44,7 +44,7 @@ public: HealthService *get() { return static_cast<HealthService *>(RefCountedObject::get()); } - virtual void get_health(Formatter *f, + virtual health_status_t get_health(Formatter *f, list<pair<health_status_t,string> > *detail) = 0; virtual int get_type() = 0; virtual string get_name() const = 0; diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index e3d33ce9d60..cc8527ed7f7 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -2259,7 +2259,8 @@ void Monitor::get_health(string& status, bufferlist *detailbl, Formatter *f) ostringstream tcss; health_status_t tcstatus = timecheck_status(tcss, skew, latency); if (tcstatus != HEALTH_OK) { - overall = tcstatus; + if (overall > tcstatus) + overall = tcstatus; warns.push_back(name); ostringstream tmp_ss; @@ -2297,8 +2298,9 @@ void Monitor::get_health(string& status, bufferlist *detailbl, Formatter *f) if (f) f->close_section(); - if (f) - health_monitor->get_health(f, (detailbl ? &detail : NULL)); + health_status_t hmstatus = health_monitor->get_health(f, (detailbl ? &detail : NULL)); + if (overall > hmstatus) + overall = hmstatus; stringstream fss; fss << overall; diff --git a/src/mon/QuorumService.h b/src/mon/QuorumService.h index dfa4f4165e9..7506421caf4 100644 --- a/src/mon/QuorumService.h +++ b/src/mon/QuorumService.h @@ -133,7 +133,7 @@ public: virtual void init() { } - virtual void get_health(Formatter *f, + virtual health_status_t get_health(Formatter *f, list<pair<health_status_t,string> > *detail) = 0; virtual int get_type() = 0; virtual string get_name() const = 0; |