{
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) {
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;
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
}
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",