1 #pragma once 2 3 #include "health_metric_collection.hpp" 4 5 #include <sdbusplus/async.hpp> 6 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 HealthMonitor(sdbusplus::async::context & ctx)19 explicit HealthMonitor(sdbusplus::async::context& ctx) : 20 ctx(ctx), configs(ConfigIntf::getHealthMetricConfigs()) 21 { 22 ctx.spawn(startup()); 23 } 24 25 private: 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 31 using map_t = std::unordered_map< 32 MetricIntf::Type, 33 std::unique_ptr<CollectionIntf::HealthMetricCollection>>; 34 35 /** @brief D-Bus context */ 36 sdbusplus::async::context& ctx; 37 /** @brief Health metric configs */ 38 ConfigIntf::HealthMetric::map_t configs; 39 map_t collections; 40 }; 41 42 } // namespace phosphor::health::monitor 43