monitor: Use the number of failed tach sensors at startup
When marking a fan nonfunctional due to its tach sensors failing
to be read from dbus, a check against the configured number of
sensors that should result in the fan being marked as nonfunctional
should be checked.
Tested:
Run phosphor-fan-monitor --monitor in witherspoon qemu,
when the number of failed tach sensor is larger than the
configured _numSensorFailsForNonFunc then mark the
associated fan as nonfunctional.
Change-Id: I6ff97b9aae4279d6ce402d3aecda087d45dfa318
Signed-off-by: Jolie Ku <jolie_ku@wistron.com>
diff --git a/monitor/fan.cpp b/monitor/fan.cpp
index 4b84fff..3b12905 100644
--- a/monitor/fan.cpp
+++ b/monitor/fan.cpp
@@ -61,8 +61,12 @@
}
catch (InvalidSensorError& e)
{
- // mark associated fan as nonfunctional
- updateInventory(false);
+ // Count the number of failed tach sensors
+ if (++_numFailedSensor >= _numSensorFailsForNonFunc)
+ {
+ // Mark associated fan as nonfunctional
+ updateInventory(false);
+ }
}
}