Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 3 | #include "interfaces/json_storage.hpp" |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 4 | #include "interfaces/metric.hpp" |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 5 | #include "interfaces/report.hpp" |
| 6 | #include "interfaces/report_manager.hpp" |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 7 | #include "types/report_types.hpp" |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 8 | |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 9 | #include <boost/asio/io_context.hpp> |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 10 | #include <boost/asio/steady_timer.hpp> |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 11 | #include <sdbusplus/asio/object_server.hpp> |
| 12 | |
| 13 | #include <chrono> |
| 14 | #include <memory> |
| 15 | |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 16 | class Report : public interfaces::Report |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 17 | { |
| 18 | public: |
| 19 | Report(boost::asio::io_context& ioc, |
| 20 | const std::shared_ptr<sdbusplus::asio::object_server>& objServer, |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 21 | const std::string& reportName, const std::string& reportingType, |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 22 | const bool emitsReadingsSignal, |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 23 | const bool logToMetricReportsCollection, const Milliseconds period, |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 24 | interfaces::ReportManager& reportManager, |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 25 | interfaces::JsonStorage& reportStorage, |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 26 | std::vector<std::shared_ptr<interfaces::Metric>> metrics); |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 27 | ~Report() = default; |
| 28 | |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 29 | Report(const Report&) = delete; |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 30 | Report(Report&&) = delete; |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 31 | Report& operator=(const Report&) = delete; |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 32 | Report& operator=(Report&&) = delete; |
| 33 | |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 34 | std::string getName() const override |
| 35 | { |
| 36 | return name; |
| 37 | } |
| 38 | |
| 39 | std::string getPath() const override |
| 40 | { |
| 41 | return path; |
| 42 | } |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 43 | |
Wludzik, Jozef | d960e1f | 2021-01-08 09:25:59 +0100 | [diff] [blame] | 44 | void updateReadings() override; |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 45 | bool storeConfiguration() const; |
| 46 | |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 47 | private: |
Krzysztof Grobelny | 85db8bd | 2021-05-28 12:13:23 +0000 | [diff] [blame] | 48 | std::unique_ptr<sdbusplus::asio::dbus_interface> makeReportInterface(); |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 49 | static void timerProc(boost::system::error_code, Report& self); |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 50 | void scheduleTimer(Milliseconds interval); |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 51 | |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 52 | const std::string name; |
| 53 | const std::string path; |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 54 | std::string reportingType; |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 55 | Milliseconds interval; |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 56 | bool emitsReadingsUpdate; |
| 57 | bool logToMetricReportsCollection; |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 58 | ReadingParametersPastVersion readingParametersPastVersion; |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 59 | ReadingParameters readingParameters; |
Krzysztof Grobelny | 85db8bd | 2021-05-28 12:13:23 +0000 | [diff] [blame] | 60 | bool persistency = false; |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 61 | Readings cachedReadings = {}; |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 62 | Readings readings = {}; |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 63 | std::shared_ptr<sdbusplus::asio::object_server> objServer; |
| 64 | std::unique_ptr<sdbusplus::asio::dbus_interface> reportIface; |
| 65 | std::unique_ptr<sdbusplus::asio::dbus_interface> deleteIface; |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 66 | std::vector<std::shared_ptr<interfaces::Metric>> metrics; |
| 67 | boost::asio::steady_timer timer; |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 68 | |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 69 | interfaces::JsonStorage::FilePath fileName; |
| 70 | interfaces::JsonStorage& reportStorage; |
| 71 | |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 72 | public: |
| 73 | static constexpr const char* reportIfaceName = |
| 74 | "xyz.openbmc_project.Telemetry.Report"; |
| 75 | static constexpr const char* reportDir = |
| 76 | "/xyz/openbmc_project/Telemetry/Reports/"; |
| 77 | static constexpr const char* deleteIfaceName = |
| 78 | "xyz.openbmc_project.Object.Delete"; |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 79 | static constexpr size_t reportVersion = 4; |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 80 | }; |