From 718f73da081c01b3c39a179635e4095557a70e12 Mon Sep 17 00:00:00 2001 From: eportnov Date: Thu, 8 Sep 2022 17:51:50 +0300 Subject: bugfix circular buffer --- .../0013-bugfix-telemetry-circular-buffer.patch | 43 + .../recipes-phosphor/interfaces/bmcweb_%.bbappend | 1 + .../telemetry/0001-configure-telemetry.patch | 121 ++ .../telemetry/0001-set_new_report_path.patch | 22 - .../telemetry/telemetry/0002-add-hour-data.patch | 97 ++ .../telemetry/0002-configure-telemetry.patch | 1191 -------------------- .../telemetry/0003-bugfix-circular-buffer.patch | 200 ++++ .../telemetry/0003-fix-bug-circular-buffer.patch | 191 ---- .../telemetry/0004-configure-telemetry.patch | 121 -- .../telemetry/telemetry/0005-add-hour-data.patch | 97 -- .../telemetry/telemetry_%.bbappend | 5 +- 11 files changed, 465 insertions(+), 1624 deletions(-) create mode 100644 meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb/0013-bugfix-telemetry-circular-buffer.patch create mode 100644 meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0001-configure-telemetry.patch delete mode 100644 meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0001-set_new_report_path.patch create mode 100644 meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0002-add-hour-data.patch delete mode 100644 meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0002-configure-telemetry.patch create mode 100644 meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0003-bugfix-circular-buffer.patch delete mode 100644 meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0003-fix-bug-circular-buffer.patch delete mode 100644 meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0004-configure-telemetry.patch delete mode 100644 meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0005-add-hour-data.patch (limited to 'meta-ibs/meta-cp2-5422/recipes-phosphor') diff --git a/meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb/0013-bugfix-telemetry-circular-buffer.patch b/meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb/0013-bugfix-telemetry-circular-buffer.patch new file mode 100644 index 0000000000..9f7f538dbd --- /dev/null +++ b/meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb/0013-bugfix-telemetry-circular-buffer.patch @@ -0,0 +1,43 @@ +From 38a09080bb7bb43700b2fb021cd20137e7a3acad Mon Sep 17 00:00:00 2001 +From: eportnov +Date: Thu, 8 Sep 2022 17:38:05 +0300 +Subject: [PATCH] bugfix telemetry circular buffer + +--- + include/dbus_utility.hpp | 2 ++ + redfish-core/lib/metric_report.hpp | 2 +- + 2 files changed, 3 insertions(+), 1 deletion(-) + +diff --git a/include/dbus_utility.hpp b/include/dbus_utility.hpp +index 05adb1e6..3aa694b7 100644 +--- a/include/dbus_utility.hpp ++++ b/include/dbus_utility.hpp +@@ -31,6 +31,7 @@ + #include + #include + #include ++#include + + // IWYU pragma: no_include + // IWYU pragma: no_include +@@ -63,6 +64,7 @@ using DbusVariantType = std::variant< + sdbusplus::message::object_path, + std::tuple>>, + std::tuple>>, ++ std::tuple>>, + std::vector>, + std::vector>>, + std::vector>, +diff --git a/redfish-core/lib/metric_report.hpp b/redfish-core/lib/metric_report.hpp +index 64808a9c..68500902 100644 +--- a/redfish-core/lib/metric_report.hpp ++++ b/redfish-core/lib/metric_report.hpp +@@ -34,7 +34,7 @@ constexpr const char* metricReportUri = + "/redfish/v1/TelemetryService/MetricReports"; + + using Readings = +- std::vector>; ++ std::list>; + using TimestampReadings = std::tuple; + + inline std::string GetCroppedTimeStamp(uint64_t timestamp) 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 8eb1537e64..93a031f401 100644 --- a/meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb_%.bbappend +++ b/meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb_%.bbappend @@ -4,6 +4,7 @@ SRC_URI += "\ file://0001-IBS-Default-BMC-Name-and-Model.patch \ file://0011-configure-telemetry.patch \ file://0012-add-telemetry-hour-data.patch \ + file://0013-bugfix-telemetry-circular-buffer.patch \ " #SRC_URI += "\ diff --git a/meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0001-configure-telemetry.patch b/meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0001-configure-telemetry.patch new file mode 100644 index 0000000000..91b64d6e30 --- /dev/null +++ b/meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0001-configure-telemetry.patch @@ -0,0 +1,121 @@ +From 00985aa2686a9277291b1fc744d78899a0e33807 Mon Sep 17 00:00:00 2001 +From: eportnov +Date: Thu, 8 Sep 2022 14:26:35 +0300 +Subject: [PATCH] configure telemetry + +--- + meson_options.txt | 4 ++-- + src/metric.cpp | 2 +- + src/metric_value.hpp | 1 - + src/report.cpp | 6 +++--- + src/types/readings.hpp | 4 ++-- + src/utils/dbus_path_utils.hpp | 2 +- + 6 files changed, 9 insertions(+), 10 deletions(-) + +diff --git a/meson_options.txt b/meson_options.txt +index c8a46b8..0a50b7d 100644 +--- a/meson_options.txt ++++ b/meson_options.txt +@@ -1,5 +1,5 @@ + option('buildtest', type: 'boolean', value: true, description: 'Build tests') +-option('max-reports', type: 'integer', min: 0, value: 10, ++option('max-reports', type: 'integer', min: 0, value: 20, + description: 'Max number of Reports') + option('max-reading-parameters', type: 'integer', min: 0, value: 200, + description: 'Max number of metric properties in single report') +@@ -9,7 +9,7 @@ option('max-triggers', type: 'integer', min: 0, value: 10, + description: 'Max number of Triggers') + option('max-dbus-path-length', type: 'integer', min: 256, value: 4095, + description: 'Max length of dbus object path') +-option('max-append-limit', type: 'integer', min: 0, value: 256, ++option('max-append-limit', type: 'integer', min: 0, value: 2147483647, + description: 'Max AppendLimit value') + option('max-id-name-length', type: 'integer', min: 32, value: 256, + description: 'Max length of any "id" or "name" type field.') +diff --git a/src/metric.cpp b/src/metric.cpp +index d6b62d8..48fb7a7 100644 +--- a/src/metric.cpp ++++ b/src/metric.cpp +@@ -81,7 +81,7 @@ const std::vector& Metric::getUpdatedReadings() + i = idx; + } + +- readings.emplace_back(id, sensors[i]->metadata(), *value, ++ readings.emplace_back(sensors[i]->metadata(), *value, + systemTimestamp); + } + } +diff --git a/src/metric_value.hpp b/src/metric_value.hpp +index d01ac4e..9dfc6ac 100644 +--- a/src/metric_value.hpp ++++ b/src/metric_value.hpp +@@ -5,7 +5,6 @@ + + struct MetricValue + { +- std::string id; + std::string metadata; + double value; + uint64_t timestamp; +diff --git a/src/report.cpp b/src/report.cpp +index 9ee60a4..624bdbc 100644 +--- a/src/report.cpp ++++ b/src/report.cpp +@@ -461,7 +461,7 @@ void Report::scheduleTimerForPeriodicReport(Milliseconds timerInterval) + + void Report::scheduleTimerForOnChangeReport() + { +- constexpr Milliseconds timerInterval{100}; ++ constexpr Milliseconds timerInterval{10000}; + + timer.expires_after(timerInterval); + timer.async_wait([this](boost::system::error_code ec) { +@@ -489,7 +489,7 @@ void Report::updateReadings() + break; + } + +- for (const auto& [id, metadata, value, timestamp] : ++ for (const auto& [metadata, value, timestamp] : + metric->getUpdatedReadings()) + { + if (reportUpdates == ReportUpdates::appendStopsWhenFull && +@@ -499,7 +499,7 @@ void Report::updateReadings() + reportIface->signal_property("Enabled"); + break; + } +- readingsBuffer.emplace(id, metadata, value, timestamp); ++ readingsBuffer.emplace(metadata, value, timestamp); + } + } + +diff --git a/src/types/readings.hpp b/src/types/readings.hpp +index 6749bbf..74566eb 100644 +--- a/src/types/readings.hpp ++++ b/src/types/readings.hpp +@@ -3,11 +3,11 @@ + #include "utils/labeled_tuple.hpp" + #include "utils/tstring.hpp" + +-using ReadingData = std::tuple; ++using ReadingData = std::tuple; + using Readings = std::tuple>; + + using LabeledReadingData = +- utils::LabeledTuple; + +diff --git a/src/utils/dbus_path_utils.hpp b/src/utils/dbus_path_utils.hpp +index 3798d98..d0e1d24 100644 +--- a/src/utils/dbus_path_utils.hpp ++++ b/src/utils/dbus_path_utils.hpp +@@ -14,7 +14,7 @@ namespace constants + constexpr std::string_view triggerDirStr = + "/xyz/openbmc_project/Telemetry/Triggers/"; + constexpr std::string_view reportDirStr = +- "/xyz/openbmc_project/Telemetry/Reports/"; ++ "/xyz/openbmc_project/Telemetry/Reports/TelemetryService"; + + constexpr std::string_view allowedCharactersInPath = + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_/"; diff --git a/meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0001-set_new_report_path.patch b/meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0001-set_new_report_path.patch deleted file mode 100644 index b59438bd28..0000000000 --- a/meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0001-set_new_report_path.patch +++ /dev/null @@ -1,22 +0,0 @@ -From 71ad04dd8ce0a31fe260626215d30bf0e58b255c Mon Sep 17 00:00:00 2001 -From: eportnov -Date: Fri, 15 Jul 2022 17:38:30 +0300 -Subject: [PATCH] set_new_report_path - ---- - src/report.hpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/report.hpp b/src/report.hpp -index 6d8c6b4..8d71bc9 100644 ---- a/src/report.hpp -+++ b/src/report.hpp -@@ -137,7 +137,7 @@ class Report : public interfaces::Report, public interfaces::MetricListener - static constexpr const char* reportIfaceName = - "xyz.openbmc_project.Telemetry.Report"; - static constexpr const char* reportDir = -- "/xyz/openbmc_project/Telemetry/Reports/"; -+ "/xyz/openbmc_project/Telemetry/Reports/TelemetryService/"; - static constexpr const char* deleteIfaceName = - "xyz.openbmc_project.Object.Delete"; - static constexpr size_t reportVersion = 6; diff --git a/meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0002-add-hour-data.patch b/meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0002-add-hour-data.patch new file mode 100644 index 0000000000..3a795b1838 --- /dev/null +++ b/meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0002-add-hour-data.patch @@ -0,0 +1,97 @@ +From 34ff94d5b3c8fae4050c96aaabc2975d158c85cf Mon Sep 17 00:00:00 2001 +From: eportnov +Date: Thu, 8 Sep 2022 15:23:11 +0300 +Subject: [PATCH] add hour data + +--- + src/report.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++++++---- + src/report.hpp | 2 ++ + 2 files changed, 49 insertions(+), 4 deletions(-) + +diff --git a/src/report.cpp b/src/report.cpp +index 624bdbc..06985a5 100644 +--- a/src/report.cpp ++++ b/src/report.cpp +@@ -296,10 +296,6 @@ std::unique_ptr + return 1; + }, + [this](const auto&) { return persistency; }); +- +- dbusIface->register_property_r("Readings", readings, +- sdbusplus::vtable::property_::emits_change, +- [this](const auto&) { return readings; }); + dbusIface->register_property_rw( + "ReportingType", sdbusplus::vtable::property_::emits_change, + [this](auto newVal, auto& oldVal) { +@@ -411,11 +407,58 @@ std::unique_ptr + updateReadings(); + } + }); ++ dbusIface->register_method("GetReadings", [this](bool is_need_last_hour) { ++ if(is_need_last_hour) ++ { ++ return getHourReadings(); ++ } ++ return readings; ++ }); + constexpr bool skipPropertiesChangedSignal = true; + dbusIface->initialize(skipPropertiesChangedSignal); + return dbusIface; + } + ++ Readings Report::getHourReadings() ++ { ++ static constexpr int ZERO_POSITION = 0; ++ ++ Readings result; ++ std::get<0>(result) = std::get<0>(readings); ++ auto& result_read = std::get<1>(result);; ++ ++ auto& read = std::get<1>(readings); ++ auto hour_pos = GetPositionOnLastHour(read); ++ ++ if(hour_pos == ZERO_POSITION) ++ { ++ return readings; ++ } ++ std::copy(read.begin() + hour_pos, read.end(), std::back_inserter(result_read)); ++ ++ return result; ++ } ++ ++ int Report::GetPositionOnLastHour(const std::vector& readings) ++ { ++ static constexpr uint32_t SECONDS_IN_HOUR = 60*60; ++ static constexpr int DEFAULT_RESULT = 0; ++ ++ uint64_t time_past_hour = std::chrono::duration_cast( ++ std::chrono::system_clock::now().time_since_epoch()).count() - SECONDS_IN_HOUR; ++ ++ ++ for(auto it = readings.rbegin(); it !=readings.rend(); ++it) ++ { ++ auto reading_time = std::get<2>(*it); ++ if(reading_time < time_past_hour) ++ { ++ return abs(readings.rend() - it); ++ } ++ } ++ return DEFAULT_RESULT; ++ } ++ + void Report::timerProcForPeriodicReport(boost::system::error_code ec, + Report& self) + { +diff --git a/src/report.hpp b/src/report.hpp +index 74c979b..b55b01b 100644 +--- a/src/report.hpp ++++ b/src/report.hpp +@@ -112,6 +112,8 @@ class Report : public interfaces::Report, public interfaces::MetricListener + void updateReadings(); + void scheduleTimer(); + std::vector verify() const; ++ Readings getHourReadings(); ++ int GetPositionOnLastHour(const std::vector& readings); + + std::string id; + const sdbusplus::message::object_path path; diff --git a/meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0002-configure-telemetry.patch b/meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0002-configure-telemetry.patch deleted file mode 100644 index e59e6a5c1d..0000000000 --- a/meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0002-configure-telemetry.patch +++ /dev/null @@ -1,1191 +0,0 @@ -From 749825187d79077161f63086141f8a7f25c7655b Mon Sep 17 00:00:00 2001 -From: eportnov -Date: Fri, 5 Aug 2022 16:14:04 +0300 -Subject: [PATCH] configure telemetry - ---- - meson_options.txt | 2 +- - src/discrete_threshold.cpp | 10 ++--- - src/discrete_threshold.hpp | 10 ++--- - src/interfaces/clock.hpp | 4 +- - src/interfaces/metric.hpp | 2 +- - src/interfaces/report_factory.hpp | 2 +- - src/interfaces/sensor_listener.hpp | 2 +- - src/interfaces/trigger_action.hpp | 2 +- - src/metric.cpp | 8 ++-- - src/metric.hpp | 4 +- - src/metric_value.hpp | 3 +- - src/metrics/collection_data.cpp | 14 +++---- - src/metrics/collection_data.hpp | 4 +- - src/metrics/collection_function.cpp | 22 +++++----- - src/metrics/collection_function.hpp | 6 +-- - src/numeric_threshold.cpp | 10 ++--- - src/numeric_threshold.hpp | 10 ++--- - src/on_change_threshold.cpp | 4 +- - src/on_change_threshold.hpp | 4 +- - src/report.cpp | 64 ++++++++++++++++++++++++----- - src/report.hpp | 8 ++-- - src/report_factory.cpp | 4 +- - src/report_factory.hpp | 2 +- - src/report_manager.cpp | 12 +++--- - src/report_manager.hpp | 11 ++--- - src/sensor.hpp | 4 +- - src/trigger_actions.cpp | 16 ++++---- - src/trigger_actions.hpp | 14 +++---- - src/trigger_factory.cpp | 6 +-- - src/types/collection_duration.hpp | 4 +- - src/types/duration_types.hpp | 3 +- - src/types/readings.hpp | 8 ++-- - src/utils/clock.hpp | 8 ++-- - 33 files changed, 166 insertions(+), 121 deletions(-) - -diff --git a/meson_options.txt b/meson_options.txt -index 23ec2aa..d17bb1a 100644 ---- a/meson_options.txt -+++ b/meson_options.txt -@@ -3,7 +3,7 @@ option('max-reports', type: 'integer', min: 1, value: 10, - description: 'Max number of Reports') - option('max-reading-parameters', type: 'integer', min: 1, value: 200, - description: 'Max number of metric properties in single report') --option('min-interval', type: 'integer', min: 1, value: 1000, -+option('min-interval', type: 'integer', min: 1, value: 10, - description: 'Minimal value of interval in milliseconds') - option('max-triggers', type: 'integer', min: 1, value: 10, - description: 'Max number of Triggers') -diff --git a/src/discrete_threshold.cpp b/src/discrete_threshold.cpp -index 1bb250f..e9c73d1 100644 ---- a/src/discrete_threshold.cpp -+++ b/src/discrete_threshold.cpp -@@ -7,7 +7,7 @@ - DiscreteThreshold::DiscreteThreshold( - boost::asio::io_context& ioc, Sensors sensorsIn, - std::vector> actionsIn, -- Milliseconds dwellTimeIn, const std::string& thresholdValueIn, -+ Seconds dwellTimeIn, const std::string& thresholdValueIn, - const std::string& nameIn, const discrete::Severity severityIn) : - ioc(ioc), - actions(std::move(actionsIn)), dwellTime(dwellTimeIn), -@@ -44,7 +44,7 @@ std::shared_ptr - } - - void DiscreteThreshold::sensorUpdated(interfaces::Sensor& sensor, -- Milliseconds timestamp, double value) -+ Seconds timestamp, double value) - { - auto& details = getDetails(sensor); - auto& [sensorName, dwell, timer] = details; -@@ -61,13 +61,13 @@ void DiscreteThreshold::sensorUpdated(interfaces::Sensor& sensor, - } - - void DiscreteThreshold::startTimer(DiscreteThreshold::ThresholdDetail& details, -- Milliseconds timestamp, double value) -+ Seconds timestamp, double value) - { - const auto& sensorName = details.sensorName; - auto& dwell = details.dwell; - auto& timer = details.timer; - -- if (dwellTime == Milliseconds::zero()) -+ if (dwellTime == Seconds::zero()) - { - commit(sensorName, timestamp, value); - } -@@ -90,7 +90,7 @@ void DiscreteThreshold::startTimer(DiscreteThreshold::ThresholdDetail& details, - } - - void DiscreteThreshold::commit(const std::string& sensorName, -- Milliseconds timestamp, double value) -+ Seconds timestamp, double value) - { - for (const auto& action : actions) - { -diff --git a/src/discrete_threshold.hpp b/src/discrete_threshold.hpp -index 545a980..9f049b5 100644 ---- a/src/discrete_threshold.hpp -+++ b/src/discrete_threshold.hpp -@@ -24,20 +24,20 @@ class DiscreteThreshold : - DiscreteThreshold( - boost::asio::io_context& ioc, Sensors sensors, - std::vector> actions, -- Milliseconds dwellTime, const std::string& thresholdValue, -+ Seconds dwellTime, const std::string& thresholdValue, - const std::string& name, const discrete::Severity severity); - DiscreteThreshold(const DiscreteThreshold&) = delete; - DiscreteThreshold(DiscreteThreshold&&) = delete; - - void initialize() override; -- void sensorUpdated(interfaces::Sensor&, Milliseconds, double) override; -+ void sensorUpdated(interfaces::Sensor&, Seconds, double) override; - LabeledThresholdParam getThresholdParam() const override; - void updateSensors(Sensors newSensors) override; - - private: - boost::asio::io_context& ioc; - const std::vector> actions; -- const Milliseconds dwellTime; -+ const Seconds dwellTime; - const std::string thresholdValue; - const double numericThresholdValue; - const std::string name; -@@ -63,8 +63,8 @@ class DiscreteThreshold : - - friend ThresholdOperations; - -- void startTimer(ThresholdDetail&, Milliseconds, double); -- void commit(const std::string&, Milliseconds, double); -+ void startTimer(ThresholdDetail&, Seconds, double); -+ void commit(const std::string&, Seconds, double); - ThresholdDetail& getDetails(const interfaces::Sensor& sensor); - std::shared_ptr makeDetails(const std::string& sensorName); - }; -diff --git a/src/interfaces/clock.hpp b/src/interfaces/clock.hpp -index b37ff3a..bb06569 100644 ---- a/src/interfaces/clock.hpp -+++ b/src/interfaces/clock.hpp -@@ -12,8 +12,8 @@ class Clock - public: - virtual ~Clock() = default; - -- virtual Milliseconds steadyTimestamp() const noexcept = 0; -- virtual Milliseconds systemTimestamp() const noexcept = 0; -+ virtual Seconds steadyTimestamp() const noexcept = 0; -+ virtual Seconds systemTimestamp() const noexcept = 0; - }; - - } // namespace interfaces -diff --git a/src/interfaces/metric.hpp b/src/interfaces/metric.hpp -index c52dd45..2a5f999 100644 ---- a/src/interfaces/metric.hpp -+++ b/src/interfaces/metric.hpp -@@ -25,7 +25,7 @@ class Metric - virtual void registerForUpdates(interfaces::MetricListener& listener) = 0; - virtual void - unregisterFromUpdates(interfaces::MetricListener& listener) = 0; -- virtual void updateReadings(Milliseconds) = 0; -+ virtual void updateReadings(Seconds) = 0; - virtual bool isTimerRequired() const = 0; - }; - -diff --git a/src/interfaces/report_factory.hpp b/src/interfaces/report_factory.hpp -index d8e076a..d58a15e 100644 ---- a/src/interfaces/report_factory.hpp -+++ b/src/interfaces/report_factory.hpp -@@ -39,7 +39,7 @@ class ReportFactory - make(const std::string& id, const std::string& name, - const ReportingType reportingType, - const std::vector& reportActions, -- Milliseconds period, uint64_t appendLimit, -+ Seconds period, uint64_t appendLimit, - const ReportUpdates reportUpdates, ReportManager& reportManager, - JsonStorage& reportStorage, - std::vector labeledMetricParams, -diff --git a/src/interfaces/sensor_listener.hpp b/src/interfaces/sensor_listener.hpp -index 3f35c38..ed7b904 100644 ---- a/src/interfaces/sensor_listener.hpp -+++ b/src/interfaces/sensor_listener.hpp -@@ -15,7 +15,7 @@ class SensorListener - public: - virtual ~SensorListener() = default; - -- virtual void sensorUpdated(interfaces::Sensor&, Milliseconds, double) = 0; -+ virtual void sensorUpdated(interfaces::Sensor&, Seconds, double) = 0; - }; - - } // namespace interfaces -diff --git a/src/interfaces/trigger_action.hpp b/src/interfaces/trigger_action.hpp -index 437a79f..f7cdb92 100644 ---- a/src/interfaces/trigger_action.hpp -+++ b/src/interfaces/trigger_action.hpp -@@ -13,7 +13,7 @@ class TriggerAction - public: - virtual ~TriggerAction() = default; - -- virtual void commit(const std::string& id, Milliseconds timestamp, -+ virtual void commit(const std::string& id, Seconds timestamp, - double value) = 0; - }; - } // namespace interfaces -diff --git a/src/metric.cpp b/src/metric.cpp -index d6b62d8..b58f0c7 100644 ---- a/src/metric.cpp -+++ b/src/metric.cpp -@@ -58,7 +58,7 @@ const std::vector& Metric::getUpdatedReadings() - { - const auto steadyTimestamp = clock->steadyTimestamp(); - const auto systemTimestamp = -- std::chrono::duration_cast(clock->systemTimestamp()) -+ std::chrono::duration_cast(clock->systemTimestamp()) - .count(); - - for (size_t i = 0; i < collectionAlgorithms.size(); ++i) -@@ -81,7 +81,7 @@ const std::vector& Metric::getUpdatedReadings() - i = idx; - } - -- readings.emplace_back(id, sensors[i]->metadata(), *value, -+ readings.emplace_back(sensors[i]->metadata(), *value, - systemTimestamp); - } - } -@@ -90,7 +90,7 @@ const std::vector& Metric::getUpdatedReadings() - return readings; - } - --void Metric::sensorUpdated(interfaces::Sensor& notifier, Milliseconds timestamp, -+void Metric::sensorUpdated(interfaces::Sensor& notifier, Seconds timestamp, - double value) - { - auto& data = findAssociatedData(notifier); -@@ -131,7 +131,7 @@ uint64_t Metric::sensorCount() const - return sensors.size(); - } - --void Metric::updateReadings(Milliseconds timestamp) -+void Metric::updateReadings(Seconds timestamp) - { - for (auto& data : collectionAlgorithms) - { -diff --git a/src/metric.hpp b/src/metric.hpp -index 8b367b3..197f9c5 100644 ---- a/src/metric.hpp -+++ b/src/metric.hpp -@@ -21,13 +21,13 @@ class Metric : - void initialize() override; - void deinitialize() override; - const std::vector& getUpdatedReadings() override; -- void sensorUpdated(interfaces::Sensor&, Milliseconds, -+ void sensorUpdated(interfaces::Sensor&, Seconds, - double value) override; - LabeledMetricParameters dumpConfiguration() const override; - uint64_t sensorCount() const override; - void registerForUpdates(interfaces::MetricListener& listener) override; - void unregisterFromUpdates(interfaces::MetricListener& listener) override; -- void updateReadings(Milliseconds) override; -+ void updateReadings(Seconds) override; - bool isTimerRequired() const override; - - private: -diff --git a/src/metric_value.hpp b/src/metric_value.hpp -index d01ac4e..4073112 100644 ---- a/src/metric_value.hpp -+++ b/src/metric_value.hpp -@@ -5,8 +5,7 @@ - - struct MetricValue - { -- std::string id; - std::string metadata; - double value; -- uint64_t timestamp; -+ uint32_t timestamp; - }; -diff --git a/src/metrics/collection_data.cpp b/src/metrics/collection_data.cpp -index 9512252..445da08 100644 ---- a/src/metrics/collection_data.cpp -+++ b/src/metrics/collection_data.cpp -@@ -15,12 +15,12 @@ bool CollectionData::updateLastValue(double value) - class DataPoint : public CollectionData - { - public: -- std::optional update(Milliseconds) override -+ std::optional update(Seconds) override - { - return lastReading; - } - -- double update(Milliseconds, double reading) override -+ double update(Seconds, double reading) override - { - lastReading = reading; - return reading; -@@ -46,7 +46,7 @@ class DataInterval : public CollectionData - } - } - -- std::optional update(Milliseconds timestamp) override -+ std::optional update(Seconds timestamp) override - { - if (readings.empty()) - { -@@ -58,7 +58,7 @@ class DataInterval : public CollectionData - return function->calculate(readings, timestamp); - } - -- double update(Milliseconds timestamp, double reading) override -+ double update(Seconds timestamp, double reading) override - { - readings.emplace_back(timestamp, reading); - -@@ -68,7 +68,7 @@ class DataInterval : public CollectionData - } - - private: -- void cleanup(Milliseconds timestamp) -+ void cleanup(Seconds timestamp) - { - auto it = readings.begin(); - for (auto kt = std::next(readings.rbegin()); kt != readings.rend(); -@@ -103,7 +103,7 @@ class DataStartup : public CollectionData - function(std::move(function)) - {} - -- std::optional update(Milliseconds timestamp) override -+ std::optional update(Seconds timestamp) override - { - if (readings.empty()) - { -@@ -113,7 +113,7 @@ class DataStartup : public CollectionData - return function->calculateForStartupInterval(readings, timestamp); - } - -- double update(Milliseconds timestamp, double reading) override -+ double update(Seconds timestamp, double reading) override - { - readings.emplace_back(timestamp, reading); - return function->calculateForStartupInterval(readings, timestamp); -diff --git a/src/metrics/collection_data.hpp b/src/metrics/collection_data.hpp -index 251e704..1f14d76 100644 ---- a/src/metrics/collection_data.hpp -+++ b/src/metrics/collection_data.hpp -@@ -17,8 +17,8 @@ class CollectionData - public: - virtual ~CollectionData() = default; - -- virtual std::optional update(Milliseconds timestamp) = 0; -- virtual double update(Milliseconds timestamp, double value) = 0; -+ virtual std::optional update(Seconds timestamp) = 0; -+ virtual double update(Seconds timestamp, double value) = 0; - bool updateLastValue(double value); - - private: -diff --git a/src/metrics/collection_function.cpp b/src/metrics/collection_function.cpp -index 717bb68..6b21749 100644 ---- a/src/metrics/collection_function.cpp -+++ b/src/metrics/collection_function.cpp -@@ -9,7 +9,7 @@ class FunctionMinimum : public CollectionFunction - { - public: - double calculate(const std::vector& readings, -- Milliseconds) const override -+ Seconds) const override - { - return std::min_element( - readings.begin(), readings.end(), -@@ -23,7 +23,7 @@ class FunctionMinimum : public CollectionFunction - } - - double calculateForStartupInterval(std::vector& readings, -- Milliseconds timestamp) const override -+ Seconds timestamp) const override - { - readings.assign( - {ReadingItem(timestamp, calculate(readings, timestamp))}); -@@ -35,7 +35,7 @@ class FunctionMaximum : public CollectionFunction - { - public: - double calculate(const std::vector& readings, -- Milliseconds) const override -+ Seconds) const override - { - return std::max_element( - readings.begin(), readings.end(), -@@ -49,7 +49,7 @@ class FunctionMaximum : public CollectionFunction - } - - double calculateForStartupInterval(std::vector& readings, -- Milliseconds timestamp) const override -+ Seconds timestamp) const override - { - readings.assign( - {ReadingItem(timestamp, calculate(readings, timestamp))}); -@@ -61,10 +61,10 @@ class FunctionAverage : public CollectionFunction - { - public: - double calculate(const std::vector& readings, -- Milliseconds timestamp) const override -+ Seconds timestamp) const override - { - auto valueSum = 0.0; -- auto timeSum = Milliseconds{0}; -+ auto timeSum = Seconds{0}; - for (auto it = readings.begin(); it != std::prev(readings.end()); ++it) - { - if (std::isfinite(it->second)) -@@ -80,11 +80,11 @@ class FunctionAverage : public CollectionFunction - valueSum += readings.back().second * duration.count(); - timeSum += duration; - -- return valueSum / std::max(timeSum.count(), uint64_t{1u}); -+ return valueSum / std::max(timeSum.count(), uint32_t{1u}); - } - - double calculateForStartupInterval(std::vector& readings, -- Milliseconds timestamp) const override -+ Seconds timestamp) const override - { - auto result = calculate(readings, timestamp); - if (std::isfinite(result)) -@@ -102,7 +102,7 @@ class FunctionSummation : public CollectionFunction - - public: - double calculate(const std::vector& readings, -- const Milliseconds timestamp) const override -+ const Seconds timestamp) const override - { - auto valueSum = 0.0; - for (auto it = readings.begin(); it != std::prev(readings.end()); ++it) -@@ -125,7 +125,7 @@ class FunctionSummation : public CollectionFunction - - double - calculateForStartupInterval(std::vector& readings, -- const Milliseconds timestamp) const override -+ const Seconds timestamp) const override - { - const auto result = calculate(readings, timestamp); - if (readings.size() > 2 && std::isfinite(result)) -@@ -144,7 +144,7 @@ class FunctionSummation : public CollectionFunction - } - - private: -- static constexpr Multiplier calculateMultiplier(Milliseconds duration) -+ static constexpr Multiplier calculateMultiplier(Seconds duration) - { - constexpr auto m = Multiplier{Seconds{1}}; - return Multiplier{duration / m}; -diff --git a/src/metrics/collection_function.hpp b/src/metrics/collection_function.hpp -index 610f015..58ff5d0 100644 ---- a/src/metrics/collection_function.hpp -+++ b/src/metrics/collection_function.hpp -@@ -11,7 +11,7 @@ - namespace metrics - { - --using ReadingItem = std::pair; -+using ReadingItem = std::pair; - - class CollectionFunction - { -@@ -19,10 +19,10 @@ class CollectionFunction - virtual ~CollectionFunction() = default; - - virtual double calculate(const std::vector& readings, -- Milliseconds timestamp) const = 0; -+ Seconds timestamp) const = 0; - virtual double - calculateForStartupInterval(std::vector& readings, -- Milliseconds timestamp) const = 0; -+ Seconds timestamp) const = 0; - }; - - std::shared_ptr makeCollectionFunction(OperationType); -diff --git a/src/numeric_threshold.cpp b/src/numeric_threshold.cpp -index cb6dbdd..4c71cfb 100644 ---- a/src/numeric_threshold.cpp -+++ b/src/numeric_threshold.cpp -@@ -5,7 +5,7 @@ - NumericThreshold::NumericThreshold( - boost::asio::io_context& ioc, Sensors sensorsIn, - std::vector> actionsIn, -- Milliseconds dwellTimeIn, numeric::Direction directionIn, -+ Seconds dwellTimeIn, numeric::Direction directionIn, - double thresholdValueIn, numeric::Type typeIn) : - ioc(ioc), - actions(std::move(actionsIn)), dwellTime(dwellTimeIn), -@@ -41,7 +41,7 @@ std::shared_ptr - } - - void NumericThreshold::sensorUpdated(interfaces::Sensor& sensor, -- Milliseconds timestamp, double value) -+ Seconds timestamp, double value) - { - auto& details = getDetails(sensor); - auto& [sensorName, prevValue, dwell, timer] = details; -@@ -64,13 +64,13 @@ void NumericThreshold::sensorUpdated(interfaces::Sensor& sensor, - } - - void NumericThreshold::startTimer(NumericThreshold::ThresholdDetail& details, -- Milliseconds timestamp, double value) -+ Seconds timestamp, double value) - { - const auto& sensorName = details.sensorName; - auto& dwell = details.dwell; - auto& timer = details.timer; - -- if (dwellTime == Milliseconds::zero()) -+ if (dwellTime == Seconds::zero()) - { - commit(sensorName, timestamp, value); - } -@@ -93,7 +93,7 @@ void NumericThreshold::startTimer(NumericThreshold::ThresholdDetail& details, - } - - void NumericThreshold::commit(const std::string& sensorName, -- Milliseconds timestamp, double value) -+ Seconds timestamp, double value) - { - for (const auto& action : actions) - { -diff --git a/src/numeric_threshold.hpp b/src/numeric_threshold.hpp -index ecf3d6a..8f55af8 100644 ---- a/src/numeric_threshold.hpp -+++ b/src/numeric_threshold.hpp -@@ -24,20 +24,20 @@ class NumericThreshold : - NumericThreshold( - boost::asio::io_context& ioc, Sensors sensors, - std::vector> actions, -- Milliseconds dwellTime, numeric::Direction direction, -+ Seconds dwellTime, numeric::Direction direction, - double thresholdValue, numeric::Type type); - ~NumericThreshold() - {} - - void initialize() override; -- void sensorUpdated(interfaces::Sensor&, Milliseconds, double) override; -+ void sensorUpdated(interfaces::Sensor&, Seconds, double) override; - LabeledThresholdParam getThresholdParam() const override; - void updateSensors(Sensors newSensors) override; - - private: - boost::asio::io_context& ioc; - const std::vector> actions; -- const Milliseconds dwellTime; -+ const Seconds dwellTime; - const numeric::Direction direction; - const double thresholdValue; - const numeric::Type type; -@@ -63,8 +63,8 @@ class NumericThreshold : - - friend ThresholdOperations; - -- void startTimer(ThresholdDetail&, Milliseconds, double); -- void commit(const std::string&, Milliseconds, double); -+ void startTimer(ThresholdDetail&, Seconds, double); -+ void commit(const std::string&, Seconds, double); - ThresholdDetail& getDetails(const interfaces::Sensor& sensor); - std::shared_ptr makeDetails(const std::string& sensorName); - }; -diff --git a/src/on_change_threshold.cpp b/src/on_change_threshold.cpp -index eea8978..b0338e0 100644 ---- a/src/on_change_threshold.cpp -+++ b/src/on_change_threshold.cpp -@@ -51,7 +51,7 @@ void OnChangeThreshold::updateSensors(Sensors newSensors) - } - - void OnChangeThreshold::sensorUpdated(interfaces::Sensor& sensor, -- Milliseconds timestamp, double value) -+ Seconds timestamp, double value) - { - if (isFirstReading) - { -@@ -63,7 +63,7 @@ void OnChangeThreshold::sensorUpdated(interfaces::Sensor& sensor, - } - - void OnChangeThreshold::commit(const std::string& sensorName, -- Milliseconds timestamp, double value) -+ Seconds timestamp, double value) - { - for (const auto& action : actions) - { -diff --git a/src/on_change_threshold.hpp b/src/on_change_threshold.hpp -index 1d4a4d0..fb60896 100644 ---- a/src/on_change_threshold.hpp -+++ b/src/on_change_threshold.hpp -@@ -25,7 +25,7 @@ class OnChangeThreshold : - {} - - void initialize() override; -- void sensorUpdated(interfaces::Sensor&, Milliseconds, double) override; -+ void sensorUpdated(interfaces::Sensor&, Seconds, double) override; - LabeledThresholdParam getThresholdParam() const override; - void updateSensors(Sensors newSensors) override; - -@@ -35,5 +35,5 @@ class OnChangeThreshold : - bool initialized = false; - bool isFirstReading = true; - -- void commit(const std::string&, Milliseconds, double); -+ void commit(const std::string&, Seconds, double); - }; -diff --git a/src/report.cpp b/src/report.cpp -index 540418a..a53f287 100644 ---- a/src/report.cpp -+++ b/src/report.cpp -@@ -21,7 +21,7 @@ Report::Report(boost::asio::io_context& ioc, - const std::string& reportId, const std::string& reportName, - const ReportingType reportingTypeIn, - std::vector reportActionsIn, -- const Milliseconds intervalIn, const uint64_t appendLimitIn, -+ const Seconds intervalIn, const uint64_t appendLimitIn, - const ReportUpdates reportUpdatesIn, - interfaces::ReportManager& reportManager, - interfaces::JsonStorage& reportStorageIn, -@@ -234,7 +234,7 @@ std::unique_ptr - "Interval", interval.count(), - sdbusplus::vtable::property_::emits_change, - [this](uint64_t newVal, auto&) { -- if (Milliseconds newValT{newVal}; -+ if (Seconds newValT{newVal}; - newValT >= ReportManager::minInterval) - { - if (newValT != interval) -@@ -269,9 +269,6 @@ std::unique_ptr - }, - [this](const auto&) { return persistency; }); - -- dbusIface->register_property_r("Readings", readings, -- sdbusplus::vtable::property_::emits_change, -- [this](const auto&) { return readings; }); - dbusIface->register_property_rw( - "ReportingType", std::string(), - sdbusplus::vtable::property_::emits_change, -@@ -378,11 +375,58 @@ std::unique_ptr - updateReadings(); - } - }); -+ dbusIface->register_method("GetReadings", [this](bool is_need_last_hour) { -+ if(is_need_last_hour) -+ { -+ return getHourReadings(); -+ } -+ return readings; -+ }); - constexpr bool skipPropertiesChangedSignal = true; - dbusIface->initialize(skipPropertiesChangedSignal); - return dbusIface; - } - -+Readings Report::getHourReadings() -+{ -+ static constexpr int ZERO_POSITION = 0; -+ -+ Readings result; -+ std::get<0>(result) = std::get<0>(readings); -+ auto& result_read = std::get<1>(result);; -+ -+ auto& read = std::get<1>(readings); -+ auto hour_pos = GetPositionOnLastHour(read); -+ -+ if(hour_pos == ZERO_POSITION) -+ { -+ return readings; -+ } -+ std::copy(read.begin() + hour_pos, read.end(), std::back_inserter(result_read)); -+ -+ return result; -+} -+ -+int Report::GetPositionOnLastHour(const std::vector& readings) -+{ -+ static constexpr uint32_t SECONDS_IN_HOUR = 60*60; -+ static constexpr int DEFAULT_RESULT = 0; -+ -+ uint64_t time_past_hour = std::chrono::duration_cast( -+ std::chrono::system_clock::now().time_since_epoch()).count() - SECONDS_IN_HOUR; -+ -+ -+ for(auto it = readings.rbegin(); it !=readings.rend(); ++it) -+ { -+ auto reading_time = std::get<2>(*it); -+ if(reading_time < time_past_hour) -+ { -+ return abs(readings.rend() - it); -+ } -+ } -+ return DEFAULT_RESULT; -+} -+ - void Report::timerProcForPeriodicReport(boost::system::error_code ec, - Report& self) - { -@@ -418,7 +462,7 @@ void Report::timerProcForOnChangeReport(boost::system::error_code ec, - self.scheduleTimerForOnChangeReport(); - } - --void Report::scheduleTimerForPeriodicReport(Milliseconds timerInterval) -+void Report::scheduleTimerForPeriodicReport(Seconds timerInterval) - { - if (!enabled) - { -@@ -438,7 +482,7 @@ void Report::scheduleTimerForOnChangeReport() - return; - } - -- constexpr Milliseconds timerInterval{100}; -+ constexpr Seconds timerInterval{10}; - - timer.expires_after(timerInterval); - timer.async_wait([this](boost::system::error_code ec) { -@@ -461,7 +505,7 @@ void Report::updateReadings() - - for (const auto& metric : metrics) - { -- for (const auto& [id, metadata, value, timestamp] : -+ for (const auto& [metadata, value, timestamp] : - metric->getUpdatedReadings()) - { - if (reportUpdates == ReportUpdates::appendStopsWhenFull && -@@ -474,12 +518,12 @@ void Report::updateReadings() - } - break; - } -- readingsBuffer.emplace(id, metadata, value, timestamp); -+ readingsBuffer.emplace(metadata, value, timestamp); - } - } - - std::get<0>(readings) = -- std::chrono::duration_cast(clock->systemTimestamp()) -+ std::chrono::duration_cast(clock->systemTimestamp()) - .count(); - - if (utils::contains(reportActions, ReportAction::emitsReadingsUpdate)) -diff --git a/src/report.hpp b/src/report.hpp -index 8d71bc9..5353ce5 100644 ---- a/src/report.hpp -+++ b/src/report.hpp -@@ -55,7 +55,7 @@ class Report : public interfaces::Report, public interfaces::MetricListener - const std::shared_ptr& objServer, - const std::string& reportId, const std::string& reportName, - const ReportingType reportingType, -- std::vector reportActions, const Milliseconds period, -+ std::vector reportActions, const Seconds period, - const uint64_t appendLimitIn, const ReportUpdates reportUpdatesIn, - interfaces::ReportManager& reportManager, - interfaces::JsonStorage& reportStorage, -@@ -88,7 +88,7 @@ class Report : public interfaces::Report, public interfaces::MetricListener - Report& self); - static void timerProcForOnChangeReport(boost::system::error_code, - Report& self); -- void scheduleTimerForPeriodicReport(Milliseconds interval); -+ void scheduleTimerForPeriodicReport(Seconds interval); - void scheduleTimerForOnChangeReport(); - std::optional - deduceAppendLimit(const uint64_t appendLimitIn) const; -@@ -105,11 +105,13 @@ class Report : public interfaces::Report, public interfaces::MetricListener - bool shouldStoreMetricValues() const; - void updateReadings(); - void updateReportingType(ReportingType); -+ Readings getHourReadings(); -+ int GetPositionOnLastHour(const std::vector& readings); - - std::string id; - std::string name; - ReportingType reportingType; -- Milliseconds interval; -+ Seconds interval; - std::unordered_set reportActions; - ReadingParametersPastVersion readingParametersPastVersion; - ReadingParameters readingParameters; -diff --git a/src/report_factory.cpp b/src/report_factory.cpp -index 1c530f3..0d5a8d5 100644 ---- a/src/report_factory.cpp -+++ b/src/report_factory.cpp -@@ -19,7 +19,7 @@ ReportFactory::ReportFactory( - std::unique_ptr ReportFactory::make( - const std::string& id, const std::string& name, - const ReportingType reportingType, -- const std::vector& reportActions, Milliseconds period, -+ const std::vector& reportActions, Seconds period, - uint64_t appendLimit, const ReportUpdates reportUpdates, - interfaces::ReportManager& reportManager, - interfaces::JsonStorage& reportStorage, -@@ -185,6 +185,6 @@ std::vector - return LabeledMetricParameters( - std::move(sensorParameters), utils::toOperationType(operationType), - id, utils::toCollectionTimeScope(collectionTimeScope), -- CollectionDuration(Milliseconds(collectionDuration))); -+ CollectionDuration(Seconds(collectionDuration))); - }); - } -diff --git a/src/report_factory.hpp b/src/report_factory.hpp -index e8729b1..8341970 100644 ---- a/src/report_factory.hpp -+++ b/src/report_factory.hpp -@@ -33,7 +33,7 @@ class ReportFactory : public interfaces::ReportFactory - make(const std::string& reportId, const std::string& name, - const ReportingType reportingType, - const std::vector& reportActions, -- Milliseconds period, uint64_t appendLimitIn, -+ Seconds period, uint64_t appendLimitIn, - const ReportUpdates reportUpdatesIn, - interfaces::ReportManager& reportManager, - interfaces::JsonStorage& reportStorage, -diff --git a/src/report_manager.cpp b/src/report_manager.cpp -index 926b642..f7c266f 100644 ---- a/src/report_manager.cpp -+++ b/src/report_manager.cpp -@@ -90,7 +90,7 @@ ReportManager::ReportManager( - - return addReport(yield, reportId, reportId, - utils::toReportingType(reportingType), -- reportActions, Milliseconds(interval), -+ reportActions, Seconds(interval), - appendLimitDefault, reportUpdatesDefault, - convertToReadingParameters( - std::move(metricParams)), -@@ -117,7 +117,7 @@ ReportManager::ReportManager( - return utils::toReportAction( - reportAction); - }), -- Milliseconds(interval), appendLimit, -+ Seconds(interval), appendLimit, - utils::toReportUpdates(reportUpdates), - std::move(metricParams), enabledDefault) - .getPath(); -@@ -135,7 +135,7 @@ void ReportManager::removeReport(const interfaces::Report* report) - - void ReportManager::verifyAddReport( - const std::string& reportId, const std::string& reportName, -- const ReportingType reportingType, Milliseconds interval, -+ const ReportingType reportingType, Seconds interval, - const ReportUpdates reportUpdates, const uint64_t appendLimit, - const std::vector& readingParams) - { -@@ -196,7 +196,7 @@ void ReportManager::verifyAddReport( - interfaces::Report& ReportManager::addReport( - boost::asio::yield_context& yield, const std::string& reportId, - const std::string& reportName, const ReportingType reportingType, -- const std::vector& reportActions, Milliseconds interval, -+ const std::vector& reportActions, Seconds interval, - const uint64_t appendLimit, const ReportUpdates reportUpdates, - ReadingParameters metricParams, const bool enabled) - { -@@ -211,7 +211,7 @@ interfaces::Report& ReportManager::addReport( - interfaces::Report& ReportManager::addReport( - const std::string& reportId, const std::string& reportName, - const ReportingType reportingType, -- const std::vector& reportActions, Milliseconds interval, -+ const std::vector& reportActions, Seconds interval, - const uint64_t appendLimit, const ReportUpdates reportUpdates, - std::vector labeledMetricParams, - const bool enabled, Readings readings) -@@ -273,7 +273,7 @@ void ReportManager::loadFromPersistent() - } - - addReport(id, name, utils::toReportingType(reportingType), -- reportActions, Milliseconds(interval), appendLimit, -+ reportActions, Seconds(interval), appendLimit, - utils::toReportUpdates(reportUpdates), - std::move(readingParameters), enabled, - std::move(readings)); -diff --git a/src/report_manager.hpp b/src/report_manager.hpp -index d5653b2..dd029af 100644 ---- a/src/report_manager.hpp -+++ b/src/report_manager.hpp -@@ -15,6 +15,7 @@ - #include - #include - #include -+#include - - class ReportManager : public interfaces::ReportManager - { -@@ -41,20 +42,20 @@ class ReportManager : public interfaces::ReportManager - - void verifyAddReport( - const std::string& reportId, const std::string& reportName, -- const ReportingType reportingType, Milliseconds interval, -+ const ReportingType reportingType, Seconds interval, - const ReportUpdates reportUpdates, const uint64_t appendLimit, - const std::vector& readingParams); - interfaces::Report& addReport( - boost::asio::yield_context& yield, const std::string& reportId, - const std::string& reportName, const ReportingType reportingType, -- const std::vector& reportActions, Milliseconds interval, -+ const std::vector& reportActions, Seconds interval, - const uint64_t appendLimit, const ReportUpdates reportUpdates, - ReadingParameters metricParams, const bool enabled); - interfaces::Report& - addReport(const std::string& reportId, const std::string& reportName, - const ReportingType reportingType, - const std::vector& reportActions, -- Milliseconds interval, const uint64_t appendLimit, -+ Seconds interval, const uint64_t appendLimit, - const ReportUpdates reportUpdates, - std::vector metricParams, - const bool enabled, Readings); -@@ -66,8 +67,8 @@ class ReportManager : public interfaces::ReportManager - static constexpr size_t maxReportIdLength{ - TELEMETRY_MAX_DBUS_PATH_LENGTH - - std::string_view(Report::reportDir).length()}; -- static constexpr Milliseconds minInterval{TELEMETRY_MIN_INTERVAL}; -- static constexpr size_t maxAppendLimit{TELEMETRY_MAX_APPEND_LIMIT}; -+ static constexpr Seconds minInterval{TELEMETRY_MIN_INTERVAL}; -+ static constexpr uint64_t maxAppendLimit{std::numeric_limits::max()}; - static constexpr const char* reportManagerIfaceName = - "xyz.openbmc_project.Telemetry.ReportManager"; - static constexpr const char* reportManagerPath = -diff --git a/src/sensor.hpp b/src/sensor.hpp -index 92ff02c..e4d2396 100644 ---- a/src/sensor.hpp -+++ b/src/sensor.hpp -@@ -51,12 +51,12 @@ class Sensor final : - std::string sensorMetadata; - boost::asio::io_context& ioc; - std::shared_ptr bus; -- Milliseconds timerInterval = Milliseconds(0); -+ Seconds timerInterval = Seconds(0); - std::optional timer; - - utils::UniqueCall uniqueCall; - std::vector> listeners; -- Milliseconds timestamp = Milliseconds{0u}; -+ Seconds timestamp = Seconds{0u}; - std::optional value; - std::unique_ptr signalMonitor; - }; -diff --git a/src/trigger_actions.cpp b/src/trigger_actions.cpp -index c840422..06cb419 100644 ---- a/src/trigger_actions.cpp -+++ b/src/trigger_actions.cpp -@@ -13,7 +13,7 @@ namespace action - - namespace - { --std::string timestampToString(Milliseconds timestamp) -+std::string timestampToString(Seconds timestamp) - { - std::time_t t = static_cast(timestamp.count()); - std::array buf = {}; -@@ -43,7 +43,7 @@ static const char* getDirection(double value, double threshold) - throw std::runtime_error("Invalid value"); - } - --void LogToJournal::commit(const std::string& sensorName, Milliseconds timestamp, -+void LogToJournal::commit(const std::string& sensorName, Seconds timestamp, - double value) - { - std::string msg = ::numeric::typeToString(type) + -@@ -72,7 +72,7 @@ const char* LogToRedfish::getMessageId() const - throw std::runtime_error("Invalid type"); - } - --void LogToRedfish::commit(const std::string& sensorName, Milliseconds timestamp, -+void LogToRedfish::commit(const std::string& sensorName, Seconds timestamp, - double value) - { - phosphor::logging::log( -@@ -120,7 +120,7 @@ void fillActions( - - namespace discrete - { --void LogToJournal::commit(const std::string& sensorName, Milliseconds timestamp, -+void LogToJournal::commit(const std::string& sensorName, Seconds timestamp, - double value) - { - std::string msg = ::discrete::severityToString(severity) + -@@ -145,7 +145,7 @@ const char* LogToRedfish::getMessageId() const - throw std::runtime_error("Invalid severity"); - } - --void LogToRedfish::commit(const std::string& sensorName, Milliseconds timestamp, -+void LogToRedfish::commit(const std::string& sensorName, Seconds timestamp, - double value) - { - phosphor::logging::log( -@@ -190,7 +190,7 @@ void fillActions( - - namespace onChange - { --void LogToJournal::commit(const std::string& sensorName, Milliseconds timestamp, -+void LogToJournal::commit(const std::string& sensorName, Seconds timestamp, - double value) - { - std::string msg = "Value changed on sensor " + sensorName + -@@ -200,7 +200,7 @@ void LogToJournal::commit(const std::string& sensorName, Milliseconds timestamp, - phosphor::logging::log(msg.c_str()); - } - --void LogToRedfish::commit(const std::string& sensorName, Milliseconds timestamp, -+void LogToRedfish::commit(const std::string& sensorName, Seconds timestamp, - double value) - { - const char* messageId = "OpenBMC.0.1.0.DiscreteThresholdOnChange"; -@@ -243,7 +243,7 @@ void fillActions( - } // namespace onChange - } // namespace discrete - --void UpdateReport::commit(const std::string&, Milliseconds, double) -+void UpdateReport::commit(const std::string&, Seconds, double) - { - if (reportIds->empty()) - { -diff --git a/src/trigger_actions.hpp b/src/trigger_actions.hpp -index fdf07fe..c027c1d 100644 ---- a/src/trigger_actions.hpp -+++ b/src/trigger_actions.hpp -@@ -16,7 +16,7 @@ class LogToJournal : public interfaces::TriggerAction - LogToJournal(::numeric::Type type, double val) : type(type), threshold(val) - {} - -- void commit(const std::string& id, Milliseconds timestamp, -+ void commit(const std::string& id, Seconds timestamp, - double value) override; - - private: -@@ -30,7 +30,7 @@ class LogToRedfish : public interfaces::TriggerAction - LogToRedfish(::numeric::Type type, double val) : type(type), threshold(val) - {} - -- void commit(const std::string& id, Milliseconds timestamp, -+ void commit(const std::string& id, Seconds timestamp, - double value) override; - - private: -@@ -55,7 +55,7 @@ class LogToJournal : public interfaces::TriggerAction - explicit LogToJournal(::discrete::Severity severity) : severity(severity) - {} - -- void commit(const std::string& id, Milliseconds timestamp, -+ void commit(const std::string& id, Seconds timestamp, - double value) override; - - private: -@@ -68,7 +68,7 @@ class LogToRedfish : public interfaces::TriggerAction - explicit LogToRedfish(::discrete::Severity severity) : severity(severity) - {} - -- void commit(const std::string& id, Milliseconds timestamp, -+ void commit(const std::string& id, Seconds timestamp, - double value) override; - - private: -@@ -91,7 +91,7 @@ class LogToJournal : public interfaces::TriggerAction - LogToJournal() - {} - -- void commit(const std::string& id, Milliseconds timestamp, -+ void commit(const std::string& id, Seconds timestamp, - double value) override; - }; - -@@ -101,7 +101,7 @@ class LogToRedfish : public interfaces::TriggerAction - LogToRedfish() - {} - -- void commit(const std::string& id, Milliseconds timestamp, -+ void commit(const std::string& id, Seconds timestamp, - double value) override; - }; - -@@ -122,7 +122,7 @@ class UpdateReport : public interfaces::TriggerAction - reportIds(std::move(ids)) - {} - -- void commit(const std::string& id, Milliseconds timestamp, -+ void commit(const std::string& id, Seconds timestamp, - double value) override; - - private: -diff --git a/src/trigger_factory.cpp b/src/trigger_factory.cpp -index 6c9ceb9..d51e44c 100644 ---- a/src/trigger_factory.cpp -+++ b/src/trigger_factory.cpp -@@ -154,7 +154,7 @@ void TriggerFactory::makeDiscreteThreshold( - - std::string thresholdName = thresholdParam.at_label(); - discrete::Severity severity = thresholdParam.at_label(); -- auto dwellTime = Milliseconds(thresholdParam.at_label()); -+ auto dwellTime = Seconds(thresholdParam.at_label()); - std::string thresholdValue = thresholdParam.at_label(); - - action::discrete::fillActions(actions, triggerActions, severity, -@@ -162,7 +162,7 @@ void TriggerFactory::makeDiscreteThreshold( - - thresholds.emplace_back(std::make_shared( - bus->get_io_context(), sensors, std::move(actions), -- Milliseconds(dwellTime), thresholdValue, thresholdName, severity)); -+ Seconds(dwellTime), thresholdValue, thresholdName, severity)); - } - - void TriggerFactory::makeNumericThreshold( -@@ -175,7 +175,7 @@ void TriggerFactory::makeNumericThreshold( - std::vector> actions; - - auto type = thresholdParam.at_label(); -- auto dwellTime = Milliseconds(thresholdParam.at_label()); -+ auto dwellTime = Seconds(thresholdParam.at_label()); - auto direction = thresholdParam.at_label(); - auto thresholdValue = double{thresholdParam.at_label()}; - -diff --git a/src/types/collection_duration.hpp b/src/types/collection_duration.hpp -index cdb9ff9..4d569e5 100644 ---- a/src/types/collection_duration.hpp -+++ b/src/types/collection_duration.hpp -@@ -8,7 +8,7 @@ - #include - #include - --BOOST_STRONG_TYPEDEF(Milliseconds, CollectionDuration) -+BOOST_STRONG_TYPEDEF(Seconds, CollectionDuration) - - inline void to_json(nlohmann::json& json, const CollectionDuration& value) - { -@@ -17,5 +17,5 @@ inline void to_json(nlohmann::json& json, const CollectionDuration& value) - - inline void from_json(const nlohmann::json& json, CollectionDuration& value) - { -- value = CollectionDuration(Milliseconds(json.get())); -+ value = CollectionDuration(Seconds(json.get())); - } -diff --git a/src/types/duration_types.hpp b/src/types/duration_types.hpp -index b65f779..76c960b 100644 ---- a/src/types/duration_types.hpp -+++ b/src/types/duration_types.hpp -@@ -2,5 +2,4 @@ - - #include - --using Seconds = std::chrono::duration; --using Milliseconds = std::chrono::duration; -+using Seconds = std::chrono::duration; -diff --git a/src/types/readings.hpp b/src/types/readings.hpp -index 6749bbf..ec419ec 100644 ---- a/src/types/readings.hpp -+++ b/src/types/readings.hpp -@@ -3,16 +3,16 @@ - #include "utils/labeled_tuple.hpp" - #include "utils/tstring.hpp" - --using ReadingData = std::tuple; --using Readings = std::tuple>; -+using ReadingData = std::tuple; -+using Readings = std::tuple>; - - using LabeledReadingData = -- utils::LabeledTuple; - - using LabeledReadings = -- utils::LabeledTuple>, -+ utils::LabeledTuple>, - utils::tstring::Timestamp, utils::tstring::Readings>; - - namespace utils -diff --git a/src/utils/clock.hpp b/src/utils/clock.hpp -index 4e17952..45c1bc4 100644 ---- a/src/utils/clock.hpp -+++ b/src/utils/clock.hpp -@@ -8,16 +8,16 @@ - class Clock : public interfaces::Clock - { - public: -- Milliseconds steadyTimestamp() const noexcept override -+ Seconds steadyTimestamp() const noexcept override - { -- return std::chrono::time_point_cast( -+ return std::chrono::time_point_cast( - std::chrono::steady_clock::now()) - .time_since_epoch(); - } - -- Milliseconds systemTimestamp() const noexcept override -+ Seconds systemTimestamp() const noexcept override - { -- return std::chrono::time_point_cast( -+ return std::chrono::time_point_cast( - std::chrono::system_clock::now()) - .time_since_epoch(); - } diff --git a/meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0003-bugfix-circular-buffer.patch b/meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0003-bugfix-circular-buffer.patch new file mode 100644 index 0000000000..659a74e12e --- /dev/null +++ b/meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0003-bugfix-circular-buffer.patch @@ -0,0 +1,200 @@ +From a5b67b01133090b3f498a46debefc0a2b34f1934 Mon Sep 17 00:00:00 2001 +From: eportnov +Date: Thu, 8 Sep 2022 17:38:27 +0300 +Subject: [PATCH] bugfix circular buffer + +--- + src/report.cpp | 34 ++++++++----------------- + src/report.hpp | 8 +++--- + src/types/readings.hpp | 6 +++-- + src/utils/queue_list.hpp | 55 ++++++++++++++++++++++++++++++++++++++++ + 4 files changed, 73 insertions(+), 30 deletions(-) + create mode 100644 src/utils/queue_list.hpp + +diff --git a/src/report.cpp b/src/report.cpp +index 06985a5..55bb931 100644 +--- a/src/report.cpp ++++ b/src/report.cpp +@@ -419,44 +419,30 @@ std::unique_ptr + return dbusIface; + } + +- Readings Report::getHourReadings() ++ Readings Report::getHourReadings() const + { +- static constexpr int ZERO_POSITION = 0; +- + Readings result; + std::get<0>(result) = std::get<0>(readings); +- auto& result_read = std::get<1>(result);; +- +- auto& read = std::get<1>(readings); +- auto hour_pos = GetPositionOnLastHour(read); +- +- if(hour_pos == ZERO_POSITION) +- { +- return readings; +- } +- std::copy(read.begin() + hour_pos, read.end(), std::back_inserter(result_read)); +- ++ CopyHourData(std::get<1>(readings), std::get<1>(result)); + return result; + } + +- int Report::GetPositionOnLastHour(const std::vector& readings) ++ void Report::CopyHourData(const std::list& readings, std::list& result) const + { + static constexpr uint32_t SECONDS_IN_HOUR = 60*60; +- static constexpr int DEFAULT_RESULT = 0; + + uint64_t time_past_hour = std::chrono::duration_cast( +- std::chrono::system_clock::now().time_since_epoch()).count() - SECONDS_IN_HOUR; +- +- +- for(auto it = readings.rbegin(); it !=readings.rend(); ++it) ++ std::chrono::system_clock::now().time_since_epoch()).count() - SECONDS_IN_HOUR; ++ for(auto reading_it = readings.rbegin(); reading_it !=readings.rend(); ++reading_it) + { +- auto reading_time = std::get<2>(*it); +- if(reading_time < time_past_hour) ++ ++ auto reading_time = std::get<2>(*reading_it); ++ if(reading_time <= time_past_hour) + { +- return abs(readings.rend() - it); ++ return; + } ++ result.push_front(*reading_it); + } +- return DEFAULT_RESULT; + } + + void Report::timerProcForPeriodicReport(boost::system::error_code ec, +diff --git a/src/report.hpp b/src/report.hpp +index b55b01b..bfe9e04 100644 +--- a/src/report.hpp ++++ b/src/report.hpp +@@ -14,7 +14,6 @@ + #include "types/report_types.hpp" + #include "types/report_updates.hpp" + #include "types/reporting_type.hpp" +-#include "utils/circular_vector.hpp" + #include "utils/dbus_path_utils.hpp" + #include "utils/ensure.hpp" + #include "utils/messanger.hpp" +@@ -27,6 +26,7 @@ + #include + #include + ++#include "utils/queue_list.hpp" + class Report : public interfaces::Report, public interfaces::MetricListener + { + class OnChangeContext +@@ -112,8 +112,8 @@ class Report : public interfaces::Report, public interfaces::MetricListener + void updateReadings(); + void scheduleTimer(); + std::vector verify() const; +- Readings getHourReadings(); +- int GetPositionOnLastHour(const std::vector& readings); ++ Readings getHourReadings() const; ++ void CopyHourData(const std::list& readings, std::list& result) const; + + std::string id; + const sdbusplus::message::object_path path; +@@ -128,7 +128,7 @@ class Report : public interfaces::Report, public interfaces::MetricListener + std::optional appendLimit; + ReportUpdates reportUpdates; + Readings readings = {}; +- CircularVector readingsBuffer; ++ QueueList readingsBuffer; + std::shared_ptr objServer; + std::unique_ptr reportIface; + std::unique_ptr deleteIface; +diff --git a/src/types/readings.hpp b/src/types/readings.hpp +index 74566eb..5101cd0 100644 +--- a/src/types/readings.hpp ++++ b/src/types/readings.hpp +@@ -1,10 +1,12 @@ + #pragma once + ++#include ++ + #include "utils/labeled_tuple.hpp" + #include "utils/tstring.hpp" + + using ReadingData = std::tuple; +-using Readings = std::tuple>; ++using Readings = std::tuple>; + + using LabeledReadingData = + utils::LabeledTuple; + + using LabeledReadings = +- utils::LabeledTuple>, ++ utils::LabeledTuple>, + utils::tstring::Timestamp, utils::tstring::Readings>; + + namespace utils +diff --git a/src/utils/queue_list.hpp b/src/utils/queue_list.hpp +new file mode 100644 +index 0000000..3ed08db +--- /dev/null ++++ b/src/utils/queue_list.hpp +@@ -0,0 +1,55 @@ ++#include ++ ++template ++class QueueList ++{ ++ public: ++ QueueList(std::list& externalData, size_t maxSizeIn) ++ : data(externalData), maxSize(maxSizeIn) ++ { ++ } ++ ++ template ++ void emplace(Args&&... args) ++ { ++ if(maxSize == 0) ++ { ++ return; ++ } ++ if(isFull()) ++ { ++ data.pop_front(); ++ } ++ data.emplace_back(std::forward(args)...); ++ } ++ ++ void clear() ++ { ++ data.clear(); ++ } ++ ++ bool isFull() const noexcept ++ { ++ return data.size() == maxSize; ++ } ++ ++ void clearAndResize(size_t newMaxSize) ++ { ++ clear(); ++ maxSize = newMaxSize; ++ } ++ ++ auto begin() const noexcept ++ { ++ return data.begin(); ++ } ++ ++ auto end() const noexcept ++ { ++ return data.end(); ++ } ++ ++ private: ++ std::list& data; ++ size_t maxSize; ++}; diff --git a/meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0003-fix-bug-circular-buffer.patch b/meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0003-fix-bug-circular-buffer.patch deleted file mode 100644 index 73972a50e6..0000000000 --- a/meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0003-fix-bug-circular-buffer.patch +++ /dev/null @@ -1,191 +0,0 @@ -From 0e4a90e8371dd196650e3d90dc2d8b98ab063b95 Mon Sep 17 00:00:00 2001 -From: eportnov -Date: Thu, 25 Aug 2022 17:24:37 +0300 -Subject: [PATCH] fix bug circular buffer - ---- - src/report.cpp | 31 +++++++--------------- - src/report.hpp | 7 ++--- - src/types/readings.hpp | 6 +++-- - src/utils/queue_list.hpp | 55 ++++++++++++++++++++++++++++++++++++++++ - 4 files changed, 72 insertions(+), 27 deletions(-) - create mode 100644 src/utils/queue_list.hpp - -diff --git a/src/report.cpp b/src/report.cpp -index a53f287..5d35006 100644 ---- a/src/report.cpp -+++ b/src/report.cpp -@@ -387,44 +387,31 @@ std::unique_ptr - return dbusIface; - } - --Readings Report::getHourReadings() -+Readings Report::getHourReadings() const - { -- static constexpr int ZERO_POSITION = 0; -- - Readings result; - std::get<0>(result) = std::get<0>(readings); -- auto& result_read = std::get<1>(result);; -- -- auto& read = std::get<1>(readings); -- auto hour_pos = GetPositionOnLastHour(read); - -- if(hour_pos == ZERO_POSITION) -- { -- return readings; -- } -- std::copy(read.begin() + hour_pos, read.end(), std::back_inserter(result_read)); -+ CopyHourData(std::get<1>(readings), std::get<1>(result)); - - return result; - } - --int Report::GetPositionOnLastHour(const std::vector& readings) -+void Report::CopyHourData(const std::list& readings, std::list& result) const - { - static constexpr uint32_t SECONDS_IN_HOUR = 60*60; -- static constexpr int DEFAULT_RESULT = 0; -- -+ - uint64_t time_past_hour = std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch()).count() - SECONDS_IN_HOUR; -- -- -- for(auto it = readings.rbegin(); it !=readings.rend(); ++it) -+ for(auto reading_it = readings.rbegin(); reading_it !=readings.rend(); ++reading_it) - { -- auto reading_time = std::get<2>(*it); -- if(reading_time < time_past_hour) -+ auto reading_time = std::get<2>(*reading_it); -+ if(reading_time <= time_past_hour) - { -- return abs(readings.rend() - it); -+ return; - } -+ result.push_front(*reading_it); - } -- return DEFAULT_RESULT; - } - - void Report::timerProcForPeriodicReport(boost::system::error_code ec, -diff --git a/src/report.hpp b/src/report.hpp -index 5353ce5..4a9e2b3 100644 ---- a/src/report.hpp -+++ b/src/report.hpp -@@ -23,6 +23,7 @@ - #include - #include - #include -+#include "utils/queue_list.hpp" - - class Report : public interfaces::Report, public interfaces::MetricListener - { -@@ -105,8 +106,8 @@ class Report : public interfaces::Report, public interfaces::MetricListener - bool shouldStoreMetricValues() const; - void updateReadings(); - void updateReportingType(ReportingType); -- Readings getHourReadings(); -- int GetPositionOnLastHour(const std::vector& readings); -+ Readings getHourReadings() const; -+ void CopyHourData(const std::list& readings, std::list& result) const; - - std::string id; - std::string name; -@@ -120,7 +121,7 @@ class Report : public interfaces::Report, public interfaces::MetricListener - std::optional appendLimit; - ReportUpdates reportUpdates; - Readings readings = {}; -- CircularVector readingsBuffer; -+ QueueList readingsBuffer; - std::shared_ptr objServer; - std::unique_ptr reportIface; - std::unique_ptr deleteIface; -diff --git a/src/types/readings.hpp b/src/types/readings.hpp -index ec419ec..05a39fc 100644 ---- a/src/types/readings.hpp -+++ b/src/types/readings.hpp -@@ -1,10 +1,12 @@ - #pragma once - -+#include -+ - #include "utils/labeled_tuple.hpp" - #include "utils/tstring.hpp" - - using ReadingData = std::tuple; --using Readings = std::tuple>; -+using Readings = std::tuple>; - - using LabeledReadingData = - utils::LabeledTuple; - - using LabeledReadings = -- utils::LabeledTuple>, -+ utils::LabeledTuple>, - utils::tstring::Timestamp, utils::tstring::Readings>; - - namespace utils -diff --git a/src/utils/queue_list.hpp b/src/utils/queue_list.hpp -new file mode 100644 -index 0000000..1d25615 ---- /dev/null -+++ b/src/utils/queue_list.hpp -@@ -0,0 +1,55 @@ -+#include -+ -+template -+class QueueList -+{ -+ public: -+ QueueList(std::list& externalData, size_t maxSizeIn) -+ : data(externalData), maxSize(maxSizeIn) -+ { -+ } -+ -+ template -+ void emplace(Args&&... args) -+ { -+ if(maxSize == 0) -+ { -+ return; -+ } -+ if(isFull()) -+ { -+ data.pop_front(); -+ } -+ data.emplace_back(std::forward(args)...); -+ } -+ -+ void clear() -+ { -+ data.clear(); -+ } -+ -+ bool isFull() const noexcept -+ { -+ return data.size() == maxSize; -+ } -+ -+ void clearAndResize(size_t newMaxSize) -+ { -+ clear(); -+ maxSize = newMaxSize; -+ } -+ -+ auto begin() const noexcept -+ { -+ return data.begin(); -+ } -+ -+ auto end() const noexcept -+ { -+ return data.end(); -+ } -+ -+ private: -+ std::list& data; -+ size_t maxSize; -+}; diff --git a/meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0004-configure-telemetry.patch b/meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0004-configure-telemetry.patch deleted file mode 100644 index 91b64d6e30..0000000000 --- a/meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0004-configure-telemetry.patch +++ /dev/null @@ -1,121 +0,0 @@ -From 00985aa2686a9277291b1fc744d78899a0e33807 Mon Sep 17 00:00:00 2001 -From: eportnov -Date: Thu, 8 Sep 2022 14:26:35 +0300 -Subject: [PATCH] configure telemetry - ---- - meson_options.txt | 4 ++-- - src/metric.cpp | 2 +- - src/metric_value.hpp | 1 - - src/report.cpp | 6 +++--- - src/types/readings.hpp | 4 ++-- - src/utils/dbus_path_utils.hpp | 2 +- - 6 files changed, 9 insertions(+), 10 deletions(-) - -diff --git a/meson_options.txt b/meson_options.txt -index c8a46b8..0a50b7d 100644 ---- a/meson_options.txt -+++ b/meson_options.txt -@@ -1,5 +1,5 @@ - option('buildtest', type: 'boolean', value: true, description: 'Build tests') --option('max-reports', type: 'integer', min: 0, value: 10, -+option('max-reports', type: 'integer', min: 0, value: 20, - description: 'Max number of Reports') - option('max-reading-parameters', type: 'integer', min: 0, value: 200, - description: 'Max number of metric properties in single report') -@@ -9,7 +9,7 @@ option('max-triggers', type: 'integer', min: 0, value: 10, - description: 'Max number of Triggers') - option('max-dbus-path-length', type: 'integer', min: 256, value: 4095, - description: 'Max length of dbus object path') --option('max-append-limit', type: 'integer', min: 0, value: 256, -+option('max-append-limit', type: 'integer', min: 0, value: 2147483647, - description: 'Max AppendLimit value') - option('max-id-name-length', type: 'integer', min: 32, value: 256, - description: 'Max length of any "id" or "name" type field.') -diff --git a/src/metric.cpp b/src/metric.cpp -index d6b62d8..48fb7a7 100644 ---- a/src/metric.cpp -+++ b/src/metric.cpp -@@ -81,7 +81,7 @@ const std::vector& Metric::getUpdatedReadings() - i = idx; - } - -- readings.emplace_back(id, sensors[i]->metadata(), *value, -+ readings.emplace_back(sensors[i]->metadata(), *value, - systemTimestamp); - } - } -diff --git a/src/metric_value.hpp b/src/metric_value.hpp -index d01ac4e..9dfc6ac 100644 ---- a/src/metric_value.hpp -+++ b/src/metric_value.hpp -@@ -5,7 +5,6 @@ - - struct MetricValue - { -- std::string id; - std::string metadata; - double value; - uint64_t timestamp; -diff --git a/src/report.cpp b/src/report.cpp -index 9ee60a4..624bdbc 100644 ---- a/src/report.cpp -+++ b/src/report.cpp -@@ -461,7 +461,7 @@ void Report::scheduleTimerForPeriodicReport(Milliseconds timerInterval) - - void Report::scheduleTimerForOnChangeReport() - { -- constexpr Milliseconds timerInterval{100}; -+ constexpr Milliseconds timerInterval{10000}; - - timer.expires_after(timerInterval); - timer.async_wait([this](boost::system::error_code ec) { -@@ -489,7 +489,7 @@ void Report::updateReadings() - break; - } - -- for (const auto& [id, metadata, value, timestamp] : -+ for (const auto& [metadata, value, timestamp] : - metric->getUpdatedReadings()) - { - if (reportUpdates == ReportUpdates::appendStopsWhenFull && -@@ -499,7 +499,7 @@ void Report::updateReadings() - reportIface->signal_property("Enabled"); - break; - } -- readingsBuffer.emplace(id, metadata, value, timestamp); -+ readingsBuffer.emplace(metadata, value, timestamp); - } - } - -diff --git a/src/types/readings.hpp b/src/types/readings.hpp -index 6749bbf..74566eb 100644 ---- a/src/types/readings.hpp -+++ b/src/types/readings.hpp -@@ -3,11 +3,11 @@ - #include "utils/labeled_tuple.hpp" - #include "utils/tstring.hpp" - --using ReadingData = std::tuple; -+using ReadingData = std::tuple; - using Readings = std::tuple>; - - using LabeledReadingData = -- utils::LabeledTuple; - -diff --git a/src/utils/dbus_path_utils.hpp b/src/utils/dbus_path_utils.hpp -index 3798d98..d0e1d24 100644 ---- a/src/utils/dbus_path_utils.hpp -+++ b/src/utils/dbus_path_utils.hpp -@@ -14,7 +14,7 @@ namespace constants - constexpr std::string_view triggerDirStr = - "/xyz/openbmc_project/Telemetry/Triggers/"; - constexpr std::string_view reportDirStr = -- "/xyz/openbmc_project/Telemetry/Reports/"; -+ "/xyz/openbmc_project/Telemetry/Reports/TelemetryService"; - - constexpr std::string_view allowedCharactersInPath = - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_/"; diff --git a/meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0005-add-hour-data.patch b/meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0005-add-hour-data.patch deleted file mode 100644 index 3a795b1838..0000000000 --- a/meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0005-add-hour-data.patch +++ /dev/null @@ -1,97 +0,0 @@ -From 34ff94d5b3c8fae4050c96aaabc2975d158c85cf Mon Sep 17 00:00:00 2001 -From: eportnov -Date: Thu, 8 Sep 2022 15:23:11 +0300 -Subject: [PATCH] add hour data - ---- - src/report.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++++++---- - src/report.hpp | 2 ++ - 2 files changed, 49 insertions(+), 4 deletions(-) - -diff --git a/src/report.cpp b/src/report.cpp -index 624bdbc..06985a5 100644 ---- a/src/report.cpp -+++ b/src/report.cpp -@@ -296,10 +296,6 @@ std::unique_ptr - return 1; - }, - [this](const auto&) { return persistency; }); -- -- dbusIface->register_property_r("Readings", readings, -- sdbusplus::vtable::property_::emits_change, -- [this](const auto&) { return readings; }); - dbusIface->register_property_rw( - "ReportingType", sdbusplus::vtable::property_::emits_change, - [this](auto newVal, auto& oldVal) { -@@ -411,11 +407,58 @@ std::unique_ptr - updateReadings(); - } - }); -+ dbusIface->register_method("GetReadings", [this](bool is_need_last_hour) { -+ if(is_need_last_hour) -+ { -+ return getHourReadings(); -+ } -+ return readings; -+ }); - constexpr bool skipPropertiesChangedSignal = true; - dbusIface->initialize(skipPropertiesChangedSignal); - return dbusIface; - } - -+ Readings Report::getHourReadings() -+ { -+ static constexpr int ZERO_POSITION = 0; -+ -+ Readings result; -+ std::get<0>(result) = std::get<0>(readings); -+ auto& result_read = std::get<1>(result);; -+ -+ auto& read = std::get<1>(readings); -+ auto hour_pos = GetPositionOnLastHour(read); -+ -+ if(hour_pos == ZERO_POSITION) -+ { -+ return readings; -+ } -+ std::copy(read.begin() + hour_pos, read.end(), std::back_inserter(result_read)); -+ -+ return result; -+ } -+ -+ int Report::GetPositionOnLastHour(const std::vector& readings) -+ { -+ static constexpr uint32_t SECONDS_IN_HOUR = 60*60; -+ static constexpr int DEFAULT_RESULT = 0; -+ -+ uint64_t time_past_hour = std::chrono::duration_cast( -+ std::chrono::system_clock::now().time_since_epoch()).count() - SECONDS_IN_HOUR; -+ -+ -+ for(auto it = readings.rbegin(); it !=readings.rend(); ++it) -+ { -+ auto reading_time = std::get<2>(*it); -+ if(reading_time < time_past_hour) -+ { -+ return abs(readings.rend() - it); -+ } -+ } -+ return DEFAULT_RESULT; -+ } -+ - void Report::timerProcForPeriodicReport(boost::system::error_code ec, - Report& self) - { -diff --git a/src/report.hpp b/src/report.hpp -index 74c979b..b55b01b 100644 ---- a/src/report.hpp -+++ b/src/report.hpp -@@ -112,6 +112,8 @@ class Report : public interfaces::Report, public interfaces::MetricListener - void updateReadings(); - void scheduleTimer(); - std::vector verify() const; -+ Readings getHourReadings(); -+ int GetPositionOnLastHour(const std::vector& readings); - - std::string id; - const sdbusplus::message::object_path path; diff --git a/meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry_%.bbappend b/meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry_%.bbappend index 5d0d48c8b6..5a6c13be05 100644 --- a/meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry_%.bbappend +++ b/meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry_%.bbappend @@ -39,8 +39,9 @@ SRC_URI += "file://3017361602 \ file://3017361609 \ file://3017361610 \ file://3017361611 \ - file://0004-configure-telemetry.patch \ - file://0005-add-hour-data.patch \ + file://0001-configure-telemetry.patch \ + file://0002-add-hour-data.patch \ + file://0003-bugfix-circular-buffer.patch \ " do_install:append() { -- cgit v1.2.3