Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / apc_netbotz_sensors
blob5996725ede94b30f8041fe7ae99f24eaadef6675
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2016 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 # ails. 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.5528.100.4.1.1.1.1.636159851 nbAlinkEnc_0_4_TEMP
28 # .1.3.6.1.4.1.5528.100.4.1.1.1.1.882181375 nbAlinkEnc_2_1_TEMP
29 # .1.3.6.1.4.1.5528.100.4.1.1.1.1.1619732064 nbAlinkEnc_0_2_TEMP
30 # .1.3.6.1.4.1.5528.100.4.1.1.1.1.1665932156 nbAlinkEnc_1_4_TEMP
31 # .1.3.6.1.4.1.5528.100.4.1.1.1.1.1751899818 nbAlinkEnc_2_2_TEMP
32 # .1.3.6.1.4.1.5528.100.4.1.1.1.1.1857547767 nbAlinkEnc_1_5_TEMP
33 # .1.3.6.1.4.1.5528.100.4.1.1.1.1.2370211927 nbAlinkEnc_1_6_TEMP
34 # .1.3.6.1.4.1.5528.100.4.1.1.1.1.2618588815 nbAlinkEnc_2_3_TEMP
35 # .1.3.6.1.4.1.5528.100.4.1.1.1.1.2628357572 nbAlinkEnc_0_1_TEMP
36 # .1.3.6.1.4.1.5528.100.4.1.1.1.1.3031356659 nbAlinkEnc_0_5_TEMP
37 # .1.3.6.1.4.1.5528.100.4.1.1.1.1.3056253200 nbAlinkEnc_0_6_TEMP
38 # .1.3.6.1.4.1.5528.100.4.1.1.1.1.3103062985 nbAlinkEnc_2_4_TEMP
39 # .1.3.6.1.4.1.5528.100.4.1.1.1.1.3328914949 nbAlinkEnc_1_3_TEMP
40 # .1.3.6.1.4.1.5528.100.4.1.1.1.1.3406802758 nbAlinkEnc_0_3_TEMP
41 # .1.3.6.1.4.1.5528.100.4.1.1.1.2.636159851 252
42 # .1.3.6.1.4.1.5528.100.4.1.1.1.2.882181375 222
43 # .1.3.6.1.4.1.5528.100.4.1.1.1.2.1619732064 222
44 # .1.3.6.1.4.1.5528.100.4.1.1.1.2.1665932156 216
45 # .1.3.6.1.4.1.5528.100.4.1.1.1.2.1751899818 245
46 # .1.3.6.1.4.1.5528.100.4.1.1.1.2.1857547767 234
47 # .1.3.6.1.4.1.5528.100.4.1.1.1.2.2370211927 240
48 # .1.3.6.1.4.1.5528.100.4.1.1.1.2.2618588815 220
49 # .1.3.6.1.4.1.5528.100.4.1.1.1.2.2628357572 229
50 # .1.3.6.1.4.1.5528.100.4.1.1.1.2.3031356659 0
51 # .1.3.6.1.4.1.5528.100.4.1.1.1.2.3056253200 0
52 # .1.3.6.1.4.1.5528.100.4.1.1.1.2.3103062985 215
53 # .1.3.6.1.4.1.5528.100.4.1.1.1.2.3328914949 234
54 # .1.3.6.1.4.1.5528.100.4.1.1.1.2.3406802758 238
55 # .1.3.6.1.4.1.5528.100.4.1.1.1.7.636159851 25.200000
56 # .1.3.6.1.4.1.5528.100.4.1.1.1.7.882181375 22.200000
57 # .1.3.6.1.4.1.5528.100.4.1.1.1.7.1619732064 22.200000
58 # .1.3.6.1.4.1.5528.100.4.1.1.1.7.1665932156 21.600000
59 # .1.3.6.1.4.1.5528.100.4.1.1.1.7.1751899818 24.500000
60 # .1.3.6.1.4.1.5528.100.4.1.1.1.7.1857547767 23.400000
61 # .1.3.6.1.4.1.5528.100.4.1.1.1.7.2370211927 24.000000
62 # .1.3.6.1.4.1.5528.100.4.1.1.1.7.2618588815 22.000000
63 # .1.3.6.1.4.1.5528.100.4.1.1.1.7.2628357572 22.900000
64 # .1.3.6.1.4.1.5528.100.4.1.1.1.7.3031356659
65 # .1.3.6.1.4.1.5528.100.4.1.1.1.7.3056253200
66 # .1.3.6.1.4.1.5528.100.4.1.1.1.7.3103062985 21.500000
67 # .1.3.6.1.4.1.5528.100.4.1.1.1.7.3328914949 23.400000
68 # .1.3.6.1.4.1.5528.100.4.1.1.1.7.3406802758 23.800000
70 # .1.3.6.1.4.1.5528.100.4.1.2.1.1.421607638 nbAlinkEnc_1_5_HUMI
71 # .1.3.6.1.4.1.5528.100.4.1.2.1.1.581338442 nbAlinkEnc_1_3_HUMI
72 # .1.3.6.1.4.1.5528.100.4.1.2.1.1.1121716336 nbAlinkEnc_0_6_HUMI
73 # .1.3.6.1.4.1.5528.100.4.1.2.1.1.3273299739 nbAlinkEnc_0_3_HUMI
74 # .1.3.6.1.4.1.5528.100.4.1.2.1.1.4181308384 nbAlinkEnc_0_5_HUMI
75 # .1.3.6.1.4.1.5528.100.4.1.2.1.2.421607638 370
76 # .1.3.6.1.4.1.5528.100.4.1.2.1.2.581338442 320
77 # .1.3.6.1.4.1.5528.100.4.1.2.1.2.1121716336 0
78 # .1.3.6.1.4.1.5528.100.4.1.2.1.2.3273299739 320
79 # .1.3.6.1.4.1.5528.100.4.1.2.1.2.4181308384 0
80 # .1.3.6.1.4.1.5528.100.4.1.2.1.7.421607638 37.000000
81 # .1.3.6.1.4.1.5528.100.4.1.2.1.7.581338442 32.000000
82 # .1.3.6.1.4.1.5528.100.4.1.2.1.7.1121716336
83 # .1.3.6.1.4.1.5528.100.4.1.2.1.7.3273299739 32.000000
84 # .1.3.6.1.4.1.5528.100.4.1.2.1.7.4181308384
86 # .1.3.6.1.4.1.5528.100.4.1.3.1.1.1000015730 nbAlinkEnc_0_5_DWPT
87 # .1.3.6.1.4.1.5528.100.4.1.3.1.1.1490079962 nbAlinkEnc_0_3_DWPT
88 # .1.3.6.1.4.1.5528.100.4.1.3.1.1.2228353183 nbAlinkEnc_0_6_DWPT
89 # .1.3.6.1.4.1.5528.100.4.1.3.1.1.2428087247 nbAlinkEnc_1_3_DWPT
90 # .1.3.6.1.4.1.5528.100.4.1.3.1.1.3329736831 nbAlinkEnc_1_5_DWPT
91 # .1.3.6.1.4.1.5528.100.4.1.3.1.2.1000015730 0
92 # .1.3.6.1.4.1.5528.100.4.1.3.1.2.1490079962 61
93 # .1.3.6.1.4.1.5528.100.4.1.3.1.2.2228353183 0
94 # .1.3.6.1.4.1.5528.100.4.1.3.1.2.2428087247 57
95 # .1.3.6.1.4.1.5528.100.4.1.3.1.2.3329736831 78
96 # .1.3.6.1.4.1.5528.100.4.1.3.1.7.1000015730
97 # .1.3.6.1.4.1.5528.100.4.1.3.1.7.1490079962 6.100000
98 # .1.3.6.1.4.1.5528.100.4.1.3.1.7.2228353183
99 # .1.3.6.1.4.1.5528.100.4.1.3.1.7.2428087247 5.700000
100 # .1.3.6.1.4.1.5528.100.4.1.3.1.7.3329736831 7.800000
102 # .--temperature---------------------------------------------------------.
103 # | _ _ |
104 # | | |_ ___ _ __ ___ _ __ ___ _ __ __ _| |_ _ _ _ __ ___ |
105 # | | __/ _ \ '_ ` _ \| '_ \ / _ \ '__/ _` | __| | | | '__/ _ \ |
106 # | | || __/ | | | | | |_) | __/ | | (_| | |_| |_| | | | __/ |
107 # | \__\___|_| |_| |_| .__/ \___|_| \__,_|\__|\__,_|_| \___| |
108 # | |_| |
109 # +----------------------------------------------------------------------+
110 # | main check |
111 # '----------------------------------------------------------------------'
113 # Suggested by customer
114 factory_settings['apc_netbotz_sensors_temp_default_levels'] = {
115 'levels': (30, 35),
116 'levels_lower': (25, 20),
120 def parse_apc_netbotz_sensors(info):
121 map_sensors = {
122 "1": "temp",
123 "2": "humidity",
124 "3": "dewpoint",
126 parsed = {}
127 for oid_item, reading_str, label, plugged_in_state in info:
128 if plugged_in_state:
129 item_info = oid_item.split(".")
130 item_type = map_sensors[item_info[0]]
131 item_name = " ".join(item_info[2:])
132 parsed.setdefault(item_type, {}).setdefault(item_name, {
133 "reading": float(reading_str) / 10,
134 "label": label
136 return parsed
139 def inventory_apc_netbotz_sensors_temp(parsed, what):
140 return [(item, {}) for item in parsed.get(what, [])]
143 def check_apc_netbotz_sensors_temp(item, params, parsed, what):
144 if item in parsed.get(what, []):
145 data = parsed[what][item]
146 state, infotext, perf = check_temperature(data['reading'], params,
147 "apc_netbotz_sensors_%s_%s" % (what, item))
148 return state, "[%s] %s" % (data['label'], infotext), perf
150 check_info['apc_netbotz_sensors'] = {
151 'parse_function' : parse_apc_netbotz_sensors,
152 'inventory_function' : lambda parsed: \
153 inventory_apc_netbotz_sensors_temp(parsed, "temp"),
154 'check_function' : lambda item, params, parsed: \
155 check_apc_netbotz_sensors_temp(item, params, parsed, "temp"),
156 'service_description' : 'Temperature %s',
157 'has_perfdata' : True,
158 'snmp_info' : (".1.3.6.1.4.1.5528.100.4.1", [
159 "1.1", # temp
160 "2.1", # humi
161 "3.1", # dewPoint
162 ], [
163 "1", # NETBOTZV2-MIB::*SensorId
164 "2", # NETBOTZV2-MIB::*SensorValue
165 "4", # NETBOTZV2-MIB::*SensorLabel
166 "7", # NETBOTZV2-MIB::*ValueStr; empty if sensor is not plugged in
168 'snmp_scan_function' : lambda oid: \
169 oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.5528.100.20.10"),
170 'default_levels_variable' : 'apc_netbotz_sensors_temp_default_levels',
171 'group' : "temperature",
172 'includes' : [ 'temperature.include' ],
176 # .--dewpoint------------------------------------------------------------.
177 # | _ _ _ |
178 # | __| | _____ ___ __ ___ (_)_ __ | |_ |
179 # | / _` |/ _ \ \ /\ / / '_ \ / _ \| | '_ \| __| |
180 # | | (_| | __/\ V V /| |_) | (_) | | | | | |_ |
181 # | \__,_|\___| \_/\_/ | .__/ \___/|_|_| |_|\__| |
182 # | |_| |
183 # '----------------------------------------------------------------------'
185 # Suggested by customer
186 factory_settings['apc_netbotz_sensors_dewpoint_default_levels'] = {
187 'levels': (18, 25),
188 'levels_lower': (-4, -6),
192 check_info['apc_netbotz_sensors.dewpoint'] = {
193 'inventory_function' : lambda parsed: \
194 inventory_apc_netbotz_sensors_temp(parsed, "dewpoint"),
195 'check_function' : lambda item, params, info: \
196 check_apc_netbotz_sensors_temp(item, params, info, "dewpoint"),
197 'service_description' : 'Dew point %s',
198 'has_perfdata' : True,
199 'default_levels_variable' : "apc_netbotz_sensors_dewpoint_default_levels",
200 'group' : "temperature",
201 'includes' : [ 'temperature.include' ],
205 # .--humidity------------------------------------------------------------.
206 # | _ _ _ _ _ |
207 # | | |__ _ _ _ __ ___ (_) __| (_) |_ _ _ |
208 # | | '_ \| | | | '_ ` _ \| |/ _` | | __| | | | |
209 # | | | | | |_| | | | | | | | (_| | | |_| |_| | |
210 # | |_| |_|\__,_|_| |_| |_|_|\__,_|_|\__|\__, | |
211 # | |___/ |
212 # '----------------------------------------------------------------------'
214 # Suggested by customer
215 apc_netbotz_sensors_humidity_default_levels = (30, 35, 60, 65)
218 def inventory_apc_netbotz_sensors_humidity(parsed):
219 return [ (item, "apc_netbotz_sensors_humidity_default_levels") \
220 for item in parsed.get("humidity", []) ]
223 def check_apc_netbotz_sensors_humidity(item, params, parsed):
224 if item in parsed.get("humidity", []):
225 data = parsed["humidity"][item]
226 state, infotext, perf = check_humidity(data['reading'], params)
227 return state, "[%s] %s" % (data['label'], infotext), perf
230 check_info['apc_netbotz_sensors.humidity'] = {
231 'inventory_function': inventory_apc_netbotz_sensors_humidity,
232 'check_function': check_apc_netbotz_sensors_humidity,
233 'service_description': 'Humidity %s',
234 'has_perfdata': True,
235 'group': "humidity",
236 'includes': ['humidity.include'],