summaryrefslogtreecommitdiff
path: root/meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces
diff options
context:
space:
mode:
authoreportnov <eportnov@ibs.ru>2022-09-08 14:39:01 +0300
committereportnov <eportnov@ibs.ru>2022-09-09 10:44:58 +0300
commit5989c4cfc2b2b2f56043cd45e26c07ba2d441de8 (patch)
treeba99eccb8e75b481f7e2ab62016b940f4ba5dffb /meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces
parentcef91b6e025c88d947d84d2fe2b59adeb1d7cde0 (diff)
downloadopenbmc-5989c4cfc2b2b2f56043cd45e26c07ba2d441de8.tar.xz
configure telemetry
# Conflicts: # meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb_%.bbappend
Diffstat (limited to 'meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces')
-rw-r--r--meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb/0011-configure-telemetry.patch88
-rw-r--r--meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb_%.bbappend1
2 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..97bc6d6129
--- /dev/null
+++ b/meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb/0011-configure-telemetry.patch
@@ -0,0 +1,88 @@
+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)},
++ {"MetricValue", 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;
+ }
diff --git a/meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb_%.bbappend b/meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb_%.bbappend
index a6258f3f6e..e766ebdb44 100644
--- a/meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb_%.bbappend
+++ b/meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb_%.bbappend
@@ -7,6 +7,7 @@ SRC_URI += "\
file://0007-Removed-non-working-boot-override-modes.patch \
file://0008-Add-pcie-device-names.patch \
file://0010-Add-smtp-client.patch \
+ file://0011-configure-telemetry.patch \
"
#SRC_URI += "\