Any PaxosService can return a status (or not).
Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
return;
}
if (m->cmd[0] == "health") {
- monmon()->dispatch(m);
- return;
+ health_status_t overall = HEALTH_OK;
+ string combined;
+ for (vector<PaxosService*>::iterator p = paxos_service.begin();
+ p != paxos_service.end();
+ p++) {
+ PaxosService *s = *p;
+ ostringstream oss;
+ health_status_t ret = s->get_health(oss);
+ if (ret < overall)
+ overall = ret;
+ string cur = oss.str();
+ if (cur.length()) {
+ if (combined.length())
+ combined += "; ";
+ combined += cur;
+ }
+ }
+
+ stringstream ss;
+ ss << overall << " " << combined;
+ rs = ss.str();
+ r = 0;
}
} else
rs = "no command";
else if (m->cmd[1] == "remove")
return false;
}
- else if (m->cmd[0] == "health") {
- ostringstream oss;
- health_status_t overall = HEALTH_OK;
- try {
- health_status_t ret;
- ret = mon->mdsmon()->get_health(oss);
- if (ret < overall)
- overall = ret;
- ret = mon->osdmon()->get_health(oss);
- if (ret < overall)
- overall = ret;
- ret = mon->pgmon()->get_health(oss);
- if (ret < overall)
- overall = ret;
- }
- catch (const std::exception &e) {
- oss << " monmapmonitor: caught exception while "
- << "checking health: '" << e.what() << "'";
- }
- ss << overall << oss.str();
- r = 0;
- }
if (r != -1) {
string rs;
virtual void init() {}
+ virtual enum health_status_t get_health(std::ostream& os) const { return HEALTH_OK; }
+
};
#endif