monitor: Track fan health in the System object
To prepare for being able to power off the system based on missing fans
or nonfunctional fan sensors, put a global view of this health for all
fans in the System object. This requires now keeping track of fan
presence.
This information is stored in a map based on the fan name. It is done
this way, as opposed to just always calling present/functional APIs on
the Fan objects, so that the code that will be using this information
can be tested in isolation without the System or Fan objects.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: Ieb1d4003bd13cebc806fd06f0064c63ea8ac6180
diff --git a/monitor/system.hpp b/monitor/system.hpp
index 9757082..7c424a2 100644
--- a/monitor/system.hpp
+++ b/monitor/system.hpp
@@ -62,6 +62,15 @@
void sighupHandler(sdeventplus::source::Signal&,
const struct signalfd_siginfo*);
+ /**
+ * @brief Called from the fan when it changes either
+ * present or functional status to update the
+ * fan health map.
+ *
+ * @param[in] fan - The fan that changed
+ */
+ void fanStatusChange(const Fan& fan);
+
private:
/* The mode of fan monitor */
Mode _mode;
@@ -79,6 +88,11 @@
std::vector<std::unique_ptr<Fan>> _fans;
/**
+ * @brief The latest health of all the fans
+ */
+ FanHealth _fanHealth;
+
+ /**
* @brief Retrieve the configured trust groups
*
* @param[in] jsonObj - JSON object to parse from
@@ -109,6 +123,13 @@
* @param[in] fanDefs - list of fan definitions to create fans monitored
*/
void setFans(const std::vector<FanDefinition>& fanDefs);
+
+ /**
+ * @brief Updates the fan health map entry for the fan passed in
+ *
+ * @param[in] fan - The fan to update the health map with
+ */
+ void updateFanHealth(const Fan& fan);
};
} // namespace phosphor::fan::monitor