Jagpal Singh Gill | 81da137 | 2023-12-15 17:01:03 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "health_metric_collection.hpp" |
| 4 | |
Patrick Williams | 84d0a88 | 2024-02-22 12:57:09 -0600 | [diff] [blame] | 5 | #include <sdbusplus/async.hpp> |
| 6 | |
Jagpal Singh Gill | 81da137 | 2023-12-15 17:01:03 -0800 | [diff] [blame] | 7 | #include <unordered_map> |
| 8 | |
| 9 | namespace phosphor::health::monitor |
| 10 | { |
| 11 | namespace ConfigIntf = phosphor::health::metric::config; |
| 12 | namespace MetricIntf = phosphor::health::metric; |
| 13 | namespace CollectionIntf = phosphor::health::metric::collection; |
| 14 | class HealthMonitor |
| 15 | { |
| 16 | public: |
| 17 | HealthMonitor() = delete; |
| 18 | |
Patrick Williams | 84d0a88 | 2024-02-22 12:57:09 -0600 | [diff] [blame] | 19 | explicit HealthMonitor(sdbusplus::async::context& ctx) : |
| 20 | ctx(ctx), configs(ConfigIntf::getHealthMetricConfigs()) |
Jagpal Singh Gill | 81da137 | 2023-12-15 17:01:03 -0800 | [diff] [blame] | 21 | { |
Patrick Williams | 84d0a88 | 2024-02-22 12:57:09 -0600 | [diff] [blame] | 22 | ctx.spawn(startup()); |
Jagpal Singh Gill | 81da137 | 2023-12-15 17:01:03 -0800 | [diff] [blame] | 23 | } |
| 24 | |
Jagpal Singh Gill | 81da137 | 2023-12-15 17:01:03 -0800 | [diff] [blame] | 25 | private: |
Patrick Williams | 84d0a88 | 2024-02-22 12:57:09 -0600 | [diff] [blame] | 26 | /** @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 Gill | 81da137 | 2023-12-15 17:01:03 -0800 | [diff] [blame] | 31 | using map_t = std::unordered_map< |
| 32 | MetricIntf::Type, |
| 33 | std::unique_ptr<CollectionIntf::HealthMetricCollection>>; |
Patrick Williams | 84d0a88 | 2024-02-22 12:57:09 -0600 | [diff] [blame] | 34 | |
| 35 | /** @brief D-Bus context */ |
| 36 | sdbusplus::async::context& ctx; |
Jagpal Singh Gill | 81da137 | 2023-12-15 17:01:03 -0800 | [diff] [blame] | 37 | /** @brief Health metric configs */ |
| 38 | ConfigIntf::HealthMetric::map_t configs; |
| 39 | map_t collections; |
| 40 | }; |
| 41 | |
| 42 | } // namespace phosphor::health::monitor |