[checkmk-commits] Check_MK Git: check_mk: Modernize fsc_temp check

Mathias Kettner mk at mathias-kettner.de
Fri Nov 23 09:54:02 CET 2012


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

Author: Mathias Kettner <mk at mathias-kettner.de>
Date:   Fri Nov 23 09:53:59 2012 +0100

Modernize fsc_temp check

---

 checks/fsc_temp |   35 +++++++++++++++++++++++------------
 1 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/checks/fsc_temp b/checks/fsc_temp
index fc22977..c4ab1a0 100644
--- a/checks/fsc_temp
+++ b/checks/fsc_temp
@@ -25,18 +25,26 @@
 # Boston, MA 02110-1301 USA.
 
 
-def inventory_fsc_temp(info):
+# We fetch the following columns from SNMP:
+# 13: name of the temperature sensor (used as item)
+# 11: current temperature in C
+# 6:  warning level
+# 8:  critical level
+
+def inventory_fsc_temp(info): 
+    # Ignore non-connected sensors
     return [ (line[0], None) for line in info if int(line[1]) < 500 ]
 
 def check_fsc_temp(item, _no_params, info):
-    for line in info: # , value1, value2 in info:
-        name = line[0]
+    for name, current, warn, crit in info:
         if name != item: continue
-        current = int(line[1])
-        warn = int(line[2])
-        crit = int(line[3])
+        current = int(current)
+        warn = int(warn)
+        crit = int(crit)
+
         infotext = "%d C (levels at %d C / %d C)" % (current, warn, crit)
         perfdata = [ ("temp", current, warn, crit, 0 ) ]
+
         if current == -1 or current == 4294967295:
             return(3, "UNKNOWN - Problem with sensor")
         elif current >= crit and crit > 0:
@@ -48,9 +56,12 @@ def check_fsc_temp(item, _no_params, info):
 
     return (3, "UNKNOWN - Sensor %s not found in SNMP data" % item)
 
-check_info['fsc_temp'] = (check_fsc_temp, "Temperature %s", 1,  inventory_fsc_temp)
-snmp_info['fsc_temp'] = ( ".1.3.6.1.4.1.231.2.10.2.2.5.2.1.1", [ 13, 11, 6, 8 ] )
-snmp_scan_functions['fsc_temp'] = lambda oid: \
-    oid(".1.3.6.1.4.1.231.2.10.2.1.1.0")
-
-checkgroup_of["fsc_temp"] = "temperature_auto"
+check_info['fsc_temp'] = {
+    "inventory_function"    : inventory_fsc_temp,
+    "check_function"        : check_fsc_temp,
+    "service_description"   : "Temperature %s",
+    "has_perfdata"          : True,
+    "snmp_info"             : ( ".1.3.6.1.4.1.231.2.10.2.2.5.2.1.1", [ 13, 11, 6, 8 ] ),
+    "snmp_scan_function"    : lambda oid: oid(".1.3.6.1.4.1.231.2.10.2.1.1.0"),
+    "group"                 : "temperature_auto",
+}



More information about the checkmk-commits mailing list