diff options
Diffstat (limited to 'meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb/0011-configure-telemetry.patch')
-rw-r--r-- | meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb/0011-configure-telemetry.patch | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb/0011-configure-telemetry.patch b/meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb/0011-configure-telemetry.patch new file mode 100644 index 0000000000..d77457ce7a --- /dev/null +++ b/meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb/0011-configure-telemetry.patch @@ -0,0 +1,89 @@ +From 1920d507c28baa6ca9ec3de3694a2df218a4f265 Mon Sep 17 00:00:00 2001 +From: eportnov <eportnov@ibs.ru> +Date: Thu, 8 Sep 2022 14:25:36 +0300 +Subject: [PATCH] configure telemetry + +--- + include/dbus_utility.hpp | 1 + + redfish-core/lib/metric_report.hpp | 39 +++++++++++++++++++++++++----- + 2 files changed, 34 insertions(+), 6 deletions(-) + +diff --git a/include/dbus_utility.hpp b/include/dbus_utility.hpp +index bd0d64bd..05adb1e6 100644 +--- a/include/dbus_utility.hpp ++++ b/include/dbus_utility.hpp +@@ -62,6 +62,7 @@ using DbusVariantType = std::variant< + std::vector<uint16_t>, + sdbusplus::message::object_path, + std::tuple<uint64_t, std::vector<std::tuple<std::string, std::string, double, uint64_t>>>, ++ std::tuple<uint64_t, std::vector<std::tuple<std::string, double, uint64_t>>>, + std::vector<std::tuple<std::string, std::string>>, + std::vector<std::tuple<uint32_t, std::vector<uint32_t>>>, + std::vector<std::tuple<uint32_t, size_t>>, +diff --git a/redfish-core/lib/metric_report.hpp b/redfish-core/lib/metric_report.hpp +index 18830f13..b3f5721e 100644 +--- a/redfish-core/lib/metric_report.hpp ++++ b/redfish-core/lib/metric_report.hpp +@@ -20,20 +20,47 @@ constexpr const char* metricReportUri = + "/redfish/v1/TelemetryService/MetricReports"; + + using Readings = +- std::vector<std::tuple<std::string, std::string, double, uint64_t>>; ++ std::vector<std::tuple<std::string, double, uint64_t>>; + using TimestampReadings = std::tuple<uint64_t, Readings>; + ++inline std::string GetCroppedTimeStamp(uint64_t timestamp) ++{ ++ static constexpr char DOT_CHAR = '.'; ++ ++ auto timestamp_as_string = redfish::time_utils::getDateTimeUintMs(timestamp); ++ auto last_dot_position = timestamp_as_string.rfind(DOT_CHAR); ++ if(last_dot_position != std::string::npos) ++ { ++ timestamp_as_string.erase(last_dot_position); ++ } ++ return timestamp_as_string; ++} ++ ++inline std::string GetCroppedValue(double value) ++{ ++ static constexpr char DOT_CHAR = '.'; ++ static constexpr size_t COUNT_NUMBER_AFTER_DOT = 1; ++ ++ auto value_as_string = std::to_string(value); ++ auto last_dot_position = value_as_string.rfind(DOT_CHAR); ++ auto general_size = last_dot_position + COUNT_NUMBER_AFTER_DOT + sizeof(DOT_CHAR); ++ if(last_dot_position != std::string::npos && general_size <= value_as_string.length()) ++ { ++ value_as_string.erase(general_size); ++ } ++ return value_as_string; ++} ++ + inline nlohmann::json toMetricValues(const Readings& readings) + { + nlohmann::json metricValues = nlohmann::json::array_t(); + +- for (const auto& [id, metadata, sensorValue, timestamp] : readings) ++ for (const auto& [metadata, sensorValue, timestamp] : readings) + { + metricValues.push_back({ +- {"MetricId", id}, +- {"MetricProperty", metadata}, +- {"MetricValue", std::to_string(sensorValue)}, +- {"Timestamp", redfish::time_utils::getDateTimeUintMs(timestamp)}, ++ {"Sensor", metadata}, ++ {"Value", GetCroppedValue(sensorValue)}, ++ {"Timestamp", GetCroppedTimeStamp(timestamp)}, + }); + } + +@@ -56,7 +83,7 @@ inline bool fillReport(nlohmann::json& json, const std::string& id, + .string(); + + const auto& [timestamp, readings] = timestampReadings; +- json["Timestamp"] = redfish::time_utils::getDateTimeUintMs(timestamp); ++ json["Timestamp"] = GetCroppedTimeStamp(timestamp); + json["MetricValues"] = toMetricValues(readings); + return true; + } |