Adjust LogToRedfish trigger action to DMTF standard
This patch modifies messages sent to Redfish event log to be compliant
with message registry schema [1].
Tested:
On platform, with corresponding bmcweb patch [2]. Verified that messages
appearing in Redfish event log are compliant with schema. UTs passed.
[1] https://redfish.dmtf.org/registries/Telemetry.1.0.0.json
[2] https://gerrit.openbmc.org/c/openbmc/bmcweb/+/72315
Change-Id: Ide3d5a13e5be077806df6398c5f51da41f7a7922
Signed-off-by: Michal Orzel <michalx.orzel@intel.com>
diff --git a/src/trigger_actions.cpp b/src/trigger_actions.cpp
index ef4a50b..9466b77 100644
--- a/src/trigger_actions.cpp
+++ b/src/trigger_actions.cpp
@@ -64,19 +64,40 @@
phosphor::logging::log<phosphor::logging::level::INFO>(msg.c_str());
}
-const char* LogToRedfishEventLog::getRedfishMessageId() const
+const char* LogToRedfishEventLog::getRedfishMessageId(const double value) const
{
- switch (type)
+ std::string direction(getDirection(value, threshold));
+
+ if (direction == "decreasing")
{
- case ::numeric::Type::upperCritical:
- return redfish_message_ids::TriggerNumericCritical;
- case ::numeric::Type::lowerCritical:
- return redfish_message_ids::TriggerNumericCritical;
- case ::numeric::Type::upperWarning:
- return redfish_message_ids::TriggerNumericWarning;
- case ::numeric::Type::lowerWarning:
- return redfish_message_ids::TriggerNumericWarning;
+ switch (type)
+ {
+ case ::numeric::Type::upperCritical:
+ return redfish_message_ids::TriggerNumericBelowUpperCritical;
+ case ::numeric::Type::lowerCritical:
+ return redfish_message_ids::TriggerNumericBelowLowerCritical;
+ case ::numeric::Type::upperWarning:
+ return redfish_message_ids::TriggerNumericReadingNormal;
+ case ::numeric::Type::lowerWarning:
+ return redfish_message_ids::TriggerNumericBelowLowerWarning;
+ }
}
+
+ if (direction == "increasing")
+ {
+ switch (type)
+ {
+ case ::numeric::Type::upperCritical:
+ return redfish_message_ids::TriggerNumericAboveUpperCritical;
+ case ::numeric::Type::lowerCritical:
+ return redfish_message_ids::TriggerNumericAboveLowerCritical;
+ case ::numeric::Type::upperWarning:
+ return redfish_message_ids::TriggerNumericAboveUpperWarning;
+ case ::numeric::Type::lowerWarning:
+ return redfish_message_ids::TriggerNumericReadingNormal;
+ }
+ }
+
throw std::runtime_error("Invalid type");
}
@@ -87,18 +108,26 @@
const TriggerValue triggerValue)
{
double value = std::get<double>(triggerValue);
- std::string thresholdName = ::numeric::typeToString(type);
- auto direction = getDirection(value, threshold);
- auto timestampStr = timestampToString(timestamp);
+ auto messageId = getRedfishMessageId(value);
- phosphor::logging::log<phosphor::logging::level::INFO>(
- "Logging numeric trigger action to Redfish Event Log.",
- phosphor::logging::entry("REDFISH_MESSAGE_ID=%s",
- getRedfishMessageId()),
- phosphor::logging::entry("REDFISH_MESSAGE_ARGS=%s,%s,%s,%f,%s,%s",
- thresholdName.c_str(), triggerId.c_str(),
- sensorName.c_str(), value, direction,
- timestampStr.c_str()));
+ if (messageId == redfish_message_ids::TriggerNumericReadingNormal)
+ {
+ phosphor::logging::log<phosphor::logging::level::INFO>(
+ "Logging numeric trigger action to Redfish Event Log.",
+ phosphor::logging::entry("REDFISH_MESSAGE_ID=%s", messageId),
+ phosphor::logging::entry("REDFISH_MESSAGE_ARGS=%s,%f,%s",
+ sensorName.c_str(), value,
+ triggerId.c_str()));
+ }
+ else
+ {
+ phosphor::logging::log<phosphor::logging::level::INFO>(
+ "Logging numeric trigger action to Redfish Event Log.",
+ phosphor::logging::entry("REDFISH_MESSAGE_ID=%s", messageId),
+ phosphor::logging::entry("REDFISH_MESSAGE_ARGS=%s,%f,%f,%s",
+ sensorName.c_str(), value, threshold,
+ triggerId.c_str()));
+ }
}
void fillActions(
@@ -157,20 +186,6 @@
phosphor::logging::log<phosphor::logging::level::INFO>(msg.c_str());
}
-const char* LogToRedfishEventLog::getRedfishMessageId() const
-{
- switch (severity)
- {
- case ::discrete::Severity::ok:
- return redfish_message_ids::TriggerDiscreteOK;
- case ::discrete::Severity::warning:
- return redfish_message_ids::TriggerDiscreteWarning;
- case ::discrete::Severity::critical:
- return redfish_message_ids::TriggerDiscreteCritical;
- }
- throw std::runtime_error("Invalid severity");
-}
-
void LogToRedfishEventLog::commit(const std::string& triggerId,
const ThresholdName thresholdNameIn,
const std::string& sensorName,
@@ -178,16 +193,15 @@
const TriggerValue triggerValue)
{
auto value = std::get<std::string>(triggerValue);
- auto timestampStr = timestampToString(timestamp);
phosphor::logging::log<phosphor::logging::level::INFO>(
"Logging discrete trigger action to Redfish Event Log.",
- phosphor::logging::entry("REDFISH_MESSAGE_ID=%s",
- getRedfishMessageId()),
- phosphor::logging::entry("REDFISH_MESSAGE_ARGS=%s,%s,%s,%s,%s",
- thresholdNameIn->get().c_str(),
- triggerId.c_str(), sensorName.c_str(),
- value.c_str(), timestampStr.c_str()));
+ phosphor::logging::entry(
+ "REDFISH_MESSAGE_ID=%s",
+ redfish_message_ids::TriggerDiscreteConditionMet),
+ phosphor::logging::entry("REDFISH_MESSAGE_ARGS=%s,%s,%s",
+ sensorName.c_str(), value.c_str(),
+ triggerId.c_str()));
}
void fillActions(
@@ -210,7 +224,7 @@
case TriggerAction::LogToRedfishEventLog:
{
actionsIf.emplace_back(
- std::make_unique<LogToRedfishEventLog>(severity));
+ std::make_unique<LogToRedfishEventLog>());
break;
}
case TriggerAction::UpdateReport:
@@ -247,16 +261,15 @@
const TriggerValue triggerValue)
{
auto value = triggerValueToString(triggerValue);
- auto timestampStr = timestampToString(timestamp);
phosphor::logging::log<phosphor::logging::level::INFO>(
"Logging onChange discrete trigger action to Redfish Event Log.",
- phosphor::logging::entry("REDFISH_MESSAGE_ID=%s",
- redfish_message_ids::TriggerDiscreteOK),
- phosphor::logging::entry("REDFISH_MESSAGE_ARGS=%s,%s,%s,%s,%s",
- "OnChange", triggerId.c_str(),
+ phosphor::logging::entry(
+ "REDFISH_MESSAGE_ID=%s",
+ redfish_message_ids::TriggerDiscreteConditionMet),
+ phosphor::logging::entry("REDFISH_MESSAGE_ARGS=%s,%s,%s",
sensorName.c_str(), value.c_str(),
- timestampStr.c_str()));
+ triggerId.c_str()));
}
void fillActions(
diff --git a/src/trigger_actions.hpp b/src/trigger_actions.hpp
index 14f6294..3e2c33c 100644
--- a/src/trigger_actions.hpp
+++ b/src/trigger_actions.hpp
@@ -10,15 +10,22 @@
namespace redfish_message_ids
{
-constexpr const char* TriggerNumericWarning =
- "OpenBMC.0.1.TriggerNumericWarning";
-constexpr const char* TriggerNumericCritical =
- "OpenBMC.0.1.TriggerNumericCritical";
-constexpr const char* TriggerDiscreteOK = "OpenBMC.0.1.TriggerDiscreteOK";
-constexpr const char* TriggerDiscreteWarning =
- "OpenBMC.0.1.TriggerDiscreteWarning";
-constexpr const char* TriggerDiscreteCritical =
- "OpenBMC.0.1.TriggerDiscreteCritical";
+constexpr const char* TriggerDiscreteConditionMet =
+ "Telemetry.1.0.TriggerDiscreteConditionMet";
+constexpr const char* TriggerNumericAboveLowerCritical =
+ "Telemetry.1.0.TriggerNumericAboveLowerCritical";
+constexpr const char* TriggerNumericAboveUpperCritical =
+ "Telemetry.1.0.TriggerNumericAboveUpperCritical";
+constexpr const char* TriggerNumericAboveUpperWarning =
+ "Telemetry.1.0.TriggerNumericAboveUpperWarning";
+constexpr const char* TriggerNumericBelowLowerCritical =
+ "Telemetry.1.0.TriggerNumericBelowLowerCritical";
+constexpr const char* TriggerNumericBelowLowerWarning =
+ "Telemetry.1.0.TriggerNumericBelowLowerWarning";
+constexpr const char* TriggerNumericBelowUpperCritical =
+ "Telemetry.1.0.TriggerNumericBelowUpperCritical";
+constexpr const char* TriggerNumericReadingNormal =
+ "Telemetry.1.0.TriggerNumericReadingNormal";
} // namespace redfish_message_ids
namespace numeric
@@ -53,7 +60,7 @@
const ::numeric::Type type;
const double threshold;
- const char* getRedfishMessageId() const;
+ const char* getRedfishMessageId(const double value) const;
};
void fillActions(
@@ -81,18 +88,11 @@
class LogToRedfishEventLog : public interfaces::TriggerAction
{
public:
- explicit LogToRedfishEventLog(::discrete::Severity severity) :
- severity(severity)
- {}
+ explicit LogToRedfishEventLog() {}
void commit(const std::string& triggerId, const ThresholdName thresholdName,
const std::string& sensorName, const Milliseconds timestamp,
const TriggerValue value) override;
-
- private:
- const ::discrete::Severity severity;
-
- const char* getRedfishMessageId() const;
};
void fillActions(