From: Sage Weil Date: Thu, 10 Oct 2019 23:37:27 +0000 (-0500) Subject: mon: fix 'smart' asok command X-Git-Tag: v15.1.0~1178^2~14 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=484f1cbe81a8b23707a2014de3e573c7226d0b18;p=ceph.git mon: fix 'smart' asok command Move to the right function, registery, and remove from the CLI command registry. Signed-off-by: Sage Weil --- diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index 562925342458..fee9813e46eb 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -1253,6 +1253,3 @@ COMMAND("config generate-minimal-conf", "Generate a minimal ceph.conf file", "config", "r") -COMMAND_WITH_FLAG("smart name=devid,type=CephString,req=false", - "Query health metrics for underlying device", - "mon", "rw", FLAG(HIDDEN)) diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index a9e1ff01e462..1638b2b38633 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -356,6 +356,33 @@ void Monitor::do_admin_command( err << "op_tracker tracking is not enabled now, so no ops are tracked currently, even those get stuck. \ please enable \"mon_enable_op_tracker\", and the tracker will start to track new ops received afterwards."; } + } else if (command == "smart") { + string want_devid; + cmd_getval(cct, cmdmap, "devid", want_devid); + + string devname = store->get_devname(); + set devnames; + get_raw_devices(devname, &devnames); + json_spirit::mObject json_map; + uint64_t smart_timeout = cct->_conf.get_val( + "mon_smart_report_timeout"); + for (auto& devname : devnames) { + string err; + string devid = get_device_id(devname, &err); + if (want_devid.size() && want_devid != devid) { + derr << "get_device_id failed on " << devname << ": " << err << dendl; + continue; + } + json_spirit::mValue smart_json; + if (block_device_get_metrics(devname, smart_timeout, + &smart_json)) { + dout(10) << "block_device_get_metrics failed for /dev/" << devname + << dendl; + continue; + } + json_map[devid] = smart_json; + } + json_spirit::write(json_map, out, json_spirit::pretty_print); } else { ceph_abort_msg("bad AdminSocket command binding"); } @@ -830,6 +857,10 @@ int Monitor::preinit() admin_hook, "show recent slow ops"); ceph_assert(r == 0); + r = admin_socket->register_command("smart name=devid,type=CephString,req=false", + admin_hook, + "probe OSD devices for SMART data."); + ceph_assert(r == 0); l.lock(); @@ -3840,37 +3871,6 @@ void Monitor::handle_command(MonOpRequestRef op) f->flush(rdata); rs = ""; r = 0; - } else if (prefix == "smart") { - string want_devid; - cmd_getval(cct, cmdmap, "devid", want_devid); - - string devname = store->get_devname(); - set devnames; - get_raw_devices(devname, &devnames); - json_spirit::mObject json_map; - uint64_t smart_timeout = cct->_conf.get_val( - "mon_smart_report_timeout"); - for (auto& devname : devnames) { - string err; - string devid = get_device_id(devname, &err); - if (want_devid.size() && want_devid != devid) { - derr << "get_device_id failed on " << devname << ": " << err << dendl; - continue; - } - json_spirit::mValue smart_json; - if (block_device_get_metrics(devname, smart_timeout, - &smart_json)) { - dout(10) << "block_device_get_metrics failed for /dev/" << devname - << dendl; - continue; - } - 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: