From 119fc0e5525eab84a7e4e2b3f98bf012013346cf Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 18 Sep 2018 14:08:41 -0500 Subject: [PATCH] mon: report device id used by mon This will feed into the same device tracking that OSDs currently use. Signed-off-by: Sage Weil --- src/mon/Monitor.cc | 13 +++++++++++++ src/mon/MonitorDBStore.h | 8 ++++++++ 2 files changed, 21 insertions(+) diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index c24b8ca436e18..29093442828c9 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 227b36e70a6a2..0561dadf8c8d2 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; -- 2.39.5