1 #pragma once 2 3 #include "health_metric.hpp" 4 5 namespace phosphor::health::metric::collection 6 { 7 namespace ConfigIntf = phosphor::health::metric::config; 8 namespace MetricIntf = phosphor::health::metric; 9 10 using configs_t = std::vector<ConfigIntf::HealthMetric>; 11 12 class HealthMetricCollection 13 { 14 public: HealthMetricCollection(sdbusplus::bus_t & bus,MetricIntf::Type type,const configs_t & configs,MetricIntf::paths_t & bmcPaths)15 HealthMetricCollection(sdbusplus::bus_t& bus, MetricIntf::Type type, 16 const configs_t& configs, 17 MetricIntf::paths_t& bmcPaths) : 18 bus(bus), type(type), configs(configs) 19 { 20 create(bmcPaths); 21 } 22 23 /** @brief Read the health metric collection from the system */ 24 void read(); 25 26 private: 27 using map_t = std::unordered_map<std::string, 28 std::unique_ptr<MetricIntf::HealthMetric>>; 29 using time_map_t = std::unordered_map<MetricIntf::SubType, uint64_t>; 30 /** @brief Create a new health metric collection object */ 31 void create(const MetricIntf::paths_t& bmcPaths); 32 /** @brief Read the CPU */ 33 auto readCPU() -> bool; 34 /** @brief Read the memory */ 35 auto readMemory() -> bool; 36 /** @brief Read the storage */ 37 auto readStorage() -> bool; 38 /** @brief D-Bus bus connection */ 39 sdbusplus::bus_t& bus; 40 /** @brief Metric type */ 41 MetricIntf::Type type; 42 /** @brief Health metric configs */ 43 const configs_t& configs; 44 /** @brief Map of health metrics by subtype */ 45 map_t metrics; 46 /** @brief Map for active time by subtype */ 47 time_map_t preActiveTime; 48 /** @brief Map for total time by subtype */ 49 time_map_t preTotalTime; 50 }; 51 52 } // namespace phosphor::health::metric::collection 53