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