monitor: Add thermal fault alert D-Bus property
Add a new property to alert of a thermal fault. In this context, it
means an imminent power off due to fan faults. On certain IBM systems
it will be used as a mechanism to alert the host of the power off when
the 'epow_power_off' power off rule is used.
Service: xyz.openbmc_project.Thermal.Alert
Path: /xyz/openbmc_project/alerts/thermal_fault_alert
Interface: xyz.openbmc_project.Object.Enable
Property: Enabled
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I0531de9ce40b6148244fda18a20e144bad85d830
diff --git a/monitor/main.cpp b/monitor/main.cpp
index 93a5e1d..ae6d034 100644
--- a/monitor/main.cpp
+++ b/monitor/main.cpp
@@ -77,6 +77,8 @@
std::bind(&System::sighupHandler,
&system, std::placeholders::_1,
std::placeholders::_2));
+
+ bus.request_name(THERMAL_ALERT_BUSNAME);
#endif
#ifndef MONITOR_USE_JSON
diff --git a/monitor/system.cpp b/monitor/system.cpp
index 229eca8..dbb9b73 100644
--- a/monitor/system.cpp
+++ b/monitor/system.cpp
@@ -24,6 +24,8 @@
#include "json_parser.hpp"
#endif
+#include "config.h"
+
#include <nlohmann/json.hpp>
#include <phosphor-logging/log.hpp>
#include <sdbusplus/bus.hpp>
@@ -41,11 +43,12 @@
System::System(Mode mode, sdbusplus::bus::bus& bus,
const sdeventplus::Event& event) :
_mode(mode),
- _bus(bus), _event(event)
-{
- _powerState = std::make_unique<PGoodState>(
+ _bus(bus), _event(event),
+ _powerState(std::make_unique<PGoodState>(
bus, std::bind(std::mem_fn(&System::powerStateChanged), this,
- std::placeholders::_1));
+ std::placeholders::_1))),
+ _thermalAlert(bus, THERMAL_ALERT_OBJPATH)
+{
json jsonObj = json::object();
#ifdef MONITOR_USE_JSON
@@ -212,6 +215,8 @@
}
else
{
+ _thermalAlert.enabled(false);
+
// Cancel any in-progress power off actions
std::for_each(_powerOffRules.begin(), _powerOffRules.end(),
[this](auto& rule) { rule->cancel(); });
diff --git a/monitor/system.hpp b/monitor/system.hpp
index 744c775..a0030da 100644
--- a/monitor/system.hpp
+++ b/monitor/system.hpp
@@ -146,6 +146,11 @@
std::unique_ptr<FanError> _lastError;
/**
+ * @brief The thermal alert D-Bus object
+ */
+ ThermalAlertObject _thermalAlert;
+
+ /**
* @brief Captures tach sensor data as JSON for use in
* fan fault and fan missing event logs.
*
diff --git a/monitor/types.hpp b/monitor/types.hpp
index 609199a..a7f61d1 100644
--- a/monitor/types.hpp
+++ b/monitor/types.hpp
@@ -5,6 +5,7 @@
#include <nlohmann/json.hpp>
#include <phosphor-logging/log.hpp>
+#include <xyz/openbmc_project/Object/Enable/server.hpp>
#include <functional>
#include <optional>
@@ -19,6 +20,14 @@
namespace monitor
{
+template <typename... T>
+using ServerObject = typename sdbusplus::server::object::object<T...>;
+
+using ObjectEnableInterface =
+ sdbusplus::xyz::openbmc_project::Object::server::Enable;
+
+using ThermalAlertObject = ServerObject<ObjectEnableInterface>;
+
constexpr auto propObj = 0;
constexpr auto propIface = 1;
constexpr auto propName = 2;