Module: check_mk
Branch: master
Commit: 3a30759f77758f36bcac3d8dff47ce425ff1c187
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3a30759f77758f…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Fri Oct 23 14:41:00 2015 +0200
preliminary version of wut_webtherm check
---
checks/wut_webtherm | 152 ++++++++++++++++++++++++++++++---------------------
1 file changed, 91 insertions(+), 61 deletions(-)
diff --git a/checks/wut_webtherm b/checks/wut_webtherm
index fd142c5..96932f8 100644
--- a/checks/wut_webtherm
+++ b/checks/wut_webtherm
@@ -24,6 +24,7 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
+
def detect_webtherm(oid):
return oid(".1.3.6.1.2.1.1.2.0") in \
[ ".1.3.6.1.4.1.5040.1.2.1",
@@ -36,6 +37,81 @@ def detect_webtherm(oid):
".1.3.6.1.4.1.5040.1.2.16",
".1.3.6.1.4.1.5040.1.2.18" ]
+
+def parse_wut_webtherm(info):
+ map_sensor_type = {
+ "1" : "temp",
+ "2" : "humid",
+ "3" : "air_pressure",
+ }
+ parsed = {}
+ for index, reading in info:
+ webtherm_type, sensor_id = index.split(".")
+ # Dependent on webtherm_type we have to determine
+ # which sensors are available. Feel free to
+ # declare more sensor types here.
+ if "---" not in reading:
+ # We have only temperature sensors
+ if webtherm_type == "6":
+ parsed[sensor_id] = {
+ "type" : "temp",
+ "reading" : float(reading),
+ }
+ # Here we have three different types of sensors:
+ # 1 = temp, 2 = humid, 3 = air pressure
+ elif webtherm_type == "16":
+ parsed[sensor_id] = {
+ "type" : map_sensor_type[sensor_id],
+ "reading" : float(reading),
+ }
+
+ return parsed
+
+
+# .--Temperature---------------------------------------------------------.
+# | _____ _ |
+# | |_ _|__ _ __ ___ _ __ ___ _ __ __ _| |_ _ _ _ __ ___ |
+# | | |/ _ \ '_ ` _ \| '_ \ / _ \ '__/ _` | __| | | | '__/ _ \
|
+# | | | __/ | | | | | |_) | __/ | | (_| | |_| |_| | | | __/ |
+# | |_|\___|_| |_| |_| .__/ \___|_| \__,_|\__|\__,_|_| \___| |
+# | |_| |
+# +----------------------------------------------------------------------+
+# | main check |
+# '----------------------------------------------------------------------'
+
+
+factory_settings["wut_webtherm_defaultlevels"] = {
+ "levels" : (30, 35),
+}
+
+
+def inventory_wut_webtherm(parsed):
+ return [ (sensor_id, {}) for sensor_id, values in parsed.items() \
+ if values["type"] == "temp" ]
+
+
+def check_wut_webtherm(item, params, parsed):
+ if item in parsed:
+ return check_temperature(parsed[item]["reading"], params)
+
+
+check_info["wut_webtherm"] = {
+ 'default_levels_variable' : "wut_webtherm_defaultlevels",
+ 'parse_function' : parse_wut_webtherm,
+ 'inventory_function' : inventory_wut_webtherm,
+ 'check_function' : check_wut_webtherm,
+ 'service_description' : 'Temperature %s',
+ 'has_perfdata' : True,
+ 'snmp_info' : ('.1.3.6.1.4.1.5040.1.2', ['1',
'2', '3', '6', '7', '8', '9',
'16', '18'], [
+ '1.2.1.1', # sensorNo
+ '1.8.1.1' # valuePkt
+ ]),
+ 'snmp_scan_function' : detect_webtherm,
+ 'group' : 'temperature',
+ 'includes' : [ 'temperature.include' ],
+}
+
+#.
# .--Air Pressure--------------------------------------------------------.
# | _ _ ____ |
# | / \ (_)_ __ | _ \ _ __ ___ ___ ___ _ _ _ __ ___ |
@@ -45,17 +121,14 @@ def detect_webtherm(oid):
# | |
# '----------------------------------------------------------------------'
-def inventory_wut_webtherm_pressure(info):
- for index, reading in info:
- if index.split(".")[1] == "3":
- return [ ("3", None) ]
+def inventory_wut_webtherm_pressure(parsed):
+ return [ (sensor_id, None) for sensor_id, values in parsed.items() \
+ if values["type"] == "air_pressure" ]
-def check_wut_webtherm_pressure(item, _no_params, info):
- for index, reading in info:
- if index.split(".")[1] == item:
- pressure = float(reading.replace(",",".")) # This value
is in hPa
- return 0, "%.2f hPa" % pressure
+def check_wut_webtherm_pressure(item, _no_params, parsed):
+ if item in parsed:
+ return 0, "%.2f hPa" % parsed[item]["reading"]
check_info["wut_webtherm.pressure"] = {
@@ -64,6 +137,7 @@ check_info["wut_webtherm.pressure"] = {
"service_description" : "Pressure %s",
}
+
#.
# .--Humidity------------------------------------------------------------.
# | _ _ _ _ _ _ |
@@ -74,19 +148,18 @@ check_info["wut_webtherm.pressure"] = {
# | |___/ |
# '----------------------------------------------------------------------'
+
wut_webtherm_humidity_defaultlevels = (35, 40, 60, 65)
-def inventory_wut_webtherm_humidity(info):
- for index, reading in info:
- if index.split(".")[1] == "2":
- return [ ("2", "wut_webtherm_humidity_defaultlevels") ]
+def inventory_wut_webtherm_humidity(parsed):
+ return [ (sensor_id, "wut_webtherm_humidity_defaultlevels") \
+ for sensor_id, values in parsed.items() if values["type"] ==
"humid" ]
-def check_wut_webtherm_humidity(item, params, info):
- for index, reading in info:
- if index.split(".")[1] == item:
- humidity = float(reading.replace(",","."))
- return check_humidity(humidity, params)
+
+def check_wut_webtherm_humidity(item, params, parsed):
+ if item in parsed:
+ return check_humidity(parsed[item]["reading"], params)
check_info["wut_webtherm.humidity"] = {
@@ -96,46 +169,3 @@ check_info["wut_webtherm.humidity"] = {
"includes" : [ "humidity.include" ],
"group" : "humidity",
}
-
-#.
-# .--Temperature---------------------------------------------------------.
-# | _____ _ |
-# | |_ _|__ _ __ ___ _ __ ___ _ __ __ _| |_ _ _ _ __ ___ |
-# | | |/ _ \ '_ ` _ \| '_ \ / _ \ '__/ _` | __| | | | '__/ _ \
|
-# | | | __/ | | | | | |_) | __/ | | (_| | |_| |_| | | | __/ |
-# | |_|\___|_| |_| |_| .__/ \___|_| \__,_|\__|\__,_|_| \___| |
-# | |_| |
-# '----------------------------------------------------------------------'
-
-factory_settings["wut_webtherm_defaultlevels"] = {
- "levels" : (30, 35),
-}
-
-def inventory_wut_webtherm(info):
- # line[0] is 1.1, 2.1, 3.1, 6.1, 8.1, 16.1 or 18.1 depending on MIB variant. We chop
- # of the first part in order to get independent of that.
- for index, reading in info:
- if index.split(".")[1] == "1":
- return [ ("1", {}) ]
-
-def check_wut_webtherm(item, params, info):
- for line in info:
- if line[0].split(".")[1] == item:
- temp = float(line[1].replace(",", "."))
- return check_temperature(temp, params)
-
-
-check_info["wut_webtherm"] = {
- 'default_levels_variable' : "wut_webtherm_defaultlevels",
- 'inventory_function' : inventory_wut_webtherm,
- 'check_function' : check_wut_webtherm,
- 'service_description' : 'Temperature %s',
- 'has_perfdata' : True,
- 'snmp_info' : ('.1.3.6.1.4.1.5040.1.2',
- ['1', '2', '3', '6',
'7', '8', '9', '16', '18'],
- ['1.2.1.1', '1.3.1.1']
- ),
- 'snmp_scan_function' : detect_webtherm,
- 'group' : 'temperature',
- 'includes' : [ 'temperature.include' ],
-}