From: Sage Weil Date: Tue, 18 Sep 2018 19:08:41 +0000 (-0500) Subject: mon: report device id used by mon X-Git-Tag: v14.0.1~19^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=119fc0e5525eab84a7e4e2b3f98bf012013346cf;p=ceph.git mon: report device id used by mon This will feed into the same device tracking that OSDs currently use. Signed-off-by: Sage Weil --- diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index c24b8ca436e1..29093442828c 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -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() diff --git a/src/mon/MonitorDBStore.h b/src/mon/MonitorDBStore.h index 227b36e70a6a..0561dadf8c8d 100644 --- a/src/mon/MonitorDBStore.h +++ b/src/mon/MonitorDBStore.h @@ -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;