blob: 558f4e334d3f95ba0cb963a30b6d7585e5d6931d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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;
};
|