]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: optionally query smart for a single devid
authorSage Weil <sage@redhat.com>
Fri, 8 Jun 2018 22:45:43 +0000 (17:45 -0500)
committerSage Weil <sage@redhat.com>
Sat, 23 Jun 2018 22:01:31 +0000 (17:01 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
src/osd/OSD.cc
src/osd/OSD.h

index 46d1ae683587de7b1e0287dbe5955ebd780b7ef5..810d5bb8fa357f1b01b7d46a002e4a151182919b 100644 (file)
@@ -2243,7 +2243,9 @@ will start to track new ops received afterwards.";
     }
     f->close_section();
   } else if (admin_command == "smart") {
-    probe_smart(ss);
+    string devid;
+    cmd_getval(cct, cmdmap, "devid", devid);
+    probe_smart(devid, ss);
   } else if (admin_command == "list_devices") {
     set<string> devnames;
     store->get_devices(&devnames);
@@ -2813,7 +2815,7 @@ void OSD::final_init()
 
   assert(r == 0);
 
-  r = admin_socket->register_command("smart", "smart",
+  r = admin_socket->register_command("smart", "smart name=devid,type=CephString,req=False",
                                      asok_hook,
                                      "probe OSD devices for SMART data.");
 
@@ -5733,7 +5735,7 @@ COMMAND("compact",
         "compact object store's omap. "
         "WARNING: Compaction probably slows your requests",
         "osd", "rw", "cli,rest")
-COMMAND("smart",
+COMMAND("smart name=devid,type=CephString,req=False",
         "runs smartctl on this osd devices.  ",
         "osd", "rw", "cli,rest")
 };
@@ -6171,7 +6173,9 @@ void OSD::do_command(Connection *con, ceph_tid_t tid, vector<string>& cmd, buffe
   }
 
   else if (prefix == "smart") {
-    probe_smart(ds);
+    string devid;
+    cmd_getval(cct, cmdmap, "devid", devid);
+    probe_smart(devid, ds);
   }
 
   else {
@@ -6192,13 +6196,12 @@ void OSD::do_command(Connection *con, ceph_tid_t tid, vector<string>& cmd, buffe
   }
 }
 
-void OSD::probe_smart(ostream& ss)
+void OSD::probe_smart(const string& only_devid, ostream& ss)
 {
   set<string> devnames;
   store->get_devices(&devnames);
   uint64_t smart_timeout = cct->_conf->get_val<uint64_t>(
     "osd_smart_report_timeout");
-  std::string result;
 
   // == typedef std::map<std::string, mValue> mObject;
   json_spirit::mObject json_map;
@@ -6216,9 +6219,15 @@ void OSD::probe_smart(ostream& ss)
               << dendl;
       continue;
     }
+    if (only_devid.size() && devid != only_devid) {
+      continue;
+    }
+
+    std::string result;
     if (probe_smart_device(("/dev/" + dev).c_str(), smart_timeout, &result)) {
       dout(10) << "probe_smart_device failed for /dev/" << dev << dendl;
-      continue;
+      //continue;
+      result = "{\"error\": \"smartctl failed\", \"dev\": \"" + dev + "\"}";
     }
 
     // TODO: change to read_or_throw?
index 7f0afb96eb5449652d949dae7836b29f0f34d3e6..c4cf9fcea95551d7644fe49c3dc256d5da2dc46f 100644 (file)
@@ -2208,7 +2208,7 @@ private:
 
   float get_osd_recovery_sleep();
 
-  void probe_smart(ostream& ss);
+  void probe_smart(const string& devid, ostream& ss);
   int probe_smart_device(const char *device, int timeout, std::string *result);
 
 public: