#include "common/Timer.h"
#include "mon/MDSMonitor.h"
#include "mon/OSDMonitor.h"
+#include "mon/PGMonitor.h"
#include <sstream>
#include "config.h"
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 "
mon->reply_command(m, err, rs, paxos->get_version());
return false;
}
+
+enum health_status_t PGMonitor::get_health(std::ostream &ss) const
+{
+ enum health_status_t ret(HEALTH_OK);
+
+ const hash_map<pg_t,pg_stat_t> &pg_stat = pg_map.pg_stat;
+
+ hash_map<pg_t,pg_stat_t>::const_iterator p = pg_stat.begin();
+ hash_map<pg_t,pg_stat_t>::const_iterator p_end = pg_stat.end();
+ int seen = 0;
+ for (; p != p_end; ++p) {
+ seen |= p->second.state;
+ }
+
+ string prequel(" Some PGs are: ");
+ if (seen & PG_STATE_CRASHED) {
+ ss << prequel << "crashed";
+ prequel = ",";
+ }
+ if (seen & PG_STATE_DOWN) {
+ ss << prequel << "down";
+ prequel = ",";
+ }
+ if (seen & PG_STATE_REPLAY) {
+ ss << prequel << "replaying";
+ prequel = ",";
+ }
+ if (seen & PG_STATE_SPLITTING) {
+ ss << prequel << "splitting";
+ prequel = ",";
+ }
+ if (seen & PG_STATE_DEGRADED) {
+ ss << prequel << "degraded";
+ prequel = ",";
+ }
+ if (seen & PG_STATE_INCONSISTENT) {
+ ss << prequel << "inconsistent";
+ prequel = ",";
+ }
+ if (seen & PG_STATE_PEERING) {
+ ss << prequel << "peering";
+ prequel = ",";
+ }
+ if (seen & PG_STATE_REPAIR) {
+ ss << prequel << "repairing";
+ prequel = ",";
+ }
+ if (prequel == ",") {
+ if (ret > HEALTH_WARN)
+ ret = HEALTH_WARN;
+ }
+ return ret;
+}