blob: 51a92e3e952ced6cc546f6e84df6c1f023729be3 [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) :
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<MetricIntf::SubType,
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