]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | #pragma once |
2 | ||
3 | #include <memory> | |
4 | #include <string> | |
5 | ||
6 | #include "DaemonHealthMetric.h" | |
9f95a23c | 7 | #include "DaemonKey.h" |
11fdf7f2 TL |
8 | #include "mon/health_check.h" |
9 | ||
10 | class DaemonHealthMetricCollector { | |
11 | public: | |
11fdf7f2 TL |
12 | static std::unique_ptr<DaemonHealthMetricCollector> create(daemon_metric m); |
13 | void update(const DaemonKey& daemon, const DaemonHealthMetric& metric) { | |
14 | if (_is_relevant(metric.get_type())) { | |
eafe8130 | 15 | reported |= _update(daemon, metric); |
11fdf7f2 TL |
16 | } |
17 | } | |
18 | void summarize(health_check_map_t& cm) { | |
19 | if (reported) { | |
20 | _summarize(_get_check(cm)); | |
21 | } | |
22 | } | |
23 | virtual ~DaemonHealthMetricCollector() {} | |
24 | private: | |
25 | virtual bool _is_relevant(daemon_metric type) const = 0; | |
26 | virtual health_check_t& _get_check(health_check_map_t& cm) const = 0; | |
27 | virtual bool _update(const DaemonKey& daemon, const DaemonHealthMetric& metric) = 0; | |
28 | virtual void _summarize(health_check_t& check) const = 0; | |
29 | protected: | |
30 | daemon_metric_t value; | |
31 | bool reported = false; | |
32 | }; |