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