]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mon: report device id used by mon
authorSage Weil <sage@redhat.com>
Tue, 18 Sep 2018 19:08:41 +0000 (14:08 -0500)
committerSage Weil <sage@redhat.com>
Mon, 15 Oct 2018 14:44:05 +0000 (09:44 -0500)
This will feed into the same device tracking that OSDs currently use.

Signed-off-by: Sage Weil <sage@redhat.com>
src/mon/Monitor.cc
src/mon/MonitorDBStore.h

index c24b8ca436e18fe02e4ab548ecd22c435b25a90b..29093442828c92546a33f90c9a54074537815769 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "Monitor.h"
 #include "common/version.h"
+#include "common/blkdev.h"
 
 #include "osd/OSDMap.h"
 
@@ -2094,6 +2095,18 @@ void Monitor::collect_metadata(Metadata *m)
   collect_sys_info(m, g_ceph_context);
   (*m)["addr"] = stringify(messenger->get_myaddr());
   (*m)["compression_algorithms"] = collect_compression_algorithms();
+
+  // infer storage device
+  string devname = store->get_devname();
+  if (devname.size()) {
+    (*m)["devices"] = devname;
+    string id = get_device_id(devname);
+    if (id.size()) {
+      (*m)["device_ids"] = string(devname) + "=" + id;
+    } else {
+      derr << "failed to get devid for " << devname << dendl;
+    }
+  }
 }
 
 void Monitor::finish_election()
index 227b36e70a6a2589a8cc421d10001463b1af07fc..0561dadf8c8d2748c001211ea8f5b12de685a7a7 100644 (file)
@@ -29,6 +29,7 @@
 #include "common/errno.h"
 #include "common/debug.h"
 #include "common/safe_io.h"
+#include "common/blkdev.h"
 
 #define dout_context g_ceph_context
 
@@ -48,6 +49,13 @@ class MonitorDBStore
 
  public:
 
+  string get_devname() {
+    char devname[4096] = {0}, partition[4096];
+    get_device_by_path(path.c_str(), partition, devname,
+                      sizeof(devname));
+    return devname;
+  }
+
   struct Op {
     uint8_t type;
     string prefix;