[checkmk-commits] Check_MK Git: check_mk: netapp_api_temp: Reworked to use new check_temperature_list function

Konstantin Büttner kb at mathias-kettner.de
Tue Feb 24 16:22:39 CET 2015


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

Author: Konstantin Büttner <kb at mathias-kettner.de>
Date:   Tue Feb 24 16:18:31 2015 +0100

netapp_api_temp: Reworked to use new check_temperature_list function

Conflicts:
	checks/netapp_api_temp

---

 checks/netapp_api_temp |   28 ++++++++--------------------
 1 file changed, 8 insertions(+), 20 deletions(-)

diff --git a/checks/netapp_api_temp b/checks/netapp_api_temp
index 1029f3c..80ee94d 100644
--- a/checks/netapp_api_temp
+++ b/checks/netapp_api_temp
@@ -41,10 +41,7 @@ def inventory_netapp_api_temp(parsed):
 def check_netapp_api_temp(item, params, parsed):
     is_ambient = item == "Ambient" and "true" or "false"
 
-    sensor_count  = 0
-    sum_temp      = 0.0
-
-    sensor_errors = []
+    sensorlist = []
     for shelf, sensors in parsed.items():
         if sensors["shelf-owned"][0] != "true":
             continue
@@ -53,30 +50,21 @@ def check_netapp_api_temp(item, params, parsed):
             if ambient != is_ambient:
                 continue
 
-            sensor_count += 1
             current_temp = int(sensors["temp-sensor-current-temperature"][idx])
-            sum_temp += current_temp
-            if sensor_count == 1:
-                lowest_temp = current_temp
-                highest_temp = current_temp
-            else:
-                lowest_temp = min(lowest_temp, current_temp)
-                highest_temp = max(highest_temp, current_temp)
-
             sensor_no = sensors["temp-sensor-element-no"][idx]
             warn_low  = int(sensors["temp-sensor-low-warning"][idx])
             crit_low  = int(sensors["temp-sensor-low-critical"][idx])
             warn_high = int(sensors["temp-sensor-hi-warning"][idx])
             crit_high = int(sensors["temp-sensor-hi-critical"][idx])
-            state, infotext, perfdata = check_temperature(current_temp, params,
-              dev_levels=(warn_high, crit_high), dev_levels_lower=(warn_low, crit_low))
-            if state:
-                yield state, ("Sensor %s at " % sensor_no) + infotext
 
-    if sensor_count > 0:
-        yield 0, "%d Temperature sensors, highest: %.1f °C, average: %.1f °C lowest: %.1f °C" % (
-            sensor_count, highest_temp, sum_temp / sensor_count, lowest_temp), [ ("temp", highest_temp) ]
+            kwargs = {
+                "dev_levels"         : (warn_high, crit_high),
+                "dev_levels_lower"   : (warn_low, crit_low),
+            }
+
+            sensorlist.append( (shelf + "/" + sensor_no, current_temp, kwargs) )
 
+    return check_temperature_list(sensorlist, params)
 
 
 check_info["netapp_api_temp"] = {



More information about the checkmk-commits mailing list