diff options
author | eportnov <eportnov@ibs.ru> | 2022-09-08 17:51:50 +0300 |
---|---|---|
committer | eportnov <eportnov@ibs.ru> | 2022-09-08 17:51:50 +0300 |
commit | 718f73da081c01b3c39a179635e4095557a70e12 (patch) | |
tree | e7a86bcdacddb2891bf65128fd61e19b1ad5ef1f | |
parent | 0baf1942d94d90479f411419f1c2a0fdee525ba4 (diff) | |
download | openbmc-718f73da081c01b3c39a179635e4095557a70e12.tar.xz |
bugfix circular buffer
9 files changed, 247 insertions, 1406 deletions
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 <eportnov@ibs.ru> +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 <utility> + #include <variant> + #include <vector> ++#include <list> + + // IWYU pragma: no_include <stddef.h> + // IWYU pragma: no_include <stdint.h> +@@ -63,6 +64,7 @@ using DbusVariantType = std::variant< + 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::tuple<uint64_t, std::list<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 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::tuple<std::string, double, uint64_t>>; ++ std::list<std::tuple<std::string, double, uint64_t>>; + using TimestampReadings = std::tuple<uint64_t, Readings>; + + 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/0004-configure-telemetry.patch b/meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0001-configure-telemetry.patch index 91b64d6e30..91b64d6e30 100644 --- a/meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0004-configure-telemetry.patch +++ b/meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0001-configure-telemetry.patch 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 <eportnov@ibs.ru> -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/0005-add-hour-data.patch b/meta-ibs/meta-cp2-5422/recipes-phosphor/telemetry/telemetry/0002-add-hour-data.patch index 3a795b1838..3a795b1838 100644 --- 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/0002-add-hour-data.patch 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 <eportnov@ibs.ru> -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<std::unique_ptr<interfaces::TriggerAction>> 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<DiscreteThreshold::ThresholdDetail> - } - - 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<std::unique_ptr<interfaces::TriggerAction>> 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<std::unique_ptr<interfaces::TriggerAction>> 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<ThresholdDetail> 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<ReportAction>& reportActions, -- Milliseconds period, uint64_t appendLimit, -+ Seconds period, uint64_t appendLimit, - const ReportUpdates reportUpdates, ReportManager& reportManager, - JsonStorage& reportStorage, - std::vector<LabeledMetricParameters> 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<MetricValue>& Metric::getUpdatedReadings() - { - const auto steadyTimestamp = clock->steadyTimestamp(); - const auto systemTimestamp = -- std::chrono::duration_cast<Milliseconds>(clock->systemTimestamp()) -+ std::chrono::duration_cast<Seconds>(clock->systemTimestamp()) - .count(); - - for (size_t i = 0; i < collectionAlgorithms.size(); ++i) -@@ -81,7 +81,7 @@ const std::vector<MetricValue>& 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<MetricValue>& 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<MetricValue>& 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<double> update(Milliseconds) override -+ std::optional<double> 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<double> update(Milliseconds timestamp) override -+ std::optional<double> 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<double> update(Milliseconds timestamp) override -+ std::optional<double> 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<double> update(Milliseconds timestamp) = 0; -- virtual double update(Milliseconds timestamp, double value) = 0; -+ virtual std::optional<double> 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<ReadingItem>& 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<ReadingItem>& 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<ReadingItem>& 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<ReadingItem>& 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<ReadingItem>& 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<ReadingItem>& 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<ReadingItem>& 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<ReadingItem>& 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<Milliseconds, double>; -+using ReadingItem = std::pair<Seconds, double>; - - class CollectionFunction - { -@@ -19,10 +19,10 @@ class CollectionFunction - virtual ~CollectionFunction() = default; - - virtual double calculate(const std::vector<ReadingItem>& readings, -- Milliseconds timestamp) const = 0; -+ Seconds timestamp) const = 0; - virtual double - calculateForStartupInterval(std::vector<ReadingItem>& readings, -- Milliseconds timestamp) const = 0; -+ Seconds timestamp) const = 0; - }; - - std::shared_ptr<CollectionFunction> 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<std::unique_ptr<interfaces::TriggerAction>> 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<NumericThreshold::ThresholdDetail> - } - - 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<std::unique_ptr<interfaces::TriggerAction>> 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<std::unique_ptr<interfaces::TriggerAction>> 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<ThresholdDetail> 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<ReportAction> 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<sdbusplus::asio::dbus_interface> - "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<sdbusplus::asio::dbus_interface> - }, - [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<sdbusplus::asio::dbus_interface> - 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<ReadingData>& 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::seconds>( -+ 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<Milliseconds>(clock->systemTimestamp()) -+ std::chrono::duration_cast<Seconds>(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<sdbusplus::asio::object_server>& objServer, - const std::string& reportId, const std::string& reportName, - const ReportingType reportingType, -- std::vector<ReportAction> reportActions, const Milliseconds period, -+ std::vector<ReportAction> 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<uint64_t> - 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<ReadingData>& readings); - - std::string id; - std::string name; - ReportingType reportingType; -- Milliseconds interval; -+ Seconds interval; - std::unordered_set<ReportAction> 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<interfaces::Report> ReportFactory::make( - const std::string& id, const std::string& name, - const ReportingType reportingType, -- const std::vector<ReportAction>& reportActions, Milliseconds period, -+ const std::vector<ReportAction>& reportActions, Seconds period, - uint64_t appendLimit, const ReportUpdates reportUpdates, - interfaces::ReportManager& reportManager, - interfaces::JsonStorage& reportStorage, -@@ -185,6 +185,6 @@ std::vector<LabeledMetricParameters> - 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<ReportAction>& 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<LabeledMetricParameters>& 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<ReportAction>& reportActions, Milliseconds interval, -+ const std::vector<ReportAction>& 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<ReportAction>& reportActions, Milliseconds interval, -+ const std::vector<ReportAction>& reportActions, Seconds interval, - const uint64_t appendLimit, const ReportUpdates reportUpdates, - std::vector<LabeledMetricParameters> 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 <memory> - #include <string> - #include <vector> -+#include <limits> - - 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<LabeledMetricParameters>& readingParams); - interfaces::Report& addReport( - boost::asio::yield_context& yield, const std::string& reportId, - const std::string& reportName, const ReportingType reportingType, -- const std::vector<ReportAction>& reportActions, Milliseconds interval, -+ const std::vector<ReportAction>& 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<ReportAction>& reportActions, -- Milliseconds interval, const uint64_t appendLimit, -+ Seconds interval, const uint64_t appendLimit, - const ReportUpdates reportUpdates, - std::vector<LabeledMetricParameters> 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<uint64_t>::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<sdbusplus::asio::connection> bus; -- Milliseconds timerInterval = Milliseconds(0); -+ Seconds timerInterval = Seconds(0); - std::optional<boost::asio::high_resolution_timer> timer; - - utils::UniqueCall uniqueCall; - std::vector<std::weak_ptr<interfaces::SensorListener>> listeners; -- Milliseconds timestamp = Milliseconds{0u}; -+ Seconds timestamp = Seconds{0u}; - std::optional<double> value; - std::unique_ptr<sdbusplus::bus::match_t> 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<time_t>(timestamp.count()); - std::array<char, sizeof("YYYY-MM-DDThh:mm:ssZ")> 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<phosphor::logging::level::INFO>( -@@ -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<phosphor::logging::level::INFO>( -@@ -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<phosphor::logging::level::INFO>(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<ts::UserId>(); - discrete::Severity severity = thresholdParam.at_label<ts::Severity>(); -- auto dwellTime = Milliseconds(thresholdParam.at_label<ts::DwellTime>()); -+ auto dwellTime = Seconds(thresholdParam.at_label<ts::DwellTime>()); - std::string thresholdValue = thresholdParam.at_label<ts::ThresholdValue>(); - - action::discrete::fillActions(actions, triggerActions, severity, -@@ -162,7 +162,7 @@ void TriggerFactory::makeDiscreteThreshold( - - thresholds.emplace_back(std::make_shared<DiscreteThreshold>( - 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<std::unique_ptr<interfaces::TriggerAction>> actions; - - auto type = thresholdParam.at_label<ts::Type>(); -- auto dwellTime = Milliseconds(thresholdParam.at_label<ts::DwellTime>()); -+ auto dwellTime = Seconds(thresholdParam.at_label<ts::DwellTime>()); - auto direction = thresholdParam.at_label<ts::Direction>(); - auto thresholdValue = double{thresholdParam.at_label<ts::ThresholdValue>()}; - -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 <chrono> - #include <cstdint> - --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<uint64_t>())); -+ value = CollectionDuration(Seconds(json.get<uint64_t>())); - } -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 <chrono> - --using Seconds = std::chrono::duration<uint64_t>; --using Milliseconds = std::chrono::duration<uint64_t, std::milli>; -+using Seconds = std::chrono::duration<uint32_t>; -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<std::string, std::string, double, uint64_t>; --using Readings = std::tuple<uint64_t, std::vector<ReadingData>>; -+using ReadingData = std::tuple<std::string, double, uint32_t>; -+using Readings = std::tuple<uint32_t, std::vector<ReadingData>>; - - using LabeledReadingData = -- utils::LabeledTuple<ReadingData, utils::tstring::MetricId, -+ utils::LabeledTuple<ReadingData, - utils::tstring::MetricProperty, - utils::tstring::MetricValue, utils::tstring::Timestamp>; - - using LabeledReadings = -- utils::LabeledTuple<std::tuple<uint64_t, std::vector<LabeledReadingData>>, -+ utils::LabeledTuple<std::tuple<uint32_t, std::vector<LabeledReadingData>>, - 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<Milliseconds>( -+ return std::chrono::time_point_cast<Seconds>( - std::chrono::steady_clock::now()) - .time_since_epoch(); - } - -- Milliseconds systemTimestamp() const noexcept override -+ Seconds systemTimestamp() const noexcept override - { -- return std::chrono::time_point_cast<Milliseconds>( -+ return std::chrono::time_point_cast<Seconds>( - 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 <eportnov@ibs.ru> +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<sdbusplus::asio::dbus_interface> + 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<ReadingData>& readings) ++ void Report::CopyHourData(const std::list<ReadingData>& readings, std::list<ReadingData>& 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::seconds>( +- 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 <memory> + #include <unordered_set> + ++#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<ErrorMessage> verify() const; +- Readings getHourReadings(); +- int GetPositionOnLastHour(const std::vector<ReadingData>& readings); ++ Readings getHourReadings() const; ++ void CopyHourData(const std::list<ReadingData>& readings, std::list<ReadingData>& 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<uint64_t> appendLimit; + ReportUpdates reportUpdates; + Readings readings = {}; +- CircularVector<ReadingData> readingsBuffer; ++ QueueList<ReadingData> readingsBuffer; + std::shared_ptr<sdbusplus::asio::object_server> objServer; + std::unique_ptr<sdbusplus::asio::dbus_interface> reportIface; + std::unique_ptr<sdbusplus::asio::dbus_interface> 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 <list> ++ + #include "utils/labeled_tuple.hpp" + #include "utils/tstring.hpp" + + using ReadingData = std::tuple<std::string, double, uint64_t>; +-using Readings = std::tuple<uint64_t, std::vector<ReadingData>>; ++using Readings = std::tuple<uint64_t, std::list<ReadingData>>; + + using LabeledReadingData = + utils::LabeledTuple<ReadingData, +@@ -12,7 +14,7 @@ using LabeledReadingData = + utils::tstring::MetricValue, utils::tstring::Timestamp>; + + using LabeledReadings = +- utils::LabeledTuple<std::tuple<uint64_t, std::vector<LabeledReadingData>>, ++ utils::LabeledTuple<std::tuple<uint64_t, std::list<LabeledReadingData>>, + 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 <list> ++ ++template <class T> ++class QueueList ++{ ++ public: ++ QueueList(std::list<T>& externalData, size_t maxSizeIn) ++ : data(externalData), maxSize(maxSizeIn) ++ { ++ } ++ ++ template <class... Args> ++ void emplace(Args&&... args) ++ { ++ if(maxSize == 0) ++ { ++ return; ++ } ++ if(isFull()) ++ { ++ data.pop_front(); ++ } ++ data.emplace_back(std::forward<Args>(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<T>& 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 <eportnov@ibs.ru> -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<sdbusplus::asio::dbus_interface> - 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<ReadingData>& readings) -+void Report::CopyHourData(const std::list<ReadingData>& readings, std::list<ReadingData>& 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::seconds>( - 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 <chrono> - #include <memory> - #include <unordered_set> -+#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<ReadingData>& readings); -+ Readings getHourReadings() const; -+ void CopyHourData(const std::list<ReadingData>& readings, std::list<ReadingData>& result) const; - - std::string id; - std::string name; -@@ -120,7 +121,7 @@ class Report : public interfaces::Report, public interfaces::MetricListener - std::optional<uint64_t> appendLimit; - ReportUpdates reportUpdates; - Readings readings = {}; -- CircularVector<ReadingData> readingsBuffer; -+ QueueList<ReadingData> readingsBuffer; - std::shared_ptr<sdbusplus::asio::object_server> objServer; - std::unique_ptr<sdbusplus::asio::dbus_interface> reportIface; - std::unique_ptr<sdbusplus::asio::dbus_interface> 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 <list> -+ - #include "utils/labeled_tuple.hpp" - #include "utils/tstring.hpp" - - using ReadingData = std::tuple<std::string, double, uint32_t>; --using Readings = std::tuple<uint32_t, std::vector<ReadingData>>; -+using Readings = std::tuple<uint32_t, std::list<ReadingData>>; - - using LabeledReadingData = - utils::LabeledTuple<ReadingData, -@@ -12,7 +14,7 @@ using LabeledReadingData = - utils::tstring::MetricValue, utils::tstring::Timestamp>; - - using LabeledReadings = -- utils::LabeledTuple<std::tuple<uint32_t, std::vector<LabeledReadingData>>, -+ utils::LabeledTuple<std::tuple<uint32_t, std::list<LabeledReadingData>>, - 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 <list> -+ -+template <class T> -+class QueueList -+{ -+ public: -+ QueueList(std::list<T>& externalData, size_t maxSizeIn) -+ : data(externalData), maxSize(maxSizeIn) -+ { -+ } -+ -+ template <class... Args> -+ void emplace(Args&&... args) -+ { -+ if(maxSize == 0) -+ { -+ return; -+ } -+ if(isFull()) -+ { -+ data.pop_front(); -+ } -+ data.emplace_back(std::forward<Args>(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<T>& data; -+ size_t maxSize; -+}; 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() { |