]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: implement PGMonitor::get_health
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Wed, 26 Jan 2011 14:11:01 +0000 (06:11 -0800)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Wed, 26 Jan 2011 15:45:12 +0000 (07:45 -0800)
Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
src/mon/MonmapMonitor.cc
src/mon/PGMonitor.cc
src/mon/PGMonitor.h

index c575163d19b0692aad5404eb928de34d8c3b0d09..9651cb14780a2bb7414c95e5898f4e5d94f7edc5 100644 (file)
@@ -20,6 +20,7 @@
 #include "common/Timer.h"
 #include "mon/MDSMonitor.h"
 #include "mon/OSDMonitor.h"
+#include "mon/PGMonitor.h"
 
 #include <sstream>
 #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 "
index d86ea874f07ec36456aec788588edc389bf9207d..4157e7f64c08b975a0aeb5717c914b23faa04a0b 100644 (file)
@@ -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_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;
+}
index 2e03b43517cb41ab51170c2a2e1cbe73457cb431..d551635b789d00013d98871a44d38fbe0bf30587 100644 (file)
@@ -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