.set_default(true)
.set_description(""),
+ Option("mon_smart_report_timeout", Option::TYPE_UINT, Option::LEVEL_ADVANCED)
+ .set_default(5)
+ .set_description("Timeout (in seconds) for smarctl to run, default is set to 5"),
+
+
Option("paxos_stash_full_interval", Option::TYPE_INT, Option::LEVEL_ADVANCED)
.set_default(25)
.set_description(""),
.set_min(2)
.set_description("Number of striping periods to zero head of MDS journal write position"),
- Option("osd_smart_report_timeout", Option::TYPE_UINT, Option::LEVEL_ADVANCED)
+ Option("osd_smart_report_timeout", Option::TYPE_UINT, Option::LEVEL_ADVANCED)
.set_default(5)
.set_description("Timeout (in seconds) for smarctl to run, default is set to 5"),
" name=num,type=CephInt",
"Revert configuration to previous state",
"config", "rw", "cli,rest")
+
+COMMAND_WITH_FLAG("smart name=devid,type=CephString,req=false",
+ "Query health metrics for underlying device",
+ "mon", "rw", "cli,rest",
+ FLAG(HIDDEN))
#include <boost/scope_exit.hpp>
#include <boost/algorithm/string/predicate.hpp>
+#include "json_spirit/json_spirit_reader.h"
+#include "json_spirit/json_spirit_writer.h"
+
#include "Monitor.h"
#include "common/version.h"
#include "common/blkdev.h"
f->flush(rdata);
rs = "";
r = 0;
+ } else if (prefix == "smart") {
+ string want_devid;
+ cmd_getval(cct, cmdmap, "devid", want_devid);
+
+ string dev = store->get_devname();
+ string devid = get_device_id(dev);
+ if (want_devid.size() && want_devid != devid) {
+ r = -ENOENT;
+ } else {
+ uint64_t smart_timeout = cct->_conf.get_val<uint64_t>(
+ "mon_smart_report_timeout");
+ json_spirit::mObject json_map;
+ json_spirit::mValue smart_json;
+ std::string result;
+ if (block_device_run_smartctl(("/dev/" + dev).c_str(), smart_timeout,
+ &result)) {
+ dout(10) << "probe_smart_device failed for /dev/" << dev << dendl;
+ result = "{\"error\": \"smartctl failed\", \"dev\": \"" + dev +
+ "\", \"smartctl_error\": \"" + result + "\"}";
+ }
+
+ if (!json_spirit::read(result, smart_json)) {
+ derr << "smartctl JSON output of /dev/" + dev + " is invalid"
+ << dendl;
+ } else {
+ json_map[devid] = smart_json;
+ }
+ ostringstream ss;
+ json_spirit::write(json_map, ss, json_spirit::pretty_print);
+ rdata.append(ss.str());
+ r = 0;
+ rs = "";
+ }
}
out: