monitor: Event logs for nonfunc fan sensors
This commit adds the code to create event logs calling out the fan when
fan sensors have been nonfunctional for a certain amount of time.
This functionality is configured in the JSON, and will only be enabled
if the 'fault_handling' JSON section is present. It uses the following
new JSON parameters:
nonfunc_rotor_error_delay (per fan):
This says how many seconds a fan sensor must be nonfunctional before the
event log will be created.
num_nonfunc_rotors_before_error (under fault_handling):
This specifies how many nonfunctional fan rotors there must be at the
same time before an event log with an error severity is created for the
rotor. When there are fewer than this many nonfunctional rotors, then
event logs with an informational severity will be created.
A new FanError class is used to create the event logs. It adds the
Logger output as FFDC, plus any JSON data that is passed in with the
commit() API. It uses CALLOUT_INVENTORY_PATH in the AdditionalData
property to specify the faulted fan FRU.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I365114357580b4f38ec943a769c1ce7f695b51ab
diff --git a/monitor/tach_sensor.hpp b/monitor/tach_sensor.hpp
index 27e0626..814df69 100644
--- a/monitor/tach_sensor.hpp
+++ b/monitor/tach_sensor.hpp
@@ -79,12 +79,16 @@
* @param[in] factor - the factor of the sensor target
* @param[in] offset - the offset of the sensor target
* @param[in] timeout - Normal timeout value to use
+ * @param[in] errorDelay - Delay in seconds before creating an error
+ * or std::nullopt if no errors.
+ *
* @param[in] event - Event loop reference
*/
TachSensor(Mode mode, sdbusplus::bus::bus& bus, Fan& fan,
const std::string& id, bool hasTarget, size_t funcDelay,
const std::string& interface, double factor, int64_t offset,
- size_t timeout, const sdeventplus::Event& event);
+ size_t timeout, const std::optional<size_t>& errorDelay,
+ const sdeventplus::Event& event);
/**
* @brief Returns the target speed value
@@ -186,6 +190,20 @@
return _name;
};
+ /**
+ * @brief Says if the error timer is running
+ *
+ * @return bool - If the timer is running
+ */
+ bool errorTimerRunning() const
+ {
+ if (_errorTimer && _errorTimer->isEnabled())
+ {
+ return true;
+ }
+ return false;
+ }
+
private:
/**
* @brief Returns the match string to use for matching
@@ -306,6 +324,24 @@
* @brief The match object for the Target properties changed signal
*/
std::unique_ptr<sdbusplus::server::match::match> targetSignal;
+
+ /**
+ * @brief The number of seconds to wait between a sensor being set
+ * to nonfunctional and creating an error for it.
+ *
+ * If std::nullopt, no errors will be created.
+ */
+ const std::optional<size_t> _errorDelay;
+
+ /**
+ * @brief The timer that uses _errorDelay. When it expires an error
+ * will be created for a faulted fan sensor (rotor).
+ *
+ * If _errorDelay is std::nullopt, then this won't be created.
+ */
+ std::unique_ptr<
+ sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>>
+ _errorTimer;
};
} // namespace monitor