1b26ff34dSEd Tanous #include "dbus_log_watcher.hpp" 2b26ff34dSEd Tanous 3*2ac69850SEd Tanous #include "dbus_singleton.hpp" 4b26ff34dSEd Tanous #include "dbus_utility.hpp" 5b26ff34dSEd Tanous #include "event_service_manager.hpp" 6b26ff34dSEd Tanous #include "logging.hpp" 7b26ff34dSEd Tanous #include "metric_report.hpp" 8b26ff34dSEd Tanous 9*2ac69850SEd Tanous #include <sdbusplus/bus/match.hpp> 10b26ff34dSEd Tanous #include <sdbusplus/message.hpp> 11b26ff34dSEd Tanous #include <sdbusplus/message/native_types.hpp> 12b26ff34dSEd Tanous 13b26ff34dSEd Tanous #include <algorithm> 14b26ff34dSEd Tanous #include <string> 15b26ff34dSEd Tanous #include <variant> 16b26ff34dSEd Tanous #include <vector> 17b26ff34dSEd Tanous 18b26ff34dSEd Tanous namespace redfish 19b26ff34dSEd Tanous { 20*2ac69850SEd Tanous static void getReadingsForReport(sdbusplus::message_t& msg) 21b26ff34dSEd Tanous { 22b26ff34dSEd Tanous if (msg.is_method_error()) 23b26ff34dSEd Tanous { 24b26ff34dSEd Tanous BMCWEB_LOG_ERROR("TelemetryMonitor Signal error"); 25b26ff34dSEd Tanous return; 26b26ff34dSEd Tanous } 27b26ff34dSEd Tanous 28b26ff34dSEd Tanous sdbusplus::message::object_path path(msg.get_path()); 29b26ff34dSEd Tanous std::string id = path.filename(); 30b26ff34dSEd Tanous if (id.empty()) 31b26ff34dSEd Tanous { 32b26ff34dSEd Tanous BMCWEB_LOG_ERROR("Failed to get Id from path"); 33b26ff34dSEd Tanous return; 34b26ff34dSEd Tanous } 35b26ff34dSEd Tanous 36b26ff34dSEd Tanous std::string interface; 37b26ff34dSEd Tanous dbus::utility::DBusPropertiesMap props; 38b26ff34dSEd Tanous std::vector<std::string> invalidProps; 39b26ff34dSEd Tanous msg.read(interface, props, invalidProps); 40b26ff34dSEd Tanous 41b26ff34dSEd Tanous auto found = std::ranges::find_if(props, [](const auto& x) { 42b26ff34dSEd Tanous return x.first == "Readings"; 43b26ff34dSEd Tanous }); 44b26ff34dSEd Tanous if (found == props.end()) 45b26ff34dSEd Tanous { 46b26ff34dSEd Tanous BMCWEB_LOG_INFO("Failed to get Readings from Report properties"); 47b26ff34dSEd Tanous return; 48b26ff34dSEd Tanous } 49b26ff34dSEd Tanous 50b26ff34dSEd Tanous const telemetry::TimestampReadings* readings = 51b26ff34dSEd Tanous std::get_if<telemetry::TimestampReadings>(&found->second); 52b26ff34dSEd Tanous if (readings == nullptr) 53b26ff34dSEd Tanous { 54b26ff34dSEd Tanous BMCWEB_LOG_INFO("Failed to get Readings from Report properties"); 55b26ff34dSEd Tanous return; 56b26ff34dSEd Tanous } 57b26ff34dSEd Tanous EventServiceManager::sendTelemetryReportToSubs(id, *readings); 58b26ff34dSEd Tanous } 59*2ac69850SEd Tanous 60*2ac69850SEd Tanous const std::string telemetryMatchStr = 61*2ac69850SEd Tanous "type='signal',member='PropertiesChanged'," 62*2ac69850SEd Tanous "interface='org.freedesktop.DBus.Properties'," 63*2ac69850SEd Tanous "arg0=xyz.openbmc_project.Telemetry.Report"; 64*2ac69850SEd Tanous 65*2ac69850SEd Tanous DbusTelemetryMonitor::DbusTelemetryMonitor() : 66*2ac69850SEd Tanous matchTelemetryMonitor(*crow::connections::systemBus, telemetryMatchStr, 67*2ac69850SEd Tanous getReadingsForReport) 68*2ac69850SEd Tanous {} 69b26ff34dSEd Tanous } // namespace redfish 70