blob: f8aac92e083f9d02cd192e97ef72be276a0be0f0 [file] [log] [blame]
Jagpal Singh Gill79434b52023-12-10 15:33:05 -08001#pragma once
2
3#include "health_metric.hpp"
4
5namespace phosphor::health::metric::collection
6{
7namespace ConfigIntf = phosphor::health::metric::config;
8namespace MetricIntf = phosphor::health::metric;
9
10using configs_t = std::vector<ConfigIntf::HealthMetric>;
11
12class HealthMetricCollection
13{
14 public:
15 HealthMetricCollection(sdbusplus::bus_t& bus, MetricIntf::Type type,
16 const configs_t& configs,
17 MetricIntf::paths_t& bmcPaths) :
Patrick Williamsce8b5ae2024-08-16 15:21:18 -040018 bus(bus), type(type), configs(configs)
Jagpal Singh Gill79434b52023-12-10 15:33:05 -080019 {
20 create(bmcPaths);
21 }
22
23 /** @brief Read the health metric collection from the system */
24 void read();
25
26 private:
Jagpal Singh Gill97582802024-02-27 13:59:11 -080027 using map_t = std::unordered_map<std::string,
Jagpal Singh Gill79434b52023-12-10 15:33:05 -080028 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