Module: check_mk
Branch: master
Commit: 59954e6567f694fbcc00f8ba0b92aa0e9fb35160
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=59954e6567f694…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Tue Sep 4 15:00:59 2018 +0200
6485 FIX fsc_sc2_voltage: Do not discover not-available voltage units
Units which are not-available have voltage values 0 V.
This may lead to WARN or CRIT because lower or upper device
levels are checked.
Change-Id: I1717fc1f28744adff8844fc99edd3fb396e62c9b
---
.werks/6485 | 12 ++++++++++++
checks/fsc_sc2_voltage | 33 ++++++++++++++++++++++++++-------
2 files changed, 38 insertions(+), 7 deletions(-)
diff --git a/.werks/6485 b/.werks/6485
new file mode 100644
index 0000000..a0af6e0
--- /dev/null
+++ b/.werks/6485
@@ -0,0 +1,12 @@
+Title: fsc_sc2_voltage: Do not discover not-available voltage units
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1536065883
+Class: fix
+
+Units which are not-available have voltage values 0 V.
+This may lead to WARN or CRIT because lower or upper device
+levels are checked.
diff --git a/checks/fsc_sc2_voltage b/checks/fsc_sc2_voltage
index 3bd6e2e..b17774e 100644
--- a/checks/fsc_sc2_voltage
+++ b/checks/fsc_sc2_voltage
@@ -72,22 +72,40 @@
def parse_fsc_sc2_voltage(info):
+ # dev_state:
+ # sc2VoltageStatus OBJECT-TYPE
+ # SYNTAX INTEGER
+ # {
+ # unknown(1),
+ # not-available(2),
+ # ok(3),
+ # too-low(4),
+ # too-high(5),
+ # sensor-failed(6)
+ # }
+ # ACCESS read-only
+ # STATUS mandatory
+ # DESCRIPTION "Voltage status"
+ # ::= { sc2Voltages 4 }
+
parsed = {}
- for designation, value, min_value, max_value in info:
+ for designation, dev_state, value, min_value, max_value in info:
+ if dev_state == "2":
+ continue
try:
value = float(value)/1000.0
min_value = float(min_value)/1000.0
max_value = float(max_value)/1000.0
except ValueError:
- dev_state = 3, 'Could not get all values'
- parsed.setdefault(designation, {"device_state": dev_state})
+ state_info = 3, 'Could not get all values'
+ parsed.setdefault(designation, {"device_state": state_info})
else:
- dev_state = value
+ state_info = value
if value < min_value:
- dev_state = value, (2, 'too low, deceeds %.2f V' % min_value)
+ state_info = value, (2, 'too low, deceeds %.2f V' % min_value)
elif value >= max_value:
- dev_state = value, (2, 'too high, exceeds %.2f V' % max_value)
- parsed.setdefault(designation, {"voltage": dev_state})
+ state_info = value, (2, 'too high, exceeds %.2f V' % max_value)
+ parsed.setdefault(designation, {"voltage": state_info})
return parsed
@@ -98,6 +116,7 @@ check_info['fsc_sc2_voltage'] = {
'service_description' : 'Voltage %s',
'snmp_info' : ('.1.3.6.1.4.1.231.2.10.2.2.10.6.3.1',
[
'3', #sc2VoltageDesignation
+ '4', #sc2VoltageStatus
'5', #sc2VoltageCurrentValue
'7', #sc2VoltageMinimumLevel
'8', #sc2VoltageMaximumLevel