Refactoring: Moved check parameters from unsorted.py to dedicated modules (CMK-1393)
[check_mk.git] / checks / etherbox2_temp
blob1dd8b26b65671e33be98f079a50c94a5e83cb030
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
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.
27 # .1.3.6.1.4.1.14848.2.1.7.1.2.1 -0.0008 Volt --> BETTER-NETWORKS-ETHERNETBOX-MIB::ethernetboxObjects.7.1.2.1
28 # .1.3.6.1.4.1.14848.2.1.7.1.2.2 -0.0008 Volt --> BETTER-NETWORKS-ETHERNETBOX-MIB::ethernetboxObjects.7.1.2.2
29 # .1.3.6.1.4.1.14848.2.1.7.1.2.3 5.0015 Volt --> BETTER-NETWORKS-ETHERNETBOX-MIB::ethernetboxObjects.7.1.2.3
30 # .1.3.6.1.4.1.14848.2.1.7.1.2.4 2.0031 Volt --> BETTER-NETWORKS-ETHERNETBOX-MIB::ethernetboxObjects.7.1.2.4
31 # .1.3.6.1.4.1.14848.2.1.7.1.2.5 -0.0005 Volt --> BETTER-NETWORKS-ETHERNETBOX-MIB::ethernetboxObjects.7.1.2.5
32 # .1.3.6.1.4.1.14848.2.1.7.1.2.6 -0.0004 Volt --> BETTER-NETWORKS-ETHERNETBOX-MIB::ethernetboxObjects.7.1.2.6
33 # .1.3.6.1.4.1.14848.2.1.7.1.2.7 5.0002 Volt --> BETTER-NETWORKS-ETHERNETBOX-MIB::ethernetboxObjects.7.1.2.7
34 # .1.3.6.1.4.1.14848.2.1.7.1.2.8 2.0010 Volt --> BETTER-NETWORKS-ETHERNETBOX-MIB::ethernetboxObjects.7.1.2.8
36 # .1.3.6.1.4.1.14848.2.1.9.1.2.1 -2472 --> BETTER-NETWORKS-ETHERNETBOX-MIB::ethernetboxObjects.9.1.2.1
37 # .1.3.6.1.4.1.14848.2.1.9.1.2.2 252 --> BETTER-NETWORKS-ETHERNETBOX-MIB::ethernetboxObjects.9.1.2.2
38 # .1.3.6.1.4.1.14848.2.1.9.1.2.3 0 --> BETTER-NETWORKS-ETHERNETBOX-MIB::ethernetboxObjects.9.1.2.3
39 # .1.3.6.1.4.1.14848.2.1.9.1.2.4 248 --> BETTER-NETWORKS-ETHERNETBOX-MIB::ethernetboxObjects.9.1.2.4
41 # suggested by customer
42 factory_settings['etherbox2_temp_default_levels'] = {
43 'levels': (30, 35),
47 def parse_etherbox2_temp(info):
48 # We have to use xxx.7.1.2.a to know if a temperature sensor
49 # is connected:
50 # - if oid(xxx.7.1.2.{a}) == 5.fff and oid(xxx.7.1.2.{a+1}) == 2.fff
51 # then a temperature sensor is connected to oid(xxx.9.1.2.{(a+1)/2})
52 # (a = 1, 3, 5, ...)
53 # - otherwise there's no sensor connected.
54 # Furthermore we cannot only use xxx.9.1.2.{a} < 0 (or something like that)
55 # because the temperature can drop below 0.
56 parsed = {}
57 sensor_indicators, sensors = info
58 for sensor_index, sensor in enumerate(sensors):
59 indicator_index = 2 * sensor_index
60 if float((sensor_indicators[indicator_index][0].split("Volt")[0]).strip()) > 4 and \
61 float((sensor_indicators[indicator_index + 1][0].split("Volt")[0]).strip()) > 1:
62 parsed["Sensor %s" % sensor[0]] = float(sensor[1]) / 10
64 return parsed
67 def inventory_etherbox2_temp(parsed):
68 return [(sensor, {}) for sensor in parsed]
71 def check_etherbox2_temp(item, params, parsed):
72 if item in parsed:
73 return check_temperature(parsed[item], params, "etherbox2_%s" % item)
76 check_info['etherbox2_temp'] = {
77 'parse_function' : parse_etherbox2_temp,
78 'inventory_function' : inventory_etherbox2_temp,
79 'check_function' : check_etherbox2_temp,
80 'service_description' : 'Temperature %s',
81 'has_perfdata' : True,
82 'snmp_info' : [(".1.3.6.1.4.1.14848.2.1.7.1.2", [ "" ]),
83 (".1.3.6.1.4.1.14848.2.1.9.1.2", [ OID_END, "" ])],
84 # From firmware version 1.21 on the ethernetbox 2 from MessPC
85 # supports additional temperature sensors. The sensor data are
86 # located under these OIDs. There are no standard OIDs for
87 # disk space reasons.
88 'snmp_scan_function' : lambda oid: oid(".1.3.6.1.2.1.1.1.0") == "" and \
89 "Version 1.2" in oid(".1.3.6.1.4.1.14848.2.1.1.1.0", ""),
90 'default_levels_variable' : 'etherbox2_temp_default_levels',
91 'group' : 'temperature',
92 'includes' : [ "temperature.include" ],