blob: d5653b2d304dfb6330685b3d06131350e9c156a9 [file] [log] [blame]
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +02001#pragma once
2
Wludzik, Jozefe2362792020-10-27 17:23:55 +01003#include "interfaces/json_storage.hpp"
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +02004#include "interfaces/report.hpp"
5#include "interfaces/report_factory.hpp"
6#include "interfaces/report_manager.hpp"
Szymon Dompkeb4ef22e2022-02-07 15:15:12 +01007#include "interfaces/trigger_manager.hpp"
Szymon Dompkee28aa532021-10-27 12:33:12 +02008#include "report.hpp"
Wludzik, Jozefcb88cfd2020-09-28 16:38:57 +02009
Karol Niczyj32859b62021-05-19 10:20:46 +020010#include <systemd/sd-bus-protocol.h>
11
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020012#include <sdbusplus/asio/object_server.hpp>
13
14#include <chrono>
15#include <memory>
Wludzik, Jozefbc766b42020-12-08 16:06:22 +010016#include <string>
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020017#include <vector>
18
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020019class ReportManager : public interfaces::ReportManager
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020020{
21 public:
22 ReportManager(
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020023 std::unique_ptr<interfaces::ReportFactory> reportFactory,
Wludzik, Jozefe2362792020-10-27 17:23:55 +010024 std::unique_ptr<interfaces::JsonStorage> reportStorage,
Krzysztof Grobelnye6d48872022-02-08 13:41:30 +010025 const std::shared_ptr<sdbusplus::asio::object_server>& objServer);
Wludzik, Jozefcb88cfd2020-09-28 16:38:57 +020026 ~ReportManager() = default;
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020027
Krzysztof Grobelny31db7f72021-12-21 12:26:22 +010028 ReportManager(const ReportManager&) = delete;
Wludzik, Jozefcb88cfd2020-09-28 16:38:57 +020029 ReportManager(ReportManager&&) = delete;
Krzysztof Grobelny31db7f72021-12-21 12:26:22 +010030 ReportManager& operator=(const ReportManager&) = delete;
Wludzik, Jozefcb88cfd2020-09-28 16:38:57 +020031 ReportManager& operator=(ReportManager&&) = delete;
32
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020033 void removeReport(const interfaces::Report* report) override;
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020034
35 private:
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020036 std::unique_ptr<interfaces::ReportFactory> reportFactory;
Wludzik, Jozefe2362792020-10-27 17:23:55 +010037 std::unique_ptr<interfaces::JsonStorage> reportStorage;
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020038 std::shared_ptr<sdbusplus::asio::object_server> objServer;
Wludzik, Jozefcb88cfd2020-09-28 16:38:57 +020039 std::unique_ptr<sdbusplus::asio::dbus_interface> reportManagerIface;
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020040 std::vector<std::unique_ptr<interfaces::Report>> reports;
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020041
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +000042 void verifyAddReport(
Krzysztof Grobelnyb8cc78d2021-11-29 15:54:53 +010043 const std::string& reportId, const std::string& reportName,
44 const ReportingType reportingType, Milliseconds interval,
Ankita Vilas Gawadecd5b0b72022-01-20 20:55:04 +000045 const ReportUpdates reportUpdates, const uint64_t appendLimit,
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +000046 const std::vector<LabeledMetricParameters>& readingParams);
Lukasz Kazmierczak7e098e92021-09-16 15:59:56 +020047 interfaces::Report& addReport(
Krzysztof Grobelnyb8cc78d2021-11-29 15:54:53 +010048 boost::asio::yield_context& yield, const std::string& reportId,
49 const std::string& reportName, const ReportingType reportingType,
Krzysztof Grobelny51497a02021-11-09 14:56:22 +010050 const std::vector<ReportAction>& reportActions, Milliseconds interval,
51 const uint64_t appendLimit, const ReportUpdates reportUpdates,
Lukasz Kazmierczak7e098e92021-09-16 15:59:56 +020052 ReadingParameters metricParams, const bool enabled);
Krzysztof Grobelny493e62e2022-02-14 10:55:50 +010053 interfaces::Report&
54 addReport(const std::string& reportId, const std::string& reportName,
55 const ReportingType reportingType,
56 const std::vector<ReportAction>& reportActions,
57 Milliseconds interval, const uint64_t appendLimit,
58 const ReportUpdates reportUpdates,
59 std::vector<LabeledMetricParameters> metricParams,
60 const bool enabled, Readings);
Wludzik, Jozefe2362792020-10-27 17:23:55 +010061 void loadFromPersistent();
62
Wludzik, Jozefcb88cfd2020-09-28 16:38:57 +020063 public:
Wludzik, Jozef503c1582020-12-11 14:48:01 +010064 static constexpr size_t maxReports{TELEMETRY_MAX_REPORTS};
Ankita Vilas Gawadecd5b0b72022-01-20 20:55:04 +000065 static constexpr size_t maxNumberMetrics{TELEMETRY_MAX_READING_PARAMS};
Krzysztof Grobelnyb8cc78d2021-11-29 15:54:53 +010066 static constexpr size_t maxReportIdLength{
Szymon Dompkee28aa532021-10-27 12:33:12 +020067 TELEMETRY_MAX_DBUS_PATH_LENGTH -
68 std::string_view(Report::reportDir).length()};
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +000069 static constexpr Milliseconds minInterval{TELEMETRY_MIN_INTERVAL};
Ankita Vilas Gawadecd5b0b72022-01-20 20:55:04 +000070 static constexpr size_t maxAppendLimit{TELEMETRY_MAX_APPEND_LIMIT};
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020071 static constexpr const char* reportManagerIfaceName =
72 "xyz.openbmc_project.Telemetry.ReportManager";
73 static constexpr const char* reportManagerPath =
74 "/xyz/openbmc_project/Telemetry/Reports";
Krzysztof Grobelnya950e422021-12-31 13:49:00 +010075 static constexpr const char* reportNameDefault = "Report";
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020076};