Module: check_mk
Branch: master
Commit: 08f606812078876843c328a7b1e7da885a14fb77
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=08f60681207887…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Mar 22 12:57:47 2011 +0100
Added srem1_sensors check
---
checkman/strem1_sensors | 35 +++++++++++++++
checks/strem1_sensors | 108 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 143 insertions(+), 0 deletions(-)
diff --git a/checkman/strem1_sensors b/checkman/strem1_sensors
new file mode 100644
index 0000000..f2f8b0b
--- /dev/null
+++ b/checkman/strem1_sensors
@@ -0,0 +1,35 @@
+title: Checks temperature,humidity,wetness on sensatronic em1 devices
+agents: snmp
+author: Lars Michelsen <lm(a)mathias-kettner.de>
+license: GPL
+distribution:
+description:
+ This check monitors the data gathered by the sensors sensors attached
+ to a Sensatronic EM1 device. The device needs to support the {SENSATRONICS-EM1} MIB.
+
+item:
+ Each sensor which returns a value different than -999.9 results in one service. The
item
+ containts the group name and the sensor type.
+
+perfdata:
+ Depends on the sensor type. In case of temperature the service outputs a perfdata value
+ {temperature} and the current value, warn, crit in the provided measure unit. In case
of
+ humidity the check returns a perfdata value {humindity} with the percentage value.
+
+inventory:
+ All available sensors are automatically inventorized.
+
+examples:
+ # set default levels for all sensors
+ strem1_temp_defaultlevels = (28, 32)
+ strem1_humidity_defaultlevels = (None, None)
+ strem1_wetness_defaultlevels = (None, None)
+
+[parameters]
+warning (int): minimum value leading to a WARNING state
+critical (int): mimimum value leading to a CRITICAL state
+
+[configuration]
+strem1_temp_defaultlevels (int/None, int/None): default temperature levels for warning,
critical states. Preset to (28, 32). None disables a threshold.
+strem1_humidity_defaultlevels (int/None, int/None): default humidity levels for warning,
critical states. Preset to (28, 32). None disables a threshold.
+strem1_wetness_defaultlevels (int/None, int/None): default wetness levels for warning,
critical states. Preset to (28, 32). None disables a threshold.
diff --git a/checks/strem1_sensors b/checks/strem1_sensors
new file mode 100644
index 0000000..8bb9871
--- /dev/null
+++ b/checks/strem1_sensors
@@ -0,0 +1,108 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2010 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# ails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+# Author: Lars Michelsen <lm(a)mathias-kettner.de>de>, 2011-03-21
+
+strem1_temp_defaultlevels = (28, 32)
+strem1_humidity_defaultlevels = (None, None)
+strem1_wetness_defaultlevels = (None, None)
+
+def strem1_sensors_parse_info(info):
+ # Change format of output: 1 tuple for each group
+ info = zip(*info)
+
+ parsed = []
+ for group in info:
+ grp = group[0]
+
+ items = group[1:]
+ for i in xrange(0, len(items), 3):
+ parsed.append([ grp + ' ' + items[i]] + list(items[i:i+3]))
+ return parsed
+
+
+def inventory_strem1_sensors(checkname, info):
+ inventory = []
+ for index, typ, val, intval in strem1_sensors_parse_info(info[1]):
+ lvls = 'strem1_temp_defaultlevels'
+ if typ == 'Humidity':
+ lvls = 'strem1_humidity_defaultlevels'
+ elif typ == 'Wetness':
+ lvls = 'strem1_wetness_defaultlevels'
+ if val != '-999.9':
+ inventory.append((index, lvls))
+ return inventory
+
+def check_strem1_sensors(item, params, info):
+ for index, typ, val, intval in strem1_sensors_parse_info(info[1]):
+ if index == item:
+ uom = typ == 'Temperature' and info[0][0][0] or '%'
+ val = float(val)
+ warn, crit = params
+
+ infotext = "%.1f" % val + uom
+ perfdata = [ ( typ.lower(), infotext, warn, crit ) ]
+ thrtext = []
+ if warn:
+ thrtext += ["warn at %.1f" % warn + uom]
+ if crit:
+ thrtext += ["crit at %.1f" % crit + uom]
+ if thrtext:
+ infotext += ' (%s)' % ', '.join(thrtext)
+
+ if crit and val >= crit:
+ return (2, "CRITICAL - %s is: " % typ + infotext, perfdata)
+ elif warn and val >= warn:
+ return (1, "WARNING - %s is: " % typ + infotext, perfdata)
+ else:
+ return (0, "OK - %s is: " % typ + infotext, perfdata )
+ return (3, "UNKNOWN - Sensor not found")
+
+
+check_info['strem1_sensors'] = ( check_strem1_sensors, "Sensor - %s",
1, inventory_strem1_sensors)
+
+#1, # SENSATRONICS-EM1::group1Name
+#2, # SENSATRONICS-EM1::group1TempName
+#3, # SENSATRONICS-EM1::group1TempDataStr
+#4, # SENSATRONICS-EM1::group1TempDataInt
+#5, # SENSATRONICS-EM1::group1HumidName
+#6, # group1HumidDataStr
+#7, # group1HumidDataInt
+#8, # group1WetName
+#9, # group1WetDataStr
+#10, # group1WetDataInt
+snmp_info['strem1_sensors'] = [
+ ("1.3.6.1.4.1.16174.1.1.3.2.3", [1]),
+ ("1.3.6.1.4.1.16174.1.1.3.3", [ # SENSATRONICS-EM1::measurementSystem
+ 1, # First group
+ 2, # Second group
+ 3, # Third group
+ 4, # Fourth group
+ ]),
+]
+
+snmp_scan_functions['strem1_sensors'] = \
+ lambda oid: "Sensatronics EM1" in oid(".1.3.6.1.2.1.1.1.0")