[checkmk-commits] Check_MK Git: check_mk: #2213 FIX cisco_temperature: Fixed behaviour in cases where device reports status but no temperature

Konstantin Büttner kb at mathias-kettner.de
Fri Apr 17 14:32:14 CEST 2015


Module: check_mk
Branch: master
Commit: c0cfb6bc13096647e5f343bd2af30666474e4741
URL:    http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c0cfb6bc13096647e5f343bd2af30666474e4741

Author: Konstantin Büttner <kb at mathias-kettner.de>
Date:   Fri Apr 17 14:31:03 2015 +0200

#2213 FIX cisco_temperature: Fixed behaviour in cases where device reports status but no temperature

Previously, the check would report unknown in cases where the device reports an ok status but no valid
temperature. This behaviour differed from the way the old cisco_temp_perf check handled this. This has
been fixed to be consistent with the old behaviour.

---

 .werks/2213              |   12 ++++++++
 ChangeLog                |    1 +
 checks/cisco_temperature |   70 +++++++++++++++++++++++++---------------------
 3 files changed, 51 insertions(+), 32 deletions(-)

diff --git a/.werks/2213 b/.werks/2213
new file mode 100644
index 0000000..061d46c
--- /dev/null
+++ b/.werks/2213
@@ -0,0 +1,12 @@
+Title: cisco_temperature: Fixed behaviour in cases where device reports status but no temperature
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1429273644
+
+Previously, the check would report unknown in cases where the device reports an ok status but no valid
+temperature. This behaviour differed from the way the old cisco_temp_perf check handled this. This has
+been fixed to be consistent with the old behaviour.
diff --git a/ChangeLog b/ChangeLog
index b0b324e..e441f67 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -332,6 +332,7 @@
     * 2179 FIX: apc_symmetra: Fixed regression introduced with last release when output state is empty
     * 2067 FIX: windows agent: product version is no longer set to 1.0.0...
     * 2068 FIX: Filesystem checks: Fix crash when legacy parameters (tuple) were used...
+    * 2213 FIX: cisco_temperature: Fixed behaviour in cases where device reports status but no temperature...
 
     Multisite:
     * 1758 Improved exception hander: Shows details without additional debug request, added mailto link for error report...
diff --git a/checks/cisco_temperature b/checks/cisco_temperature
index 5f31bfe..01c6051 100644
--- a/checks/cisco_temperature
+++ b/checks/cisco_temperature
@@ -49,24 +49,26 @@ def parse_cisco_temperature(info):
         else:
             descr = sensor_id
         if descr and sensortype == '8':
-            entity_parsed[descr] = {}
-            scale = 10**int(magnitude)
-            if scalecode == '8':
-                scale *= 1000
-            entity_parsed[descr]['temp'] = float(value) / scale
-
-            if len(thresholds[sensor_id]) in [ 2, 4 ]:
-                warnraw, critraw = thresholds[sensor_id][0:2]
-                dev_levels = (float(warnraw)/scale, float(critraw)/scale)
-            else:
-                dev_levels = None
-            entity_parsed[descr]['dev_levels'] = dev_levels
 
             if sensorstate == '2':
-                entity_parsed[descr]['unknown'] = (3, "Data from sensor currently not available")
+                entity_parsed[descr] = (3, "Data from sensor currently not available")
             elif sensorstate == '3':
-                entity_parsed[descr]['unknown'] = (3, "Sensor is broken")
-            entity_parsed[descr]['dev_status'] = None
+                entity_parsed[descr] = (3, "Sensor is broken")
+            else:
+                entity_parsed[descr] = {}
+                scale = 10**int(magnitude)
+                if scalecode == '8':
+                    scale *= 1000
+                entity_parsed[descr]['temp'] = float(value) / scale
+
+                if len(thresholds[sensor_id]) in [ 2, 4 ]:
+                    warnraw, critraw = thresholds[sensor_id][0:2]
+                    dev_levels = (float(warnraw)/scale, float(critraw)/scale)
+                else:
+                    dev_levels = None
+                entity_parsed[descr]['dev_levels'] = dev_levels
+
+                entity_parsed[descr]['dev_status'] = None
 
     # Now parse OIDs described by CISCO-ENVMON-MIB
     envmon_states = {
@@ -81,25 +83,29 @@ def parse_cisco_temperature(info):
     parsed = {}
     for statustext, temp, max_temp, state, oid_end in perfstuff:
         item = cisco_sensor_item(statustext, oid_end)
-        parsed[item] = {}
-        parsed[item]['temp'] = int(temp)
         if state in ['5', '6']:
-            parsed[item]['unknown'] = (3, "Sensor %s" % envmon_states[state])
+            parsed[item] = (3, "Sensor %s" % envmon_states[state])
         elif int(temp) == 0:
-            parsed[item]['unknown'] = (3, "Sensor defect")
-        elif max_temp and int(max_temp):
-            parsed[item]['dev_status'] = None
-            parsed[item]['dev_levels'] = (int(max_temp), int(max_temp))
+            if state in ('123'):
+                parsed[item] = ( int(state) - 1, "Sensor reports %s state" % envmon_states[state] )
+            else:
+                parsed[item] = (3, "Sensor defect")
         else:
-            parsed[item]['dev_levels'] = None
-            if state == '1':
-                parsed[item]['dev_status'] = 0
-            elif state == '2':
-                parsed[item]['dev_status'] = 1
-            elif state in '34':
-                parsed[item]['dev_status'] = 2
+            parsed[item] = {}
+            parsed[item]['temp'] = int(temp)
+            if max_temp and int(max_temp):
+                parsed[item]['dev_status'] = None
+                parsed[item]['dev_levels'] = (int(max_temp), int(max_temp))
             else:
-                parsed[item]['unknown'] = (3, "Sensor reports unknown status code")
+                parsed[item]['dev_levels'] = None
+                if state == '1':
+                    parsed[item]['dev_status'] = 0
+                elif state == '2':
+                    parsed[item]['dev_status'] = 1
+                elif state in '34':
+                    parsed[item]['dev_status'] = 2
+                else:
+                    parsed[item] = (3, "Sensor reports unknown status code")
 
     # Merge the two dicts, preferring keys generated from ENTITY data
     parsed.update(entity_parsed)
@@ -114,8 +120,8 @@ def inventory_cisco_temperature(parsed):
 
 def check_cisco_temperature(item, params, parsed):
     if item in parsed:
-        if parsed[item].get('unknown', None):
-            return parsed[item]['unknown']
+        if type(parsed[item]) == tuple:
+            return parsed[item]
         else:
             return check_temperature(parsed[item]['temp'], params,
                         dev_levels = parsed[item]['dev_levels'],



More information about the checkmk-commits mailing list