Module: check_mk
Branch: master
Commit: be5fbb1e34cbc625553ebf9c717cd4f7fe4e3fde
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=be5fbb1e34cbc6…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Fri Aug 31 13:49:33 2018 +0200
6218 FIX mgmt_ipmi_sensors: Wrong battery / power supply WARN state
Due to a bug in pyghmi (
https://bugs.launchpad.net/pyghmi/+bug/1790120)
a WARN state was reported for sensors of type "battery" and "power
supply".
A workaroud has been added to mitigate this problem.
FEED-943
Change-Id: I9af116870b977706305ab9ae6253b8c0d61d7893
---
.werks/6218 | 12 ++++++++++++
checks/ipmi_sensors.include | 8 ++++----
cmk_base/data_sources/ipmi.py | 34 ++++++++++++++++++++++++++++++++++
3 files changed, 50 insertions(+), 4 deletions(-)
diff --git a/.werks/6218 b/.werks/6218
new file mode 100644
index 0000000..81c0695
--- /dev/null
+++ b/.werks/6218
@@ -0,0 +1,12 @@
+Title: mgmt_ipmi_sensors: Wrong battery / power supply WARN state
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1535715823
+Class: fix
+
+Due to a bug in pyghmi (
https://bugs.launchpad.net/pyghmi/+bug/1790120)
+a WARN state was reported for sensors of type "battery" and "power
supply".
+A workaroud has been added to mitigate this problem.
diff --git a/checks/ipmi_sensors.include b/checks/ipmi_sensors.include
index 7b36483..adaf1d2 100644
--- a/checks/ipmi_sensors.include
+++ b/checks/ipmi_sensors.include
@@ -198,10 +198,10 @@ def freeipmi_status_txt_mapping(status_txt):
if state is not None:
return state
- if status_txt in [
- "Entity Present", "battery presence detected",
- "Drive Presence", "transition to Running", "Device
Enabled",
- "System full operational, working", "System Restart",
+ if status_txt.lower() in [
+ "entity present", "battery presence detected",
+ "drive presence", "transition to running", "device
enabled",
+ "system full operational, working", "system restart",
"present",
] or \
status_txt.startswith("Fully Redundant") or \
status_txt.endswith("is connected") or \
diff --git a/cmk_base/data_sources/ipmi.py b/cmk_base/data_sources/ipmi.py
index 4b09bcc..1f23c93 100644
--- a/cmk_base/data_sources/ipmi.py
+++ b/cmk_base/data_sources/ipmi.py
@@ -37,6 +37,38 @@ from cmk_base.exceptions import MKAgentError
from .abstract import CheckMKAgentDataSource, ManagementBoardDataSource
+def _handle_false_positive_warnings(reading):
+ """This is a workaround for a pyghmi bug
+ (bug report:
https://bugs.launchpad.net/pyghmi/+bug/1790120)
+
+ For some sensors undefined states are looked up, which results in readings of the
form
+ {'states': ['Present',
+ 'Unknown state 8 for reading type 111/sensor type 8',
+ 'Unknown state 9 for reading type 111/sensor type 8',
+ 'Unknown state 10 for reading type 111/sensor type 8',
+ 'Unknown state 11 for reading type 111/sensor type 8',
+ 'Unknown state 12 for reading type 111/sensor type 8', ...],
+ 'health': 1, 'name': 'PS Status', 'imprecision':
None, 'units': '',
+ 'state_ids': [552704, 552712, 552713, 552714, 552715, 552716, 552717,
552718],
+ 'type': 'Power Supply', 'value': None,
'unavailable': 0}
+
+ The health warning is set, but only due to the lookup errors. We remove the lookup
+ errors, and see whether the remaining states are meaningful.
+ """
+ states = [s for s in reading.states if not s.startswith("Unknown state ")]
+
+ if not states:
+ return "no state reported"
+
+ if any("non-critical" in s for s in states):
+ return "WARNING"
+
+ # just keep all the available info. It should be dealt with in
+ # ipmi_sensors.include (freeipmi_status_txt_mapping),
+ # where it will default to 2(CRIT)
+ return ', '.join(states)
+
+
class IPMIManagementBoardDataSource(ManagementBoardDataSource, CheckMKAgentDataSource):
def id(self):
@@ -126,6 +158,8 @@ class IPMIManagementBoardDataSource(ManagementBoardDataSource,
CheckMKAgentDataS
health_txt = "CRITICAL"
elif reading.health >= ipmi_const.Health.Warning:
health_txt = "WARNING"
+ # workaround for pyghmi bug:
https://bugs.launchpad.net/pyghmi/+bug/1790120
+ health_txt = _handle_false_positive_warnings(reading)
elif reading.health == ipmi_const.Health.Ok:
health_txt = "OK"