2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2015 mk@mathias-kettner.de |
11 # +------------------------------------------------------------------+
13 # This file is part of Check_MK.
14 # The official homepage is at http://mathias-kettner.de/check_mk.
16 # check_mk is free software; you can redistribute it and/or modify it
17 # under the terms of the GNU General Public License as published by
18 # the Free Software Foundation in version 2. check_mk is distributed
19 # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
20 # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
21 # PARTICULAR PURPOSE. See the GNU General Public License for more de-
22 # tails. You should have received a copy of the GNU General Public
23 # License along with GNU Make; see the file COPYING. If not, write
24 # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
25 # Boston, MA 02110-1301 USA.
28 def detect_webtherm(oid
):
29 return oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.5040.1.2.")
32 def parse_wut_webtherm(info
):
39 for index
, reading_de
, reading_en
in info
:
41 reading_str
= reading_en
43 reading_str
= reading_de
.replace(",", ".")
47 webtherm_type
, sensor_id
= index
.split(".")
48 # Dependent on webtherm_type we have to determine
49 # which sensors are available. Feel free to
50 # declare more sensor types here.
51 if "---" not in reading_str
and reading_str
:
52 # We have only temperature sensors
53 if int(webtherm_type
) <= 9: # TODO: this is just a guess
56 "reading": float(reading_str
),
58 # Here we have three different types of sensors:
59 # 1 = temp, 2 = humid, 3 = air pressure
62 "type": map_sensor_type
[sensor_id
],
63 "reading": float(reading_str
),
69 # .--Temperature---------------------------------------------------------.
71 # | |_ _|__ _ __ ___ _ __ ___ _ __ __ _| |_ _ _ _ __ ___ |
72 # | | |/ _ \ '_ ` _ \| '_ \ / _ \ '__/ _` | __| | | | '__/ _ \ |
73 # | | | __/ | | | | | |_) | __/ | | (_| | |_| |_| | | | __/ |
74 # | |_|\___|_| |_| |_| .__/ \___|_| \__,_|\__|\__,_|_| \___| |
76 # +----------------------------------------------------------------------+
78 # '----------------------------------------------------------------------'
80 factory_settings
["wut_webtherm_defaultlevels"] = {
85 def inventory_wut_webtherm(parsed
):
86 return [ (sensor_id
, {}) for sensor_id
, values
in parsed
.items() \
87 if values
["type"] == "temp" ]
90 def check_wut_webtherm(item
, params
, parsed
):
92 return check_temperature(parsed
[item
]["reading"], params
, "wut_webtherm_%s" % item
)
95 check_info
["wut_webtherm"] = {
96 'default_levels_variable': "wut_webtherm_defaultlevels",
97 'parse_function': parse_wut_webtherm
,
98 'inventory_function': inventory_wut_webtherm
,
99 'check_function': check_wut_webtherm
,
100 'service_description': 'Temperature %s',
101 'has_perfdata': True,
103 '.1.3.6.1.4.1.5040.1.2',
104 ['1', '2', '3', '6', '7', '8', '9', '16', '18', '36', '37', '38', '42'],
106 '1.2.1.1', # WebGraph-Thermo-Hygro-Barometer-MIB::wtWebGraphThermoBaroSensorNo
107 '1.3.1.1', # WebGraph-Thermo-Hygro-Barometer-MIB::wtWebGraphThermoBaroTempValue
108 '1.8.1.1', # WebGraph-Thermo-Hygro-Barometer-MIB::wtWebGraphThermoBaroTempValuePkt
110 'snmp_scan_function': detect_webtherm
,
111 'group': 'temperature',
112 'includes': ['temperature.include'],
116 # .--Air Pressure--------------------------------------------------------.
118 # | / \ (_)_ __ | _ \ _ __ ___ ___ ___ _ _ _ __ ___ |
119 # | / _ \ | | '__| | |_) | '__/ _ \/ __/ __| | | | '__/ _ \ |
120 # | / ___ \| | | | __/| | | __/\__ \__ \ |_| | | | __/ |
121 # | /_/ \_\_|_| |_| |_| \___||___/___/\__,_|_| \___| |
123 # '----------------------------------------------------------------------'
126 def inventory_wut_webtherm_pressure(parsed
):
127 return [ (sensor_id
, None) for sensor_id
, values
in parsed
.items() \
128 if values
["type"] == "air_pressure" ]
131 def check_wut_webtherm_pressure(item
, _no_params
, parsed
):
133 return 0, "%.2f hPa" % parsed
[item
]["reading"]
136 check_info
["wut_webtherm.pressure"] = {
137 "inventory_function": inventory_wut_webtherm_pressure
,
138 "check_function": check_wut_webtherm_pressure
,
139 "service_description": "Pressure %s",
143 # .--Humidity------------------------------------------------------------.
145 # | | | | |_ _ _ __ ___ (_) __| (_) |_ _ _ |
146 # | | |_| | | | | '_ ` _ \| |/ _` | | __| | | | |
147 # | | _ | |_| | | | | | | | (_| | | |_| |_| | |
148 # | |_| |_|\__,_|_| |_| |_|_|\__,_|_|\__|\__, | |
150 # '----------------------------------------------------------------------'
152 wut_webtherm_humidity_defaultlevels
= (35, 40, 60, 65)
155 def inventory_wut_webtherm_humidity(parsed
):
156 return [ (sensor_id
, "wut_webtherm_humidity_defaultlevels") \
157 for sensor_id
, values
in parsed
.items() if values
["type"] == "humid" ]
160 def check_wut_webtherm_humidity(item
, params
, parsed
):
162 return check_humidity(parsed
[item
]["reading"], params
)
165 check_info
["wut_webtherm.humidity"] = {
166 "inventory_function": inventory_wut_webtherm_humidity
,
167 "check_function": check_wut_webtherm_humidity
,
168 "service_description": "Humidity %s",
169 "includes": ["humidity.include"],
170 'has_perfdata': True,