pulse_event_monitor: add host id in DC power on/off log
Current DC power on/off log does not contains host id, in multi-host
system, it hard to identify the event log is from which host via
redfish.
Add host id into event log message for helping identify the log comes
from which host.
Tested result:
```
{
"@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/2",
"@odata.type": "#LogEntry.v1_9_0.LogEntry",
"AdditionalDataURI": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/2/attachment",
"Created": "2024-03-18T16:28:09.708+00:00",
"EntryType": "Event",
"Id": "2",
"Message": "Host3 system DC power is off",
"Modified": "2024-03-18T16:28:09.708+00:00",
"Name": "System Event Log Entry",
"Resolved": false,
"Severity": "OK"
}
```
Change-Id: I4b2b3cb17f8aaf65f0bea7e359f8d5a83f2674bb
Signed-off-by: Potin Lai <potin.lai@quantatw.com>
diff --git a/include/pulse_event_monitor.hpp b/include/pulse_event_monitor.hpp
index d2c589a..0ad6b38 100644
--- a/include/pulse_event_monitor.hpp
+++ b/include/pulse_event_monitor.hpp
@@ -27,6 +27,7 @@
boost::container::flat_map<std::string, std::variant<std::string>>
propertiesChanged;
msg.read(thresholdInterface, propertiesChanged);
+ std::string objPath = msg.get_path();
if (propertiesChanged.empty())
{
@@ -45,18 +46,25 @@
if (event == "CurrentHostState")
{
- std::string journalMsg;
+ std::string journalMsg = "Host";
std::string redfishMsgId;
+ std::string_view hostObjPathPrefix =
+ "/xyz/openbmc_project/state/host";
+
+ if (objPath.starts_with(hostObjPathPrefix))
+ {
+ journalMsg += objPath.erase(0, hostObjPathPrefix.size());
+ }
if (*variant == "xyz.openbmc_project.State.Host.HostState.Off")
{
- journalMsg = "Host system DC power is off";
+ journalMsg += " system DC power is off";
redfishMsgId = "OpenBMC.0.1.DCPowerOff";
}
else if (*variant ==
"xyz.openbmc_project.State.Host.HostState.Running")
{
- journalMsg = "Host system DC power is on";
+ journalMsg += " system DC power is on";
redfishMsgId = "OpenBMC.0.1.DCPowerOn";
}
else