]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osdmonitor: use a new get_full_osd_counts to generate health without osdstat
authorGreg Farnum <gfarnum@redhat.com>
Fri, 19 May 2017 06:56:56 +0000 (23:56 -0700)
committerSage Weil <sage@redhat.com>
Fri, 2 Jun 2017 17:06:48 +0000 (13:06 -0400)
Signed-off-by: Greg Farnum <gfarnum@redhat.com>
src/mon/OSDMonitor.cc
src/osd/OSDMap.cc
src/osd/OSDMap.h

index b74853f1a27a7b26aef3f72593e3cf8ceb2e9cc6..fc951c6bdb14aebc9be49e9d340b809ecbb417c8 100644 (file)
@@ -3749,8 +3749,8 @@ void OSDMonitor::get_health(list<pair<health_status_t,string> >& summary,
        summary.push_back(make_pair(HEALTH_ERR, ss.str()));
       }
 
-      map<int, float> full, backfillfull, nearfull;
-      osdmap.get_full_osd_util(mon->pgservice->get_osd_stat(), &full, &backfillfull, &nearfull);
+      set<int> full, backfillfull, nearfull;
+      osdmap.get_full_osd_counts(&full, &backfillfull, &nearfull);
       if (full.size()) {
        ostringstream ss;
        ss << full.size() << " full osd(s)";
@@ -3769,17 +3769,17 @@ void OSDMonitor::get_health(list<pair<health_status_t,string> >& summary,
       if (detail) {
         for (auto& i: full) {
           ostringstream ss;
-          ss << "osd." << i.first << " is full at " << roundf(i.second * 100) << "%";
+          ss << "osd." << i << " is full";
          detail->push_back(make_pair(HEALTH_ERR, ss.str()));
         }
         for (auto& i: backfillfull) {
           ostringstream ss;
-          ss << "osd." << i.first << " is backfill full at " << roundf(i.second * 100) << "%";
+          ss << "osd." << i << " is backfill full";
          detail->push_back(make_pair(HEALTH_WARN, ss.str()));
         }
         for (auto& i: nearfull) {
           ostringstream ss;
-          ss << "osd." << i.first << " is near full at " << roundf(i.second * 100) << "%";
+          ss << "osd." << i << " is near full";
          detail->push_back(make_pair(HEALTH_WARN, ss.str()));
         }
       }
index 0f1c6f5df87c2071a78a4d8d2adf926b57e2a2ec..bf5f07e7d8d673d7590747cd184d428b4a47f5a4 100644 (file)
@@ -1148,6 +1148,24 @@ void OSDMap::get_full_osd_util(
   }
 }
 
+void OSDMap::get_full_osd_counts(set<int> *full, set<int> *backfill,
+                                set<int> *nearfull) const
+{
+  full->clear();
+  backfill->clear();
+  nearfull->clear();
+  for (int i = 0; i < max_osd; ++i) {
+    if (exists(i) && is_up(i) && is_in(i)) {
+      if (osd_state[i] & CEPH_OSD_FULL)
+       full->emplace(i);
+      else if (osd_state[i] & CEPH_OSD_BACKFILLFULL)
+       backfill->emplace(i);
+      else if (osd_state[i] & CEPH_OSD_NEARFULL)
+       nearfull->emplace(i);
+    }
+  }
+}
+
 void OSDMap::get_all_osds(set<int32_t>& ls) const
 {
   for (int i=0; i<max_osd; i++)
index 904f3c0af6dcfd1237d43f1d9a9b35fc1c93b33b..96a360d034971ac3f035baed45c97a95bba9d59a 100644 (file)
@@ -611,6 +611,10 @@ public:
     map<int, float> *backfill,
     map<int, float> *nearfull) const;
 
+  void get_full_osd_counts(set<int> *full, set<int> *backfill,
+                          set<int> *nearfull) const;
+
+
   /***** cluster state *****/
   /* osds */
   int get_max_osd() const { return max_osd; }