]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: key smart results by unique device id
authorSage Weil <sage@redhat.com>
Fri, 8 Jun 2018 14:21:36 +0000 (09:21 -0500)
committerSage Weil <sage@redhat.com>
Sat, 23 Jun 2018 22:01:31 +0000 (17:01 -0500)
This is more useful than the current local device name.

Clean up some formatting.

Signed-off-by: Sage Weil <sage@redhat.com>
src/osd/OSD.cc

index d6596fb36f74d7eaa1a04f55fafa1e28156aeeb3..46d1ae683587de7b1e0287dbe5955ebd780b7ef5 100644 (file)
@@ -6196,10 +6196,12 @@ void OSD::probe_smart(ostream& ss)
 {
   set<string> devnames;
   store->get_devices(&devnames);
-  uint64_t smart_timeout = cct->_conf->get_val<uint64_t>("osd_smart_report_timeout");
+  uint64_t smart_timeout = cct->_conf->get_val<uint64_t>(
+    "osd_smart_report_timeout");
   std::string result;
 
-  json_spirit::mObject json_map; // == typedef std::map<std::string, mValue> mObject;
+  // == typedef std::map<std::string, mValue> mObject;
+  json_spirit::mObject json_map;
   json_spirit::mValue smart_json;
 
   for (auto dev : devnames) {
@@ -6208,6 +6210,12 @@ void OSD::probe_smart(ostream& ss)
       continue;
     }
 
+    string devid = get_device_id(dev);
+    if (devid.size() == 0) {
+      dout(10) << __func__ << " no unique id for dev " << dev << ", skipping"
+              << dendl;
+      continue;
+    }
     if (probe_smart_device(("/dev/" + dev).c_str(), smart_timeout, &result)) {
       dout(10) << "probe_smart_device failed for /dev/" << dev << dendl;
       continue;
@@ -6217,7 +6225,7 @@ void OSD::probe_smart(ostream& ss)
     if (!json_spirit::read(result, smart_json)) {
       derr << "smartctl JSON output of /dev/" + dev + " is invalid" << dendl;
     } else { //json is valid, assigning
-      json_map[dev] = smart_json;
+      json_map[devid] = smart_json;
     }
     // no need to result.clear() or clear smart_json
   }
@@ -6227,8 +6235,9 @@ void OSD::probe_smart(ostream& ss)
 int OSD::probe_smart_device(const char *device, int timeout, std::string *result)
 {
   // when using --json, smartctl will report its errors in JSON format to stdout 
-  SubProcessTimed smartctl("sudo", SubProcess::CLOSE, SubProcess::PIPE, SubProcess::CLOSE,
-                          timeout);
+  SubProcessTimed smartctl(
+    "sudo", SubProcess::CLOSE, SubProcess::PIPE, SubProcess::CLOSE,
+    timeout);
   smartctl.add_cmd_args(
     "smartctl",
     "-a",