Cleanup config.nodes_of
[check_mk.git] / checks / kentix_amp_sensors
blob5c1f38499777f3b006744656ebb4ce1ab9ffb0d0
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.37954.1.2.7.1.0 RZ1SE-KLIMA-NEU sensor name
28 # .1.3.6.1.4.1.37954.1.2.7.2.0 159 temperature INTEGER (0..1000)
29 # .1.3.6.1.4.1.37954.1.2.7.3.0 474 humidity INTEGER (0..1000)
30 # .1.3.6.1.4.1.37954.1.2.7.4.0 48 dew point INTEGER (0..1000)
31 # .1.3.6.1.4.1.37954.1.2.7.5.0 0 carbon monoxide INTEGER (-100..100) # in percent
32 # .1.3.6.1.4.1.37954.1.2.7.6.0 0 motion INTEGER (0..100)
33 # .1.3.6.1.4.1.37954.1.2.7.7.0 0 digital in 1 INTEGER (0..1) # leakage sensor: 0 (no alarm, connected)
34 # 1 (alarm or disconnected)
35 # .1.3.6.1.4.1.37954.1.2.7.8.0 0 digital in 2 INTEGER (0..1)
36 # .1.3.6.1.4.1.37954.1.2.7.9.0 0 digital out INTEGER (0..1)
37 # .1.3.6.1.4.1.37954.1.2.7.10.0 0 comError INTEGER (0..1)
39 # parsed:
40 # {'AlarmManager' : { 'smoke': 0, 'humidity': 0.0, 'temp': 0.0 , 'leakage':0 },
41 # 'RZ1SE-INNENRAUM': { 'smoke': 0, 'humidity': 35.9, 'temp': 21.8, 'leakage':1 },
42 # 'RZ1SE-KLIMA-ALT': { 'smoke': 0, 'humidity': 34.4, 'temp': 22.5, 'leakage':0 },
43 # 'RZ1SE-KLIMA-NEU': { 'smoke': 0, 'humidity': 47.4, 'temp': 15.9, 'leakage':0 },
44 # 'RZ1SELI1' : { 'smoke': 0, 'humidity': 35.6, 'temp': 21.6, 'leakage':0 },
45 # 'RZ1SERE1' : { 'smoke': 0, 'humidity': 47.3, 'temp': 16.7, 'leakage':0 },
46 # 'RZ2AMR001' : { 'smoke': 0, 'humidity': 36.7, 'temp': 16.6, 'leakage':0 },
47 # 'RZ2SE-INNENRAUM': { 'smoke': 0, 'humidity': 34.9, 'temp': 18.3, 'leakage':0 },
48 # 'RZ2SELI1' : { 'smoke': 0, 'humidity': 41.9, 'temp': 15.1, 'leakage':0 }
49 # }
52 def parse_kentix_amp_sensors(info):
53 info_flattened = []
55 for i in xrange(0, len(info[0]), 10):
56 info_flattened.append([a[0] for a in info[0][i:i + 10]])
58 parsed = {}
59 for line in info_flattened:
60 if line[0] != '':
61 parsed[line[0]] = {
62 'temp': float(line[1]) / 10,
63 'humidity': float(line[2]) / 10,
64 'smoke': int(line[4]),
66 if line[6] != '':
67 parsed[line[0]]['leakage'] = int(line[6])
69 return parsed
72 def inventory_kentix_amp_sensors(parsed, params):
73 return [(key, params) for key in parsed]
76 # .--temperature---------------------------------------------------------.
77 # | _ _ |
78 # | | |_ ___ _ __ ___ _ __ ___ _ __ __ _| |_ _ _ _ __ ___ |
79 # | | __/ _ \ '_ ` _ \| '_ \ / _ \ '__/ _` | __| | | | '__/ _ \ |
80 # | | || __/ | | | | | |_) | __/ | | (_| | |_| |_| | | | __/ |
81 # | \__\___|_| |_| |_| .__/ \___|_| \__,_|\__|\__,_|_| \___| |
82 # | |_| |
83 # +----------------------------------------------------------------------+
84 # | main check |
85 # '----------------------------------------------------------------------'
88 def check_kentix_amp_sensors_temperature(item, params, parsed):
89 if item in parsed:
90 return check_temperature(parsed[item]['temp'], params, "kentix_amp_sensors_%s" % item)
93 check_info['kentix_amp_sensors'] = {
94 'parse_function': parse_kentix_amp_sensors,
95 'inventory_function': lambda parsed: inventory_kentix_amp_sensors(parsed, {}),
96 'check_function': check_kentix_amp_sensors_temperature,
97 'service_description': 'Temperature %s',
98 'has_perfdata': True,
99 'group': 'temperature',
100 'snmp_info': [(".1.3.6.1.4.1.37954.1.2", [""])],
101 'snmp_scan_function': lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.332.11.6"),
102 'includes': ["temperature.include"],
106 # .--humidity------------------------------------------------------------.
107 # | _ _ _ _ _ |
108 # | | |__ _ _ _ __ ___ (_) __| (_) |_ _ _ |
109 # | | '_ \| | | | '_ ` _ \| |/ _` | | __| | | | |
110 # | | | | | |_| | | | | | | | (_| | | |_| |_| | |
111 # | |_| |_|\__,_|_| |_| |_|_|\__,_|_|\__|\__, | |
112 # | |___/ |
113 # +----------------------------------------------------------------------+
116 def check_kentix_amp_sensors_humidity(item, params, parsed):
117 if item in parsed:
118 return check_humidity(parsed[item]['humidity'], params)
121 check_info['kentix_amp_sensors.humidity'] = {
122 'inventory_function': lambda parsed: inventory_kentix_amp_sensors(parsed, {}),
123 'check_function': check_kentix_amp_sensors_humidity,
124 'service_description': 'Humidity %s',
125 'has_perfdata': True,
126 'group': 'humidity',
127 'includes': ["humidity.include"],
131 # .--smoke---------------------------------------------------------------.
132 # | _ |
133 # | ___ _ __ ___ ___ | | _____ |
134 # | / __| '_ ` _ \ / _ \| |/ / _ \ |
135 # | \__ \ | | | | | (_) | < __/ |
136 # | |___/_| |_| |_|\___/|_|\_\___| |
137 # | |
138 # +----------------------------------------------------------------------+
140 kentix_amp_sensors_smoke_default_levels = (1, 5)
143 def check_kentix_amp_sensors_smoke(item, params, parsed):
144 if item in parsed:
145 sensor_smoke = parsed[item]['smoke']
146 warn, crit = params
148 if sensor_smoke >= crit:
149 status = 2
150 elif sensor_smoke >= warn:
151 status = 1
152 else:
153 status = 0
155 infotext = "%.1f%%" % sensor_smoke
157 if status > 0:
158 infotext += " (warn/crit at %.1f%%/%.1f%%)" % (warn, crit)
160 perfdata = [('smoke_perc', sensor_smoke, warn, crit, 0, 100)]
162 yield status, infotext, perfdata
165 check_info['kentix_amp_sensors.smoke'] = {
166 'inventory_function': lambda parsed: inventory_kentix_amp_sensors(
167 parsed, "kentix_amp_sensors_smoke_default_levels"),
168 'check_function': check_kentix_amp_sensors_smoke,
169 'service_description': 'Smoke Detector %s',
170 'has_perfdata': True,
171 'group': 'smoke',
175 # .--leakage-------------------------------------------------------------.
176 # | _ _ |
177 # | | | ___ __ _| | ____ _ __ _ ___ |
178 # | | |/ _ \/ _` | |/ / _` |/ _` |/ _ \ |
179 # | | | __/ (_| | < (_| | (_| | __/ |
180 # | |_|\___|\__,_|_|\_\__,_|\__, |\___| |
181 # | |___/ |
182 # +----------------------------------------------------------------------+
185 def check_kentix_amp_sensors_leakage(item, params, parsed):
186 if item in parsed:
187 if parsed[item]['leakage'] > 0:
188 return 2, "Alarm or disconnected"
189 return 0, "Connected"
192 check_info['kentix_amp_sensors.leakage'] = {
193 'inventory_function': lambda i: inventory_kentix_amp_sensors(i, None),
194 'check_function': check_kentix_amp_sensors_leakage,
195 'service_description': 'Leakage %s',