Refactored snapin server_time to new snapin API
[check_mk.git] / checks / apc_netbotz_sensors
blobaac99ee6a8b18fa0123df5a6fec7d104d52d1b68
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.
28 # .1.3.6.1.4.1.5528.100.4.1.1.1.1.636159851 nbAlinkEnc_0_4_TEMP
29 # .1.3.6.1.4.1.5528.100.4.1.1.1.1.882181375 nbAlinkEnc_2_1_TEMP
30 # .1.3.6.1.4.1.5528.100.4.1.1.1.1.1619732064 nbAlinkEnc_0_2_TEMP
31 # .1.3.6.1.4.1.5528.100.4.1.1.1.1.1665932156 nbAlinkEnc_1_4_TEMP
32 # .1.3.6.1.4.1.5528.100.4.1.1.1.1.1751899818 nbAlinkEnc_2_2_TEMP
33 # .1.3.6.1.4.1.5528.100.4.1.1.1.1.1857547767 nbAlinkEnc_1_5_TEMP
34 # .1.3.6.1.4.1.5528.100.4.1.1.1.1.2370211927 nbAlinkEnc_1_6_TEMP
35 # .1.3.6.1.4.1.5528.100.4.1.1.1.1.2618588815 nbAlinkEnc_2_3_TEMP
36 # .1.3.6.1.4.1.5528.100.4.1.1.1.1.2628357572 nbAlinkEnc_0_1_TEMP
37 # .1.3.6.1.4.1.5528.100.4.1.1.1.1.3031356659 nbAlinkEnc_0_5_TEMP
38 # .1.3.6.1.4.1.5528.100.4.1.1.1.1.3056253200 nbAlinkEnc_0_6_TEMP
39 # .1.3.6.1.4.1.5528.100.4.1.1.1.1.3103062985 nbAlinkEnc_2_4_TEMP
40 # .1.3.6.1.4.1.5528.100.4.1.1.1.1.3328914949 nbAlinkEnc_1_3_TEMP
41 # .1.3.6.1.4.1.5528.100.4.1.1.1.1.3406802758 nbAlinkEnc_0_3_TEMP
42 # .1.3.6.1.4.1.5528.100.4.1.1.1.2.636159851 252
43 # .1.3.6.1.4.1.5528.100.4.1.1.1.2.882181375 222
44 # .1.3.6.1.4.1.5528.100.4.1.1.1.2.1619732064 222
45 # .1.3.6.1.4.1.5528.100.4.1.1.1.2.1665932156 216
46 # .1.3.6.1.4.1.5528.100.4.1.1.1.2.1751899818 245
47 # .1.3.6.1.4.1.5528.100.4.1.1.1.2.1857547767 234
48 # .1.3.6.1.4.1.5528.100.4.1.1.1.2.2370211927 240
49 # .1.3.6.1.4.1.5528.100.4.1.1.1.2.2618588815 220
50 # .1.3.6.1.4.1.5528.100.4.1.1.1.2.2628357572 229
51 # .1.3.6.1.4.1.5528.100.4.1.1.1.2.3031356659 0
52 # .1.3.6.1.4.1.5528.100.4.1.1.1.2.3056253200 0
53 # .1.3.6.1.4.1.5528.100.4.1.1.1.2.3103062985 215
54 # .1.3.6.1.4.1.5528.100.4.1.1.1.2.3328914949 234
55 # .1.3.6.1.4.1.5528.100.4.1.1.1.2.3406802758 238
56 # .1.3.6.1.4.1.5528.100.4.1.1.1.7.636159851 25.200000
57 # .1.3.6.1.4.1.5528.100.4.1.1.1.7.882181375 22.200000
58 # .1.3.6.1.4.1.5528.100.4.1.1.1.7.1619732064 22.200000
59 # .1.3.6.1.4.1.5528.100.4.1.1.1.7.1665932156 21.600000
60 # .1.3.6.1.4.1.5528.100.4.1.1.1.7.1751899818 24.500000
61 # .1.3.6.1.4.1.5528.100.4.1.1.1.7.1857547767 23.400000
62 # .1.3.6.1.4.1.5528.100.4.1.1.1.7.2370211927 24.000000
63 # .1.3.6.1.4.1.5528.100.4.1.1.1.7.2618588815 22.000000
64 # .1.3.6.1.4.1.5528.100.4.1.1.1.7.2628357572 22.900000
65 # .1.3.6.1.4.1.5528.100.4.1.1.1.7.3031356659
66 # .1.3.6.1.4.1.5528.100.4.1.1.1.7.3056253200
67 # .1.3.6.1.4.1.5528.100.4.1.1.1.7.3103062985 21.500000
68 # .1.3.6.1.4.1.5528.100.4.1.1.1.7.3328914949 23.400000
69 # .1.3.6.1.4.1.5528.100.4.1.1.1.7.3406802758 23.800000
71 # .1.3.6.1.4.1.5528.100.4.1.2.1.1.421607638 nbAlinkEnc_1_5_HUMI
72 # .1.3.6.1.4.1.5528.100.4.1.2.1.1.581338442 nbAlinkEnc_1_3_HUMI
73 # .1.3.6.1.4.1.5528.100.4.1.2.1.1.1121716336 nbAlinkEnc_0_6_HUMI
74 # .1.3.6.1.4.1.5528.100.4.1.2.1.1.3273299739 nbAlinkEnc_0_3_HUMI
75 # .1.3.6.1.4.1.5528.100.4.1.2.1.1.4181308384 nbAlinkEnc_0_5_HUMI
76 # .1.3.6.1.4.1.5528.100.4.1.2.1.2.421607638 370
77 # .1.3.6.1.4.1.5528.100.4.1.2.1.2.581338442 320
78 # .1.3.6.1.4.1.5528.100.4.1.2.1.2.1121716336 0
79 # .1.3.6.1.4.1.5528.100.4.1.2.1.2.3273299739 320
80 # .1.3.6.1.4.1.5528.100.4.1.2.1.2.4181308384 0
81 # .1.3.6.1.4.1.5528.100.4.1.2.1.7.421607638 37.000000
82 # .1.3.6.1.4.1.5528.100.4.1.2.1.7.581338442 32.000000
83 # .1.3.6.1.4.1.5528.100.4.1.2.1.7.1121716336
84 # .1.3.6.1.4.1.5528.100.4.1.2.1.7.3273299739 32.000000
85 # .1.3.6.1.4.1.5528.100.4.1.2.1.7.4181308384
87 # .1.3.6.1.4.1.5528.100.4.1.3.1.1.1000015730 nbAlinkEnc_0_5_DWPT
88 # .1.3.6.1.4.1.5528.100.4.1.3.1.1.1490079962 nbAlinkEnc_0_3_DWPT
89 # .1.3.6.1.4.1.5528.100.4.1.3.1.1.2228353183 nbAlinkEnc_0_6_DWPT
90 # .1.3.6.1.4.1.5528.100.4.1.3.1.1.2428087247 nbAlinkEnc_1_3_DWPT
91 # .1.3.6.1.4.1.5528.100.4.1.3.1.1.3329736831 nbAlinkEnc_1_5_DWPT
92 # .1.3.6.1.4.1.5528.100.4.1.3.1.2.1000015730 0
93 # .1.3.6.1.4.1.5528.100.4.1.3.1.2.1490079962 61
94 # .1.3.6.1.4.1.5528.100.4.1.3.1.2.2228353183 0
95 # .1.3.6.1.4.1.5528.100.4.1.3.1.2.2428087247 57
96 # .1.3.6.1.4.1.5528.100.4.1.3.1.2.3329736831 78
97 # .1.3.6.1.4.1.5528.100.4.1.3.1.7.1000015730
98 # .1.3.6.1.4.1.5528.100.4.1.3.1.7.1490079962 6.100000
99 # .1.3.6.1.4.1.5528.100.4.1.3.1.7.2228353183
100 # .1.3.6.1.4.1.5528.100.4.1.3.1.7.2428087247 5.700000
101 # .1.3.6.1.4.1.5528.100.4.1.3.1.7.3329736831 7.800000
104 # .--temperature---------------------------------------------------------.
105 # | _ _ |
106 # | | |_ ___ _ __ ___ _ __ ___ _ __ __ _| |_ _ _ _ __ ___ |
107 # | | __/ _ \ '_ ` _ \| '_ \ / _ \ '__/ _` | __| | | | '__/ _ \ |
108 # | | || __/ | | | | | |_) | __/ | | (_| | |_| |_| | | | __/ |
109 # | \__\___|_| |_| |_| .__/ \___|_| \__,_|\__|\__,_|_| \___| |
110 # | |_| |
111 # +----------------------------------------------------------------------+
112 # | main check |
113 # '----------------------------------------------------------------------'
116 # Suggested by customer
117 factory_settings['apc_netbotz_sensors_temp_default_levels'] = {
118 'levels' : (30, 35),
119 'levels_lower' : (25, 20),
123 def parse_apc_netbotz_sensors(info):
124 map_sensors = {
125 "1" : "temp",
126 "2" : "humidity",
127 "3" : "dewpoint",
129 parsed = {}
130 for oid_item, reading_str, plugged_in_state in info:
131 if plugged_in_state:
132 item_info = oid_item.split(".")
133 item_type = map_sensors[item_info[0]]
134 item_name = " ".join(item_info[2:])
135 parsed.setdefault(item_type, {})
136 parsed[item_type][item_name] = float(reading_str)/10
138 return parsed
141 def inventory_apc_netbotz_sensors_temp(parsed, what):
142 return [ (item, {}) for item in parsed.get(what, []) ]
145 def check_apc_netbotz_sensors_temp(item, params, parsed, what):
146 if item in parsed.get(what, []):
147 return check_temperature(parsed[what][item], params, "apc_netbotz_sensors_%s_%s" % (what, item))
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 "7", # NETBOTZV2-MIB::*ValueStr
166 # 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' ],
177 # .--dewpoint------------------------------------------------------------.
178 # | _ _ _ |
179 # | __| | _____ ___ __ ___ (_)_ __ | |_ |
180 # | / _` |/ _ \ \ /\ / / '_ \ / _ \| | '_ \| __| |
181 # | | (_| | __/\ V V /| |_) | (_) | | | | | |_ |
182 # | \__,_|\___| \_/\_/ | .__/ \___/|_|_| |_|\__| |
183 # | |_| |
184 # '----------------------------------------------------------------------'
187 # Suggested by customer
188 factory_settings['apc_netbotz_sensors_dewpoint_default_levels'] = {
189 'levels' : (18, 25),
190 'levels_lower' : (-4, -6),
194 check_info['apc_netbotz_sensors.dewpoint'] = {
195 'inventory_function' : lambda parsed: \
196 inventory_apc_netbotz_sensors_temp(parsed, "dewpoint"),
197 'check_function' : lambda item, params, info: \
198 check_apc_netbotz_sensors_temp(item, params, info, "dewpoint"),
199 'service_description' : 'Dew point %s',
200 'has_perfdata' : True,
201 'default_levels_variable' : "apc_netbotz_sensors_dewpoint_default_levels",
202 'group' : "temperature",
203 'includes' : [ 'temperature.include' ],
208 # .--humidity------------------------------------------------------------.
209 # | _ _ _ _ _ |
210 # | | |__ _ _ _ __ ___ (_) __| (_) |_ _ _ |
211 # | | '_ \| | | | '_ ` _ \| |/ _` | | __| | | | |
212 # | | | | | |_| | | | | | | | (_| | | |_| |_| | |
213 # | |_| |_|\__,_|_| |_| |_|_|\__,_|_|\__|\__, | |
214 # | |___/ |
215 # '----------------------------------------------------------------------'
218 # Suggested by customer
219 apc_netbotz_sensors_humidity_default_levels = (30, 35, 60, 65)
222 def inventory_apc_netbotz_sensors_humidity(parsed):
223 return [ (item, "apc_netbotz_sensors_humidity_default_levels") \
224 for item in parsed.get("humidity", []) ]
227 def check_apc_netbotz_sensors_humidity(item, params, parsed):
228 if item in parsed.get("humidity", []):
229 return check_humidity(parsed["humidity"][item], params)
232 check_info['apc_netbotz_sensors.humidity'] = {
233 'inventory_function' : inventory_apc_netbotz_sensors_humidity,
234 'check_function' : check_apc_netbotz_sensors_humidity,
235 'service_description' : 'Humidity %s',
236 'has_perfdata' : True,
237 'group' : "humidity",
238 'includes' : [ 'humidity.include' ],