monitor: Allowing ignoring fan FRU func status
Make the 'num_sensors_nonfunc_for_fan_nonfunc' JSON entry be optional,
and if it isn't present then don't set the parent fan FRU inventory
object functional state when the tach sensor functional states change.
This is necessary because on some systems some other entity will be
managing the FRU level functional state.
This also adds a trace when the tach sensor functional state changes,
since if the FRU functional state updating is turned off then the
existing traces won't appear.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I1be9cc335c15a78d342e2e7ea4e5108a66d29de3
diff --git a/monitor/json_parser.cpp b/monitor/json_parser.cpp
index bd239c6..1c06f01 100644
--- a/monitor/json_parser.cpp
+++ b/monitor/json_parser.cpp
@@ -172,16 +172,14 @@
{
if (!fan.contains("inventory") ||
!fan.contains("allowed_out_of_range_time") ||
- !fan.contains("deviation") ||
- !fan.contains("num_sensors_nonfunc_for_fan_nonfunc") ||
- !fan.contains("sensors"))
+ !fan.contains("deviation") || !fan.contains("sensors"))
{
// Log error on missing required parameters
log<level::ERR>(
"Missing required fan monitor definition parameters",
entry("REQUIRED_PARAMETERS=%s",
"{inventory, allowed_out_of_range_time, deviation, "
- "num_sensors_nonfunc_for_fan_nonfunc, sensors}"));
+ "sensors}"));
throw std::runtime_error(
"Missing required fan monitor definition parameters");
}
@@ -202,6 +200,16 @@
monitorDelay = fan["monitor_start_delay"].get<size_t>();
}
+ // num_sensors_nonfunc_for_fan_nonfunc is optional and defaults
+ // to zero if not present, meaning the code will not set the
+ // parent fan to nonfunctional based on sensors.
+ size_t nonfuncSensorsCount = 0;
+ if (fan.contains("num_sensors_nonfunc_for_fan_nonfunc"))
+ {
+ nonfuncSensorsCount =
+ fan["num_sensors_nonfunc_for_fan_nonfunc"].get<size_t>();
+ }
+
// Handle optional conditions
auto cond = std::optional<Condition>();
if (fan.contains("condition"))
@@ -235,8 +243,7 @@
fanDefs.emplace_back(
std::tuple(fan["inventory"].get<std::string>(), funcDelay,
fan["allowed_out_of_range_time"].get<size_t>(),
- fan["deviation"].get<size_t>(),
- fan["num_sensors_nonfunc_for_fan_nonfunc"].get<size_t>(),
+ fan["deviation"].get<size_t>(), nonfuncSensorsCount,
monitorDelay, sensorDefs, cond));
}