From 6fed1d21be1adf1464b5834787c95fae205a91b5 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 24 Oct 2017 22:41:30 +0800 Subject: [PATCH] mgr/MgrClient: send health_checks using MMgrReport Signed-off-by: Kefu Chai --- src/messages/MMgrReport.h | 12 +++++++++++- src/mgr/MgrClient.cc | 6 ++++++ src/mgr/MgrClient.h | 6 ++++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/messages/MMgrReport.h b/src/messages/MMgrReport.h index 26268927b1a5c..f6af6dfb86aa0 100644 --- a/src/messages/MMgrReport.h +++ b/src/messages/MMgrReport.h @@ -20,6 +20,7 @@ #include "msg/Message.h" #include "common/perf_counters.h" +#include "osd/OSDHealthMetric.h" class PerfCounterType { @@ -66,7 +67,7 @@ WRITE_CLASS_ENCODER(PerfCounterType) class MMgrReport : public Message { - static const int HEAD_VERSION = 4; + static const int HEAD_VERSION = 5; static const int COMPAT_VERSION = 1; public: @@ -92,6 +93,8 @@ public: // for service registration boost::optional> daemon_status; + std::vector osd_health_metrics; + void decode_payload() override { bufferlist::iterator p = payload.begin(); @@ -104,6 +107,9 @@ public: ::decode(service_name, p); ::decode(daemon_status, p); } + if (header.version >= 5) { + ::decode(osd_health_metrics, p); + } } void encode_payload(uint64_t features) override { @@ -113,6 +119,7 @@ public: ::encode(undeclare_types, payload); ::encode(service_name, payload); ::encode(daemon_status, payload); + ::encode(osd_health_metrics, payload); } const char *get_type_name() const override { return "mgrreport"; } @@ -130,6 +137,9 @@ public: if (daemon_status) { out << " status=" << daemon_status->size(); } + if (!osd_health_metrics.empty()) { + out << " osd_metrics=" << osd_health_metrics.size(); + } out << ")"; } diff --git a/src/mgr/MgrClient.cc b/src/mgr/MgrClient.cc index 910d747f88ae0..33d467303eb0a 100644 --- a/src/mgr/MgrClient.cc +++ b/src/mgr/MgrClient.cc @@ -326,6 +326,7 @@ void MgrClient::send_report() daemon_dirty_status = false; } + report->osd_health_metrics = std::move(osd_health_metrics); session->con->send_message(report); } @@ -467,3 +468,8 @@ int MgrClient::service_daemon_update_status( daemon_dirty_status = true; return 0; } + +void MgrClient::update_osd_health(std::vector&& metrics) +{ + osd_health_metrics = std::move(metrics); +} diff --git a/src/mgr/MgrClient.h b/src/mgr/MgrClient.h index 5fcbe6383845a..a3493f5c6642b 100644 --- a/src/mgr/MgrClient.h +++ b/src/mgr/MgrClient.h @@ -14,10 +14,10 @@ #ifndef MGR_CLIENT_H_ #define MGR_CLIENT_H_ +#include "msg/Connection.h" #include "msg/Dispatcher.h" #include "mon/MgrMap.h" - -#include "msg/Connection.h" +#include "osd/OSDHealthMetric.h" #include "common/perf_counters.h" #include "common/Timer.h" @@ -79,6 +79,7 @@ protected: std::string service_name, daemon_name; std::map daemon_metadata; std::map daemon_status; + std::vector osd_health_metrics; void reconnect(); void _send_open(); @@ -117,6 +118,7 @@ public: const std::map& metadata); int service_daemon_update_status( std::map&& status); + void update_osd_health(std::vector&& metrics); private: void send_stats(); -- 2.39.5