From: Sage Weil Date: Fri, 21 Jul 2017 17:29:47 +0000 (-0400) Subject: mgr: keep per-module checks, and report them back to the mon X-Git-Tag: v12.1.2~52^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e51be85c24d36cb3f50f98f7c401f352fd1cd7e4;p=ceph.git mgr: keep per-module checks, and report them back to the mon Signed-off-by: Sage Weil --- diff --git a/src/mgr/DaemonServer.cc b/src/mgr/DaemonServer.cc index dc9837cac82..a58675ed24c 100644 --- a/src/mgr/DaemonServer.cc +++ b/src/mgr/DaemonServer.cc @@ -1169,6 +1169,8 @@ void DaemonServer::send_report() } auto m = new MMonMgrReport(); + py_modules.get_health_checks(&m->health_checks); + cluster_state.with_pgmap([&](const PGMap& pg_map) { cluster_state.update_delta_stats(); @@ -1191,6 +1193,7 @@ void DaemonServer::send_report() pg_map.get_health_checks(g_ceph_context, osdmap, &m->health_checks); + dout(10) << m->health_checks.checks.size() << " health checks" << dendl; dout(20) << "health checks:\n"; diff --git a/src/mgr/MgrPyModule.cc b/src/mgr/MgrPyModule.cc index fda9bf6528d..a2bf73ca379 100644 --- a/src/mgr/MgrPyModule.cc +++ b/src/mgr/MgrPyModule.cc @@ -365,3 +365,7 @@ int MgrPyModule::handle_command( return r; } +void MgrPyModule::get_health_checks(health_check_map_t *checks) +{ + checks->merge(health_checks); +} diff --git a/src/mgr/MgrPyModule.h b/src/mgr/MgrPyModule.h index 14be1566f06..6eea29eee24 100644 --- a/src/mgr/MgrPyModule.h +++ b/src/mgr/MgrPyModule.h @@ -21,6 +21,8 @@ #include "common/cmdparse.h" #include "common/LogEntry.h" +#include "common/Mutex.h" +#include "mon/health_check.h" #include #include @@ -47,6 +49,8 @@ private: PyThreadState *pMainThreadState; PyThreadState *pMyThreadState = nullptr; + health_check_map_t health_checks; + std::vector commands; int load_commands(); @@ -75,6 +79,11 @@ public: const cmdmap_t &cmdmap, std::stringstream *ds, std::stringstream *ss); + + void set_health_checks(health_check_map_t&& c) { + health_checks = std::move(c); + } + void get_health_checks(health_check_map_t *checks); }; std::string handle_pyerror(); diff --git a/src/mgr/PyModules.cc b/src/mgr/PyModules.cc index 74628dbbf1c..e95bec8d75d 100644 --- a/src/mgr/PyModules.cc +++ b/src/mgr/PyModules.cc @@ -800,3 +800,21 @@ void PyModules::list_modules(std::set *modules) { _list_modules(g_conf->mgr_module_path, modules); } + +void PyModules::set_health_checks(const std::string& handle, + health_check_map_t&& checks) +{ + Mutex::Locker l(lock); + auto p = modules.find(handle); + if (p != modules.end()) { + p->second->set_health_checks(std::move(checks)); + } +} + +void PyModules::get_health_checks(health_check_map_t *checks) +{ + Mutex::Locker l(lock); + for (auto& p : modules) { + p.second->get_health_checks(checks); + } +} diff --git a/src/mgr/PyModules.h b/src/mgr/PyModules.h index 1c6751f4e51..431abec76f0 100644 --- a/src/mgr/PyModules.h +++ b/src/mgr/PyModules.h @@ -30,6 +30,7 @@ #include "ClusterState.h" class ServeThread; +class health_check_map_t; class PyModules { @@ -115,6 +116,10 @@ public: void set_config(const std::string &handle, const std::string &key, const std::string &val); + void set_health_checks(const std::string& handle, + health_check_map_t&& checks); + void get_health_checks(health_check_map_t *checks); + void log(const std::string &handle, int level, const std::string &record);