summaryrefslogtreecommitdiffstats
path: root/monitor
diff options
context:
space:
mode:
Diffstat (limited to 'monitor')
-rw-r--r--monitor/fan.cpp32
-rw-r--r--monitor/fan.hpp5
-rwxr-xr-xmonitor/gen-fan-monitor-defs.py2
-rw-r--r--monitor/types.hpp2
4 files changed, 28 insertions, 13 deletions
diff --git a/monitor/fan.cpp b/monitor/fan.cpp
index 014080d..6df98e5 100644
--- a/monitor/fan.cpp
+++ b/monitor/fan.cpp
@@ -36,7 +36,8 @@ Fan::Fan(Mode mode,
const FanDefinition& def) :
_bus(bus),
_name(std::get<fanNameField>(def)),
- _deviation(std::get<fanDeviationField>(def)),
+ _deviation((std::get<fanDeviationField>(def) < 0)?abs(std::get<fanDeviationField>(def)):std::get<fanDeviationField>(def)),
+ _deviationIsMinRPM((std::get<fanDeviationField>(def) < 0)?true:false),
_numSensorFailsForNonFunc(std::get<numSensorFailsForNonfuncField>(def)),
_trustManager(trust)
{
@@ -168,17 +169,26 @@ bool Fan::outOfRange(const TachSensor& sensor)
auto factor = sensor.getFactor();
auto offset = sensor.getOffset();
- uint64_t min = target * (100 - _deviation) / 100;
- uint64_t max = target * (100 + _deviation) / 100;
-
- // TODO: openbmc/openbmc#2937 enhance this function
- // either by making it virtual, or by predefining different
- // outOfRange ops and selecting by yaml config
- min = min * factor + offset;
- max = max * factor + offset;
- if ((actual < min) || (actual > max))
+ if (_deviationIsMinRPM)
{
- return true;
+ if (actual < _deviation)
+ {
+ return true;
+ }
+ }
+ else {
+ uint64_t min = target * (100 - _deviation) / 100;
+ uint64_t max = target * (100 + _deviation) / 100;
+
+ // TODO: openbmc/openbmc#2937 enhance this function
+ // either by making it virtual, or by predefining different
+ // outOfRange ops and selecting by yaml config
+ min = min * factor + offset;
+ max = max * factor + offset;
+ if ((actual < min) || (actual > max))
+ {
+ return true;
+ }
}
return false;
diff --git a/monitor/fan.hpp b/monitor/fan.hpp
index 663e27e..5615a3a 100644
--- a/monitor/fan.hpp
+++ b/monitor/fan.hpp
@@ -176,6 +176,11 @@ class Fan
const size_t _deviation;
/**
+ * @brief True if deviation indicates minimum absolute RPM
+ */
+ bool _deviationIsMinRPM;
+
+ /**
* The number of sensors that must be nonfunctional at the
* same time in order for the fan to be set to nonfunctional
* in the inventory.
diff --git a/monitor/gen-fan-monitor-defs.py b/monitor/gen-fan-monitor-defs.py
index de25fef..fdb3b89 100755
--- a/monitor/gen-fan-monitor-defs.py
+++ b/monitor/gen-fan-monitor-defs.py
@@ -133,7 +133,7 @@ if __name__ == '__main__':
#Do some minor input validation
for fan in monitor_data.get('fans', {}):
- if ((fan['deviation'] < 0) or (fan['deviation'] > 100)):
+ if (fan['deviation'] > 100):
sys.exit("Invalid deviation value " + str(fan['deviation']))
output_file = os.path.join(args.output_dir, "fan_monitor_defs.cpp")
diff --git a/monitor/types.hpp b/monitor/types.hpp
index 9a7b1fa..53834b0 100644
--- a/monitor/types.hpp
+++ b/monitor/types.hpp
@@ -57,7 +57,7 @@ constexpr auto conditionField = 6;
using FanDefinition = std::tuple<std::string,
size_t,
size_t,
- size_t,
+ ssize_t,
size_t,
std::vector<SensorDefinition>,
std::experimental::optional<Condition>>;
OpenPOWER on IntegriCloud