monitor: Event logs for missing fans
This commit adds the code to create event logs calling out the fan when
it has been missing for a certain amount of time.
This is basically identical to the functionality that the fan presence
application in this repo provides, but with it in this application all
fan errors are created from the same place. This will become important
when there is a power off due to a fan missing and the error for that
needs to be re-committed at power off time so it can be shown as the
cause of the power off.
The functionality is configured in the JSON:
fan_missing_error_delay:
Defines the number of seconds a fan must be missing with power on before
an error will be created. If this isn't present in the JSON, then
errors will not be created at all.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I76de9d8d1bf6e283560b1ce46e70f84522e2d708
diff --git a/monitor/fan.hpp b/monitor/fan.hpp
index 187d626..a50bbb5 100644
--- a/monitor/fan.hpp
+++ b/monitor/fan.hpp
@@ -281,6 +281,21 @@
* @brief The current presence state
*/
bool _present = false;
+
+ /**
+ * @brief The number of seconds to wait after a fan is removed before
+ * creating an event log for it. If std::nullopt, then no
+ * event log will be created.
+ */
+ const std::optional<size_t> _fanMissingErrorDelay;
+
+ /**
+ * @brief The timer that uses the _fanMissingErrorDelay timeout,
+ * at the end of which an event log will be created.
+ */
+ std::unique_ptr<
+ sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>>
+ _fanMissingErrorTimer;
};
} // namespace monitor