2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2018 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 # .--parse functions-----------------------------------------------------.
30 # | _ __ __ _ _ __ ___ ___ |
31 # | | '_ \ / _` | '__/ __|/ _ \ |
32 # | | |_) | (_| | | \__ \ __/ |
33 # | | .__/ \__,_|_| |___/\___| |
36 # | / _|_ _ _ __ ___| |_(_) ___ _ __ ___ |
37 # | | |_| | | | '_ \ / __| __| |/ _ \| '_ \/ __| |
38 # | | _| |_| | | | | (__| |_| | (_) | | | \__ \ |
39 # | |_| \__,_|_| |_|\___|\__|_|\___/|_| |_|___/ |
41 # +----------------------------------------------------------------------+
43 # '----------------------------------------------------------------------'
71 "32769": "temperatureCombo",
72 "32770": "humidityCombo",
76 sensor_type_names_sems_external
= {
99 "32769": "temperatureCombo",
100 "32770": "humidityCombo",
103 sensor_type_names_external
= {
132 "44": "reactivePower",
135 "32769": "temperatureCombo",
136 "32770": "humidityCombo",
139 sensor_status_names
= {
149 sensor_digital_value_names
= {
154 factory_settings
["enviromux_default_levels"] = {
156 "levels_lower": (10, 9),
160 def parse_enviromux(info
):
164 sensor_descr
= line
[2]
165 sensor_index
= line
[0]
166 item
= sensor_descr
+ " " + sensor_index
168 sensor_type
= sensor_type_names
.get(line
[1], "unknown")
169 sensor_status
= sensor_status_names
.get(line
[8], "unknown")
170 # Observed in the wild: "power" may actually be a voltage m(
171 if sensor_type
in ["temperature", "power", "current"]:
172 # The MIB specifies that currents, voltages and temperatures have a scaling factor 10
173 sensor_value
= int(line
[5]) / 10.0
174 sensor_min
= int(line
[9]) / 10.0
175 sensor_max
= int(line
[10]) / 10.0
177 sensor_value
= int(line
[5])
178 sensor_min
= int(line
[9])
179 sensor_max
= int(line
[10])
182 "sensor_type": sensor_type
,
183 "sensor_status": sensor_status
,
184 "sensor_value": sensor_value
,
185 "sensor_min": sensor_min
,
186 "sensor_max": sensor_max
,
187 "sensor_unit": line
[6], # e.g. V, C, %
193 def parse_enviromux_sems_external(info
):
197 sensor_descr
= line
[2]
198 sensor_index
= line
[0]
199 item
= sensor_descr
+ " " + sensor_index
201 sensor_type
= sensor_type_names
.get(line
[1], "unknown")
202 sensor_status
= sensor_status_names
.get(line
[8], "unknown")
203 # Observed in the wild: "power" may actually be a voltage m(
204 if sensor_type
in ["temperature", "power", "current"]:
205 # The MIB specifies that currents, voltages and temperatures have a scaling factor 10
206 sensor_value
= int(line
[6]) / 10.0
207 sensor_min
= int(line
[10]) / 10.0
208 sensor_max
= int(line
[11]) / 10.0
210 sensor_value
= int(line
[6])
211 sensor_min
= int(line
[10])
212 sensor_max
= int(line
[11])
215 "sensor_type": sensor_type
,
216 "sensor_status": sensor_status
,
217 "sensor_value": sensor_value
,
218 "sensor_min": sensor_min
,
219 "sensor_max": sensor_max
,
220 "sensor_unit": line
[6], # e.g. V, C, %
226 def parse_enviromux_external(info
):
230 sensor_descr
= line
[2]
231 sensor_index
= line
[0]
232 item
= sensor_descr
+ " " + sensor_index
234 sensor_type
= sensor_type_names
.get(line
[1], "unknown")
235 sensor_status
= sensor_status_names
.get(line
[8], "unknown")
236 # Observed in the wild: "power" may actually be a voltage m(
237 if sensor_type
in ["temperature", "power", "current", "temperatureCombo"]:
238 # The MIB specifies that currents, voltages and temperatures have a scaling factor 10
239 sensor_value
= int(line
[6]) / 10.0
240 sensor_min
= int(line
[10]) / 10.0
241 sensor_max
= int(line
[11]) / 10.0
243 sensor_value
= int(line
[6])
244 sensor_min
= int(line
[10])
245 sensor_max
= int(line
[11])
248 "sensor_type": sensor_type
,
249 "sensor_status": sensor_status
,
250 "sensor_value": sensor_value
,
251 "sensor_min": sensor_min
,
252 "sensor_max": sensor_max
,
253 "sensor_unit": line
[6], # e.g. V, C, %
259 def parse_enviromux_digital(info
):
263 sensor_descr
= line
[2]
264 sensor_index
= line
[0]
265 sensor_normal_value
= sensor_digital_value_names
.get(line
[8], "unknown")
266 sensor_value
= sensor_digital_value_names
.get(line
[6], "unknown")
267 item
= sensor_descr
+ " " + sensor_index
268 sensor_status
= sensor_status_names
.get(line
[7], "unknown")
270 "sensor_status": sensor_status
,
271 "sensor_value": sensor_value
,
272 "sensor_normal_value": sensor_normal_value
,
278 def parse_enviromux_sems_digital(info
):
282 sensor_descr
= line
[1]
283 sensor_index
= line
[0]
284 sensor_normal_value
= sensor_digital_value_names
.get(line
[5], "unknown")
285 sensor_value
= sensor_digital_value_names
.get(line
[4], "unknown")
286 item
= sensor_descr
+ " " + sensor_index
287 sensor_status
= sensor_status_names
.get(line
[6], "unknown")
289 "sensor_status": sensor_status
,
290 "sensor_value": sensor_value
,
291 "sensor_normal_value": sensor_normal_value
,
298 # .--inventory functions-------------------------------------------------.
300 # | (_)_ ____ _____ _ __ | |_ ___ _ __ _ _ |
301 # | | | '_ \ \ / / _ \ '_ \| __/ _ \| '__| | | | |
302 # | | | | | \ V / __/ | | | || (_) | | | |_| | |
303 # | |_|_| |_|\_/ \___|_| |_|\__\___/|_| \__, | |
306 # | / _|_ _ _ __ ___| |_(_) ___ _ __ ___ |
307 # | | |_| | | | '_ \ / __| __| |/ _ \| '_ \/ __| |
308 # | | _| |_| | | | | (__| |_| | (_) | | | \__ \ |
309 # | |_| \__,_|_| |_|\___|\__|_|\___/|_| |_|___/ |
311 # +----------------------------------------------------------------------+
313 # '----------------------------------------------------------------------'
316 def inventory_enviromux_temperature(parsed
):
317 for item
, sensor_data
in parsed
.items():
318 if sensor_data
["sensor_type"] in ["temperature", "temperatureCombo"]:
322 def inventory_enviromux_voltage(parsed
):
323 for item
, sensor_data
in parsed
.items():
324 if sensor_data
["sensor_type"] == "power":
328 def inventory_enviromux_humidity(parsed
):
329 for item
, sensor_data
in parsed
.items():
330 if sensor_data
["sensor_type"] in ["humidity", "humidityCombo"]:
335 # .--scan functions------------------------------------------------------.
337 # | ___ ___ __ _ _ __ / _|_ _ _ __ ___| |_(_) ___ _ __ ___ |
338 # | / __|/ __/ _` | '_ \ | |_| | | | '_ \ / __| __| |/ _ \| '_ \/ __| |
339 # | \__ \ (_| (_| | | | | | _| |_| | | | | (__| |_| | (_) | | | \__ \ |
340 # | |___/\___\__,_|_| |_| |_| \__,_|_| |_|\___|\__|_|\___/|_| |_|___/ |
342 # +----------------------------------------------------------------------+
344 # '----------------------------------------------------------------------'
347 def enviromux_scan_function(oid
):
348 return oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.3699.1.1.11")
351 def enviromux_sems_scan_function(oid
):
352 return oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.3699.1.1.2")
356 # .--check functions-----------------------------------------------------.
358 # | ___| |__ ___ ___| | __ |
359 # | / __| '_ \ / _ \/ __| |/ / |
360 # | | (__| | | | __/ (__| < |
361 # | \___|_| |_|\___|\___|_|\_\ |
364 # | / _|_ _ _ __ ___| |_(_) ___ _ __ ___ |
365 # | | |_| | | | '_ \ / __| __| |/ _ \| '_ \/ __| |
366 # | | _| |_| | | | | (__| |_| | (_) | | | \__ \ |
367 # | |_| \__,_|_| |_|\___|\__|_|\___/|_| |_|___/ |
369 # +----------------------------------------------------------------------+
371 # '----------------------------------------------------------------------'
374 def check_enviromux_temperature(item
, params
, parsed
):
375 dev_levels_lower
= (parsed
[item
]['sensor_min'], parsed
[item
]['sensor_min'])
376 dev_levels
= (parsed
[item
]['sensor_max'], parsed
[item
]['sensor_max'])
377 return check_temperature(
378 parsed
[item
]['sensor_value'],
381 dev_levels_lower
=dev_levels_lower
,
382 dev_levels
=dev_levels
)
385 def check_enviromux_voltage(item
, params
, parsed
):
386 sensor_value
= parsed
[item
]['sensor_value']
387 perf
= [("voltage", sensor_value
)]
388 infotext
= "Input Voltage is %.1f V" % sensor_value
389 min_warn
= params
['levels_lower'][0]
390 min_crit
= params
['levels_lower'][1]
391 max_warn
= params
['levels'][0]
392 max_crit
= params
['levels'][1]
393 levelstext_lower
= " (warn/crit below %s/%s)" % (min_warn
, min_crit
)
394 levelstext_upper
= " (warn/crit at %s/%s)" % (max_warn
, max_crit
)
396 if sensor_value
>= max_crit
:
398 levelstext
= levelstext_upper
399 elif sensor_value
< min_crit
:
401 levelstext
= levelstext_lower
402 elif sensor_value
< min_warn
:
404 levelstext
= levelstext_lower
405 elif sensor_value
>= max_warn
:
407 levelstext
= levelstext_upper
411 infotext
+= levelstext
412 return state
, infotext
, perf
415 def check_enviromux_humidity(item
, params
, parsed
):
416 return check_humidity(parsed
[item
]['sensor_value'], params
)