blob: 29c62475d67ee3104812cf6ac7de0eb4a0d01584 [file] [log] [blame]
Jagpal Singh Gill81da1372023-12-15 17:01:03 -08001#pragma once
2
3#include "health_metric_collection.hpp"
4
Patrick Williams84d0a882024-02-22 12:57:09 -06005#include <sdbusplus/async.hpp>
6
Jagpal Singh Gill81da1372023-12-15 17:01:03 -08007#include <unordered_map>
8
9namespace phosphor::health::monitor
10{
11namespace ConfigIntf = phosphor::health::metric::config;
12namespace MetricIntf = phosphor::health::metric;
13namespace CollectionIntf = phosphor::health::metric::collection;
14class HealthMonitor
15{
16 public:
17 HealthMonitor() = delete;
18
Patrick Williams84d0a882024-02-22 12:57:09 -060019 explicit HealthMonitor(sdbusplus::async::context& ctx) :
20 ctx(ctx), configs(ConfigIntf::getHealthMetricConfigs())
Jagpal Singh Gill81da1372023-12-15 17:01:03 -080021 {
Patrick Williams84d0a882024-02-22 12:57:09 -060022 ctx.spawn(startup());
Jagpal Singh Gill81da1372023-12-15 17:01:03 -080023 }
24
Jagpal Singh Gill81da1372023-12-15 17:01:03 -080025 private:
Patrick Williams84d0a882024-02-22 12:57:09 -060026 /** @brief Setup and run a new health monitor object */
27 auto startup() -> sdbusplus::async::task<>;
28 /** @brief Run the health monitor */
29 auto run() -> sdbusplus::async::task<>;
30
Jagpal Singh Gill81da1372023-12-15 17:01:03 -080031 using map_t = std::unordered_map<
32 MetricIntf::Type,
33 std::unique_ptr<CollectionIntf::HealthMetricCollection>>;
Patrick Williams84d0a882024-02-22 12:57:09 -060034
35 /** @brief D-Bus context */
36 sdbusplus::async::context& ctx;
Jagpal Singh Gill81da1372023-12-15 17:01:03 -080037 /** @brief Health metric configs */
38 ConfigIntf::HealthMetric::map_t configs;
39 map_t collections;
40};
41
42} // namespace phosphor::health::monitor