Cleanup config.nodes_of
[check_mk.git] / checks / wagner_titanus_topsense
blob8b5dcf908e29f1940f2a3609c9ce7085f647ada1
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2014 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 wagner_titanus_topsense_info = [
29 ".1.3.6.1.2.1.1",
31 1, # sysDescr 0
32 3, # sysUpTimeInstance 1
33 4, # sysContact 2
34 5, # sysName 3
35 6, # sysLocation 4
36 ]),
37 # topsens LSN
39 ".1.3.6.1.4.1.34187.21501.1.1",
41 1, # company 0
42 2, # model 1
43 3, # revision 2
44 1000, # pswMainAlarmD1 3
45 1001, # pswPreAlarmD1 4
46 1002, # pswInfAlarmD1 5
47 1003, # pswMainAlarmD2 6
48 1004, # pswPreAlarmD2 7
49 1005, # pswInfAlarmD2 8
50 1006, # pswFailureDisplayOn 9
51 ]), # off(0), on(1)
53 ".1.3.6.1.4.1.34187.21501.2.1",
55 245810000, # tsBarGraph1String
56 245820000, # tsBarGraph2String
57 245950000, # tsD1ChamberValueString
58 246090000, # tsD2ChamberValueString
59 245960000, # tsD1AirFlowDeviationString
60 246100000, # tsD2AirFlowDeviationString
61 245970000, # tsD1AirTemperatureString
62 246110000, # tsD2AirTemperatureString
63 24584008, # tsLSNbusOnline 0
64 # offline(0),online(1)
65 ]),
66 # topsens non-LSN
68 ".1.3.6.1.4.1.34187.74195.1.1",
70 1, # company 0
71 2, # model 1
72 3, # revision 2
73 1000, # pswMainAlarmD1 3
74 1001, # pswPreAlarmD1 4
75 1002, # pswInfAlarmD1 5
76 1003, # pswMainAlarmD2 6
77 1004, # pswPreAlarmD2 7
78 1005, # pswInfAlarmD2 8
79 1006, # pswFailureDisplayOn 9
80 ]), # off(0), on(1)
82 ".1.3.6.1.4.1.34187.74195.2.1",
84 245790000, # tsBarGraph1String
85 245800000, # tsBarGraph2String
86 245940000, # tsD1ChamberValueString
87 246060000, # tsD2ChamberValueString
88 245950000, # tsD1AirFlowDeviationString
89 246070000, # tsD2AirFlowDeviationString
90 245960000, # tsD1AirTemperatureString
91 246080000, # tsD2AirTemperatureString
92 ]),
96 def wagner_titanus_topsense_scan(oid):
97 return oid(".1.3.6.1.2.1.1.2.0") in [".1.3.6.1.4.1.34187.21501", ".1.3.6.1.4.1.34187.74195"]
100 def parse_wagner_titanus_topsens(info):
101 # not much of a parse function. simply retrieves the info blocks that apply for the
102 # respective topsens model and returns only those
103 res = [info[0], info[1] or info[3], info[2] or info[4]]
104 return res
107 # .--titanus info--------------------------------------------------------.
108 # | _ _ _ _ __ |
109 # | | |_(_) |_ __ _ _ __ _ _ ___ (_)_ __ / _| ___ |
110 # | | __| | __/ _` | '_ \| | | / __| | | '_ \| |_ / _ \ |
111 # | | |_| | || (_| | | | | |_| \__ \ | | | | | _| (_) | |
112 # | \__|_|\__\__,_|_| |_|\__,_|___/ |_|_| |_|_| \___/ |
113 # | |
114 # '----------------------------------------------------------------------'
117 def inventory_wagner_titanus_topsense_info(info):
118 return [(None, None)]
121 def check_wagner_titanus_topsense_info(item, _no_params, info):
122 parsed = parse_wagner_titanus_topsens(info)
123 message = "System: " + parsed[0][0][0]
124 message += ", Uptime: " + get_age_human_readable(int(parsed[0][0][1]) / 100)
125 message += ", System Name: " + parsed[0][0][3]
126 message += ", System Contact: " + parsed[0][0][2]
127 message += ", System Location: " + parsed[0][0][4]
128 message += ", Company: " + parsed[1][0][0]
129 message += ", Model: " + parsed[1][0][1]
130 message += ", Revision: " + parsed[1][0][2]
131 if len(info) > 8:
132 ts_lsn_bus = parsed[2][0][8]
133 if ts_lsn_bus == "0":
134 ts_lsn_bus = "offline"
135 elif ts_lsn_bus == "1":
136 ts_lsn_bus = "online"
137 else:
138 ts_lsn_bus = "unknown"
140 message += ", LSNi bus: " + ts_lsn_bus
141 return 0, message
144 check_info["wagner_titanus_topsense.info"] = {
145 "check_function": check_wagner_titanus_topsense_info,
146 "inventory_function": inventory_wagner_titanus_topsense_info,
147 "service_description": "Topsense Info",
148 "snmp_info": wagner_titanus_topsense_info,
149 "snmp_scan_function": wagner_titanus_topsense_scan
153 # .--overall status------------------------------------------------------.
154 # | _ _ _ _ |
155 # | _____ _____ _ __ __ _| | | ___| |_ __ _| |_ _ _ ___ |
156 # | / _ \ \ / / _ \ '__/ _` | | | / __| __/ _` | __| | | / __| |
157 # | | (_) \ V / __/ | | (_| | | | \__ \ || (_| | |_| |_| \__ \ |
158 # | \___/ \_/ \___|_| \__,_|_|_| |___/\__\__,_|\__|\__,_|___/ |
159 # | |
160 # '----------------------------------------------------------------------'
163 def inventory_wagner_titanus_topsense_overall_status(info):
164 return [(None, None)]
167 def check_wagner_titanus_topsense_overall_status(item, _no_params, info):
168 parsed = parse_wagner_titanus_topsens(info)
169 psw_failure = parsed[1][0][9]
170 status = 3
171 if psw_failure == "0":
172 message = "Overall Status reports OK"
173 status = 0
174 else:
175 message = "Overall Status reports a problem"
176 status = 2
177 return status, message
180 check_info["wagner_titanus_topsense.overall_status"] = {
181 "check_function": check_wagner_titanus_topsense_overall_status,
182 "inventory_function": inventory_wagner_titanus_topsense_overall_status,
183 "service_description": "Overall Status",
184 "snmp_info": wagner_titanus_topsense_info,
185 "snmp_scan_function": wagner_titanus_topsense_scan
189 # .--alarm---------------------------------------------------------------.
190 # | _ |
191 # | __ _| | __ _ _ __ _ __ ___ |
192 # | / _` | |/ _` | '__| '_ ` _ \ |
193 # | | (_| | | (_| | | | | | | | | |
194 # | \__,_|_|\__,_|_| |_| |_| |_| |
195 # | |
196 # '----------------------------------------------------------------------'
199 def inventory_wagner_titanus_topsense_alarm(info):
200 return [("1", None), ("2", None)]
203 def check_wagner_titanus_topsense_alarm(item, _no_params, info):
204 parsed = parse_wagner_titanus_topsens(info)
205 if item == "1":
206 main_alarm = parsed[1][0][3]
207 pre_alarm = parsed[1][0][4]
208 info_alarm = parsed[1][0][5]
209 elif item == "2":
210 main_alarm = parsed[1][0][6]
211 pre_alarm = parsed[1][0][7]
212 info_alarm = parsed[1][0][8]
213 else:
214 return 3, "Alarm Detector %s not found in SNMP" % item
216 status = 0
217 message = "No Alarm"
218 if info_alarm != "0":
219 message = "Info Alarm"
220 status = 1
221 if pre_alarm != "0":
222 message = "Pre Alarm"
223 status = 1
224 if main_alarm != "0":
225 message = "Main Alarm: Fire"
226 status = 2
228 return status, message
231 check_info["wagner_titanus_topsense.alarm"] = {
232 "check_function": check_wagner_titanus_topsense_alarm,
233 "inventory_function": inventory_wagner_titanus_topsense_alarm,
234 "service_description": "Alarm Detector %s",
235 "snmp_info": wagner_titanus_topsense_info,
236 "snmp_scan_function": wagner_titanus_topsense_scan
240 # .--smoke percent-------------------------------------------------------.
241 # | _ _ |
242 # | ___ _ __ ___ ___ | | _____ _ __ ___ _ __ ___ ___ _ __ | |_ |
243 # | / __| '_ ` _ \ / _ \| |/ / _ \ | '_ \ / _ \ '__/ __/ _ \ '_ \| __| |
244 # | \__ \ | | | | | (_) | < __/ | |_) | __/ | | (_| __/ | | | |_ |
245 # | |___/_| |_| |_|\___/|_|\_\___| | .__/ \___|_| \___\___|_| |_|\__| |
246 # | |_| |
247 # '----------------------------------------------------------------------'
250 def inventory_wagner_titanus_topsense_smoke(info):
251 return [("1", None), ("2", None)]
254 def check_wagner_titanus_topsense_smoke(item, _no_params, info):
255 parsed = parse_wagner_titanus_topsens(info)
256 if item == "1":
257 smoke_perc = float(parsed[2][0][0])
258 elif item == "2":
259 smoke_perc = float(parsed[2][0][1])
260 else:
261 return 3, "Smoke Detector %s not found in SNMP" % item
263 perfdata = [("smoke_perc", smoke_perc)]
264 if smoke_perc > 5:
265 status = 2
266 elif smoke_perc > 3:
267 status = 1
268 else:
269 status = 0
271 return status, "%0.6f%% smoke detected" % smoke_perc, perfdata
274 check_info["wagner_titanus_topsense.smoke"] = {
275 "check_function": check_wagner_titanus_topsense_smoke,
276 "inventory_function": inventory_wagner_titanus_topsense_smoke,
277 "service_description": "Smoke Detector %s",
278 "has_perfdata": True,
279 "snmp_info": wagner_titanus_topsense_info,
280 "snmp_scan_function": wagner_titanus_topsense_scan
284 # .--chamber deviation---------------------------------------------------.
285 # | _ _ _ |
286 # | ___| |__ __ _ _ __ ___ | |__ ___ _ __ __| | _____ __ |
287 # | / __| '_ \ / _` | '_ ` _ \| '_ \ / _ \ '__| / _` |/ _ \ \ / / |
288 # | | (__| | | | (_| | | | | | | |_) | __/ | | (_| | __/\ V / |
289 # | \___|_| |_|\__,_|_| |_| |_|_.__/ \___|_| \__,_|\___| \_/ |
290 # | |
291 # '----------------------------------------------------------------------'
294 def inventory_wagner_titanus_topsense_chamber_deviation(info):
295 return [("1", None), ("2", None)]
298 def check_wagner_titanus_topsense_chamber_deviation(item, _no_params, info):
299 parsed = parse_wagner_titanus_topsens(info)
300 if item == "1":
301 chamber_deviation = float(parsed[2][0][2])
302 elif item == "2":
303 chamber_deviation = float(parsed[2][0][3])
304 else:
305 return 3, "Chamber Deviation Detector %s not found in SNMP" % item
307 perfdata = [("chamber_deviation", chamber_deviation)]
309 return 0, "%0.6f%% Chamber Deviation" % chamber_deviation, perfdata
312 check_info["wagner_titanus_topsense.chamber_deviation"] = {
313 "check_function": check_wagner_titanus_topsense_chamber_deviation,
314 "inventory_function": inventory_wagner_titanus_topsense_chamber_deviation,
315 "service_description": "Chamber Deviation Detector %s",
316 "has_perfdata": True,
317 "snmp_info": wagner_titanus_topsense_info,
318 "snmp_scan_function": wagner_titanus_topsense_scan
322 # .--air flow deviation--------------------------------------------------.
323 # | _ __ _ _ |
324 # | __ _(_)_ __ / _| | _____ __ __| | _____ __ |
325 # | / _` | | '__| | |_| |/ _ \ \ /\ / / / _` |/ _ \ \ / / |
326 # | | (_| | | | | _| | (_) \ V V / | (_| | __/\ V / |
327 # | \__,_|_|_| |_| |_|\___/ \_/\_/ \__,_|\___| \_/ |
328 # | |
329 # '----------------------------------------------------------------------'
331 wagner_titanus_topsense_airflow_deviation_default_values = (-20.0, -20.0, 20.0, 20.0)
334 def inventory_wagner_titanus_topsense_airflow_deviation(info):
335 return [("1", "wagner_titanus_topsense_airflow_deviation_default_values"),
336 ("2", "wagner_titanus_topsense_airflow_deviation_default_values")]
339 def check_wagner_titanus_topsense_airflow_deviation(item, params, info):
340 parsed = parse_wagner_titanus_topsens(info)
341 lower_crit, lower_warn, upper_warn, upper_crit = params
342 status = 0
343 if item == "1":
344 airflow_deviation = float(parsed[2][0][4])
345 elif item == "2":
346 airflow_deviation = float(parsed[2][0][5])
347 else:
348 return 3, "Airflow Deviation Detector %s not found in SNMP" % item
350 if airflow_deviation >= upper_warn or airflow_deviation <= lower_warn:
351 status = 1
352 if airflow_deviation >= upper_crit or airflow_deviation <= lower_crit:
353 status = 2
355 perfdata = [("airflow_deviation", airflow_deviation, upper_warn, upper_crit, 0)]
357 return status, "Airflow Deviation is %0.6f%%" % airflow_deviation, perfdata
360 check_info["wagner_titanus_topsense.airflow_deviation"] = {
361 "check_function": check_wagner_titanus_topsense_airflow_deviation,
362 "inventory_function": inventory_wagner_titanus_topsense_airflow_deviation,
363 "service_description": "Airflow Deviation Detector %s",
364 "has_perfdata": True,
365 "group": "airflow_deviation",
366 "snmp_info": wagner_titanus_topsense_info,
367 "snmp_scan_function": wagner_titanus_topsense_scan
371 # .--air temp------------------------------------------------------------.
372 # | _ _ |
373 # | __ _(_)_ __ | |_ ___ _ __ ___ _ __ |
374 # | / _` | | '__| | __/ _ \ '_ ` _ \| '_ \ |
375 # | | (_| | | | | || __/ | | | | | |_) | |
376 # | \__,_|_|_| \__\___|_| |_| |_| .__/ |
377 # | |_| |
378 # '----------------------------------------------------------------------'
380 factory_settings["wagner_titanus_topsense_temperature_default_values"] = {
381 "levels": (30, 35),
385 def inventory_wagner_titanus_topsense_temp(info):
386 return [("Ambient 1", {}), ("Ambient 2", {})]
389 def check_wagner_titanus_topsense_temp(item, params, info):
390 parsed = parse_wagner_titanus_topsens(info)
391 if not item.startswith("Ambient"):
392 item = "Ambient %s" % item
394 if item == "Ambient 1":
395 temp = float(parsed[2][0][6])
396 elif item == "Ambient 2":
397 temp = float(parsed[2][0][7])
398 else:
399 return
401 return check_temperature(temp, params, "wagner_titanus_topsense_%s" % item)
404 check_info["wagner_titanus_topsense.temp"] = {
405 "check_function": check_wagner_titanus_topsense_temp,
406 "default_levels_variable": "wagner_titanus_topsense_temperature_default_values",
407 "inventory_function": inventory_wagner_titanus_topsense_temp,
408 "service_description": "Temperature %s",
409 "has_perfdata": True,
410 "group": "temperature",
411 "snmp_info": wagner_titanus_topsense_info,
412 "snmp_scan_function": wagner_titanus_topsense_scan,
413 "includes": ["temperature.include"],