From: Colin Patrick McCabe Date: Wed, 26 Jan 2011 14:11:01 +0000 (-0800) Subject: mon: implement PGMonitor::get_health X-Git-Tag: v0.25~234^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8aff0dd1c9eca189ed4665068cfd049240acb79f;p=ceph.git mon: implement PGMonitor::get_health Signed-off-by: Colin McCabe --- diff --git a/src/mon/MonmapMonitor.cc b/src/mon/MonmapMonitor.cc index c575163d19b0..9651cb14780a 100644 --- a/src/mon/MonmapMonitor.cc +++ b/src/mon/MonmapMonitor.cc @@ -20,6 +20,7 @@ #include "common/Timer.h" #include "mon/MDSMonitor.h" #include "mon/OSDMonitor.h" +#include "mon/PGMonitor.h" #include #include "config.h" @@ -162,6 +163,9 @@ bool MonmapMonitor::preprocess_command(MMonCommand *m) 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 " diff --git a/src/mon/PGMonitor.cc b/src/mon/PGMonitor.cc index d86ea874f07e..4157e7f64c08 100644 --- a/src/mon/PGMonitor.cc +++ b/src/mon/PGMonitor.cc @@ -841,3 +841,56 @@ bool PGMonitor::prepare_command(MMonCommand *m) 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_stat = pg_map.pg_stat; + + hash_map::const_iterator p = pg_stat.begin(); + hash_map::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; +} diff --git a/src/mon/PGMonitor.h b/src/mon/PGMonitor.h index 2e03b43517cb..d551635b789d 100644 --- a/src/mon/PGMonitor.h +++ b/src/mon/PGMonitor.h @@ -93,6 +93,8 @@ private: void tick(); // check state, take actions void check_osd_map(epoch_t epoch); + + enum health_status_t get_health(std::ostream &ss) const; }; #endif