enable health_monitor new implementation
Add health_monitor interface and implementation. Enable the
health_monitor from existing healthMonitor flow.
This change is in relation to following design and D-Bus interface
update -
https://gerrit.openbmc.org/c/openbmc/docs/+/64917
https://gerrit.openbmc.org/c/openbmc/phosphor-dbus-interfaces/+/64914
Tested:
```
busctl tree xyz.openbmc_project.HealthMon
`- /xyz
`- /xyz/openbmc_project
`- /xyz/openbmc_project/metric
`- /xyz/openbmc_project/metric/bmc
|- /xyz/openbmc_project/metric/bmc/cpu
| |- /xyz/openbmc_project/metric/bmc/cpu/kernel
| |- /xyz/openbmc_project/metric/bmc/cpu/total
| `- /xyz/openbmc_project/metric/bmc/cpu/user
|- /xyz/openbmc_project/metric/bmc/memory
| |- /xyz/openbmc_project/metric/bmc/memory/available
| |- /xyz/openbmc_project/metric/bmc/memory/buffered_and_cached
| |- /xyz/openbmc_project/metric/bmc/memory/free
| |- /xyz/openbmc_project/metric/bmc/memory/shared
| `- /xyz/openbmc_project/metric/bmc/memory/total
`- /xyz/openbmc_project/metric/bmc/storage
|- /xyz/openbmc_project/metric/bmc/storage/rw
`- /xyz/openbmc_project/metric/bmc/storage/tmp
curl -k https://localhost:8443/redfish/v1/Managers/bmc/ManagerDiagnosticData
--user "root:0penBmc"
{
"@odata.id": "/redfish/v1/Managers/bmc/ManagerDiagnosticData",
"@odata.type": "#ManagerDiagnosticData.v1_2_0.ManagerDiagnosticData",
"FreeStorageSpaceKiB": 3,
"Id": "ManagerDiagnosticData",
"MemoryStatistics": {
"AvailableBytes": 354029533,
"BuffersAndCacheBytes": 79077333,
"FreeBytes": 291730033,
"SharedBytes": 11876000,
"TotalBytes": 425516000
},
"Name": "Manager Diagnostic Data",
"ProcessorStatistics": {
"KernelPercent": 16.1534,
"UserPercent": 10.6638
},
"ServiceRootUptimeSeconds": 834.753
}
```
Change-Id: I1e9fac226b438f0556cb20321f1f2b6d51af7dbc
Signed-off-by: Jagpal Singh Gill <paligill@gmail.com>
diff --git a/health_monitor.hpp b/health_monitor.hpp
new file mode 100644
index 0000000..31d16ba
--- /dev/null
+++ b/health_monitor.hpp
@@ -0,0 +1,39 @@
+#pragma once
+
+#include "health_metric_collection.hpp"
+
+#include <unordered_map>
+
+namespace phosphor::health::monitor
+{
+namespace ConfigIntf = phosphor::health::metric::config;
+namespace MetricIntf = phosphor::health::metric;
+namespace CollectionIntf = phosphor::health::metric::collection;
+class HealthMonitor
+{
+ public:
+ HealthMonitor() = delete;
+
+ HealthMonitor(sdbusplus::bus_t& bus) :
+ bus(bus), configs(ConfigIntf::getHealthMetricConfigs())
+ {
+ create();
+ }
+
+ /** @brief Run the health monitor */
+ void run();
+
+ private:
+ using map_t = std::unordered_map<
+ MetricIntf::Type,
+ std::unique_ptr<CollectionIntf::HealthMetricCollection>>;
+ /** @brief Create a new health monitor object */
+ void create();
+ /** @brief D-Bus bus connection */
+ sdbusplus::bus_t& bus;
+ /** @brief Health metric configs */
+ ConfigIntf::HealthMetric::map_t configs;
+ map_t collections;
+};
+
+} // namespace phosphor::health::monitor