From: Sage Weil Date: Fri, 19 May 2017 16:04:27 +0000 (-0400) Subject: mon/OSDMonitor: separate health warnings into distinct messages X-Git-Tag: v12.1.0~10^2~20^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9183375b90986c095853d4a63d79660747026dd9;p=ceph.git mon/OSDMonitor: separate health warnings into distinct messages Each warning is a distinct message; the caller formats it as it deems appropriate. Signed-off-by: Sage Weil --- diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 2bdf84ed5d1e..b271855f019a 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -3549,12 +3549,12 @@ void OSDMonitor::get_health(list >& summary, num_down_in_osds = down_in_osds.size(); assert(num_down_in_osds <= num_in_osds); if (num_down_in_osds > 0) { - ostringstream ss; - ss << "\n"; // summary of down subtree types and osds for (int type = max_type; type > 0; type--) { if (subtree_type_down[type].size() > 0) { - ss << subtree_type_down[type].size() << " " << osdmap.crush->get_type_name(type); + ostringstream ss; + ss << subtree_type_down[type].size() << " " + << osdmap.crush->get_type_name(type); if (subtree_type_down[type].size() > 1) { ss << "s"; } @@ -3564,19 +3564,21 @@ void OSDMonitor::get_health(list >& summary, ++j) { sum_down_osds = sum_down_osds + num_osds_subtree[*j]; } - ss << " (" << sum_down_osds << " osds) down\n"; + ss << " (" << sum_down_osds << " osds) down"; + summary.push_back(make_pair(HEALTH_WARN, ss.str())); } } - ss << down_in_osds.size() << " osds down\n"; + ostringstream ss; + ss << down_in_osds.size() << " osds down"; summary.push_back(make_pair(HEALTH_WARN, ss.str())); if (detail) { - ostringstream ss; // details of down subtree types for (int type = max_type; type > 0; type--) { for (auto j = subtree_type_down[type].rbegin(); j != subtree_type_down[type].rend(); ++j) { + ostringstream ss; ss << osdmap.crush->get_type_name(type); ss << " "; ss << osdmap.crush->get_item_name(*j); @@ -3588,16 +3590,18 @@ void OSDMonitor::get_health(list >& summary, } int num = num_osds_subtree[*j]; ss << " (" << num << " osds)"; - ss << " is down\n"; + ss << " is down"; + detail->push_back(make_pair(HEALTH_WARN, ss.str())); } } // details of down osds for (auto it = down_in_osds.begin(); it != down_in_osds.end(); ++it) { + ostringstream ss; ss << "osd." << *it << " ("; ss << osdmap.crush->get_full_location_ordered_string(*it); - ss << ") is down\n"; + ss << ") is down"; + detail->push_back(make_pair(HEALTH_WARN, ss.str())); } - detail->push_back(make_pair(HEALTH_WARN, ss.str())); } }