jf.flush(ss);
}
+void Monitor::get_health(string& status, bufferlist *detailbl)
+{
+ list<pair<health_status_t,string> > summary;
+ list<pair<health_status_t,string> > detail;
+ for (vector<PaxosService*>::iterator p = paxos_service.begin();
+ p != paxos_service.end();
+ p++) {
+ PaxosService *s = *p;
+ s->get_health(summary, detailbl ? &detail : NULL);
+ }
+
+ stringstream ss;
+ health_status_t overall = HEALTH_OK;
+ if (!summary.empty()) {
+ ss << ' ';
+ while (!summary.empty()) {
+ if (overall > summary.front().first)
+ overall = summary.front().first;
+ ss << summary.front().second;
+ summary.pop_front();
+ if (!summary.empty())
+ ss << "; ";
+ }
+ }
+ stringstream fss;
+ fss << overall;
+ status = fss.str() + ss.str();
+
+ while (!detail.empty()) {
+ detailbl->append(detail.front().second);
+ detailbl->append('\n');
+ detail.pop_front();
+ }
+}
+
void Monitor::handle_command(MMonCommand *m)
{
if (m->fsid != monmap->fsid) {
r = 0;
}
if (m->cmd[0] == "health") {
- list<pair<health_status_t,string> > summary;
- list<pair<health_status_t,string> > detail;
- for (vector<PaxosService*>::iterator p = paxos_service.begin();
- p != paxos_service.end();
- p++) {
- PaxosService *s = *p;
- ostringstream oss;
- s->get_health(summary, (m->cmd.size() > 1) ? &detail : NULL);
- }
-
- stringstream ss;
- health_status_t overall = HEALTH_OK;
- if (!summary.empty()) {
- ss << ' ';
- while (!summary.empty()) {
- if (overall > summary.front().first)
- overall = summary.front().first;
- ss << summary.front().second;
- summary.pop_front();
- if (!summary.empty())
- ss << "; ";
- }
- }
- stringstream fss;
- fss << overall;
- rs = fss.str() + ss.str();
- while (!detail.empty()) {
- rdata.append(detail.front().second);
- rdata.append('\n');
- detail.pop_front();
- }
+ get_health(rs, (m->cmd.size() > 1) ? &rdata : NULL);
r = 0;
}
if (m->cmd[0] == "heap") {
void handle_command(class MMonCommand *m);
void handle_route(MRoute *m);
+ /**
+ * generate health report
+ *
+ * @param status one-line status summary
+ * @param detailbl optional bufferlist* to fill with a detailed report
+ */
+ void get_health(string& status, bufferlist *detailbl);
+
void reply_command(MMonCommand *m, int rc, const string &rs, version_t version);
void reply_command(MMonCommand *m, int rc, const string &rs, bufferlist& rdata, version_t version);