#pragma once #include #include #include #include #include #include #include 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, // Types for which subtype is not applicable NA }; auto to_string(Type) -> std::string; auto to_string(SubType) -> std::string; 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, Threshold>; struct defaults { static constexpr auto value = std::numeric_limits::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 window size for the metric. */ size_t windowSize = defaults::windowSize; /** @brief The hysteresis for the metric */ double hysteresis = defaults::hysteresis; /** @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>; struct defaults { static constexpr auto windowSize = 120; static constexpr auto path = ""; static constexpr auto hysteresis = 1.0; }; }; /** @brief Get the health metric configs. */ auto getHealthMetricConfigs() -> HealthMetric::map_t; } // namespace config } // namespace phosphor::health::metric