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: 15 HealthMetricCollection(sdbusplus::bus_t& bus, MetricIntf::Type type, 16 const configs_t& configs, 17 MetricIntf::paths_t& bmcPaths) : 18 bus(bus), 19 type(type), configs(configs) 20 { 21 create(bmcPaths); 22 } 23 24 /** @brief Read the health metric collection from the system */ 25 void read(); 26 27 private: 28 using map_t = std::unordered_map<std::string, 29 std::unique_ptr<MetricIntf::HealthMetric>>; 30 using time_map_t = std::unordered_map<MetricIntf::SubType, uint64_t>; 31 /** @brief Create a new health metric collection object */ 32 void create(const MetricIntf::paths_t& bmcPaths); 33 /** @brief Read the CPU */ 34 auto readCPU() -> bool; 35 /** @brief Read the memory */ 36 auto readMemory() -> bool; 37 /** @brief Read the storage */ 38 auto readStorage() -> bool; 39 /** @brief D-Bus bus connection */ 40 sdbusplus::bus_t& bus; 41 /** @brief Metric type */ 42 MetricIntf::Type type; 43 /** @brief Health metric configs */ 44 const configs_t& configs; 45 /** @brief Map of health metrics by subtype */ 46 map_t metrics; 47 /** @brief Map for active time by subtype */ 48 time_map_t preActiveTime; 49 /** @brief Map for total time by subtype */ 50 time_map_t preTotalTime; 51 }; 52 53 } // namespace phosphor::health::metric::collection 54