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