monitor: Mark a fan with a missing dbus sensor as nonfunctional
When fan monitor starts up and retrieves the tach feedback
sensor values from dbus, the associated fan should be marked
nonfunctional when the sensor value is not found on dbus.
Tested:
run phosphor-fan-monitor --monitor will mark missing
tach sensor and associated fan as non-functional upon
poweron in witherspoon qemu
Change-Id: I3be24504223d3bd9efe8c4306548d6cca93d8224
Signed-off-by: Jolie Ku <jolie_ku@wistron.com>
diff --git a/monitor/tach_sensor.cpp b/monitor/tach_sensor.cpp
index 42b826f..078b213 100644
--- a/monitor/tach_sensor.cpp
+++ b/monitor/tach_sensor.cpp
@@ -19,6 +19,8 @@
#include "sdbusplus.hpp"
#include "utility.hpp"
+#include <fmt/format.h>
+
#include <phosphor-logging/elog.hpp>
#include <phosphor-logging/log.hpp>
@@ -92,8 +94,11 @@
}
catch (std::exception& e)
{
- log<level::INFO>("Not monitoring a tach sensor",
- entry("SENSOR=%s", _name.c_str()));
+ log<level::ERR>(
+ fmt::format("Failed to retrieve tach sensor {}", _name)
+ .c_str());
+ // mark tach sensor as nonfunctional
+ setFunctional(false);
throw InvalidSensorError();
}