summaryrefslogtreecommitdiffstats
path: root/src/mgr/DaemonHealthMetricCollector.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
commit19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch)
tree42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/mgr/DaemonHealthMetricCollector.h
parentInitial commit. (diff)
downloadceph-upstream/16.2.11+ds.tar.xz
ceph-upstream/16.2.11+ds.zip
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/mgr/DaemonHealthMetricCollector.h')
-rw-r--r--src/mgr/DaemonHealthMetricCollector.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/mgr/DaemonHealthMetricCollector.h b/src/mgr/DaemonHealthMetricCollector.h
new file mode 100644
index 000000000..558f4e334
--- /dev/null
+++ b/src/mgr/DaemonHealthMetricCollector.h
@@ -0,0 +1,32 @@
+#pragma once
+
+#include <memory>
+#include <string>
+
+#include "DaemonHealthMetric.h"
+#include "DaemonKey.h"
+#include "mon/health_check.h"
+
+class DaemonHealthMetricCollector {
+public:
+ static std::unique_ptr<DaemonHealthMetricCollector> create(daemon_metric m);
+ void update(const DaemonKey& daemon, const DaemonHealthMetric& metric) {
+ if (_is_relevant(metric.get_type())) {
+ reported |= _update(daemon, metric);
+ }
+ }
+ void summarize(health_check_map_t& cm) {
+ if (reported) {
+ _summarize(_get_check(cm));
+ }
+ }
+ virtual ~DaemonHealthMetricCollector() {}
+private:
+ virtual bool _is_relevant(daemon_metric type) const = 0;
+ virtual health_check_t& _get_check(health_check_map_t& cm) const = 0;
+ virtual bool _update(const DaemonKey& daemon, const DaemonHealthMetric& metric) = 0;
+ virtual void _summarize(health_check_t& check) const = 0;
+protected:
+ daemon_metric_t value;
+ bool reported = false;
+};