From: Sage Weil Date: Fri, 8 Jun 2018 14:21:36 +0000 (-0500) Subject: osd: key smart results by unique device id X-Git-Tag: v14.0.1~1030^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a5957a9d131bd63619de93fca4da666f42b35384;p=ceph.git osd: key smart results by unique device id This is more useful than the current local device name. Clean up some formatting. Signed-off-by: Sage Weil --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index d6596fb36f74..46d1ae683587 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -6196,10 +6196,12 @@ void OSD::probe_smart(ostream& ss) { set devnames; store->get_devices(&devnames); - uint64_t smart_timeout = cct->_conf->get_val("osd_smart_report_timeout"); + uint64_t smart_timeout = cct->_conf->get_val( + "osd_smart_report_timeout"); std::string result; - json_spirit::mObject json_map; // == typedef std::map mObject; + // == typedef std::map 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",