| #pragma once |
| |
| #include <xyz/openbmc_project/Common/Threshold/server.hpp> |
| |
| #include <chrono> |
| #include <limits> |
| #include <map> |
| #include <string> |
| #include <vector> |
| |
| namespace phosphor::health::metric |
| { |
| |
| using ThresholdIntf = |
| sdbusplus::server::xyz::openbmc_project::common::Threshold; |
| |
| enum class Type |
| { |
| cpu, |
| memory, |
| storage, |
| inode, |
| unknown |
| }; |
| |
| enum class SubType |
| { |
| // CPU subtypes |
| cpuKernel, |
| cpuTotal, |
| cpuUser, |
| // Memory subtypes |
| memoryAvailable, |
| memoryBufferedAndCached, |
| memoryFree, |
| memoryShared, |
| memoryTotal, |
| // Storage subtypes |
| storageReadWrite, |
| storageTmp, |
| NA |
| }; |
| |
| namespace config |
| { |
| |
| using namespace std::literals::chrono_literals; |
| |
| struct Threshold |
| { |
| double value = defaults::value; |
| bool log = false; |
| std::string target = defaults::target; |
| |
| using map_t = |
| std::map<std::tuple<ThresholdIntf::Type, ThresholdIntf::Bound>, |
| Threshold>; |
| |
| struct defaults |
| { |
| static constexpr auto value = std::numeric_limits<double>::quiet_NaN(); |
| static constexpr auto target = ""; |
| }; |
| }; |
| |
| struct HealthMetric |
| { |
| /** @brief The name of the metric. */ |
| std::string name = "unnamed"; |
| /** @brief The metric subtype. */ |
| SubType subType = SubType::NA; |
| /** @brief The collection frequency for the metric. */ |
| std::chrono::seconds collectionFreq = defaults::frequency; |
| /** @brief The window size for the metric. */ |
| size_t windowSize = defaults::windowSize; |
| /** @brief The threshold configs for the metric. */ |
| Threshold::map_t thresholds{}; |
| /** @brief The path for filesystem metric */ |
| std::string path = defaults::path; |
| |
| using map_t = std::map<Type, std::vector<HealthMetric>>; |
| |
| struct defaults |
| { |
| static constexpr auto frequency = 1s; |
| static constexpr auto windowSize = 1; |
| static constexpr auto path = ""; |
| }; |
| }; |
| |
| /** @brief Get the health metric configs. */ |
| auto getHealthMetricConfigs() -> HealthMetric::map_t; |
| |
| } // namespace config |
| } // namespace phosphor::health::metric |