2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2017 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.
28 # .1.3.6.1.2.1.1 System description
29 # .1.3.6.1.4.1.35491.30.2.0 No of Sensors - max. 100
30 # .1.3.6.1.4.1.35491.30.3 Sensor Group1
32 # 11 values per sensor
33 # .1.3.6.1.4.1.35491.30.3.1.1.0 Sensor 1 ID
34 # .1.3.6.1.4.1.35491.30.3.1.2.0 Sensor 1 value
35 # .1.3.6.1.4.1.35491.30.3.1.3.0 Sensor 1 unit
36 # .1.3.6.1.4.1.35491.30.3.1.4.0 Sensor 1 valueint -> value *1000, without comma
37 # .1.3.6.1.4.1.35491.30.3.1.5.0 Sensor 1 name
38 # .1.3.6.1.4.1.35491.30.3.1.6.0 Sensor 1 alarmint
39 # -1 = no value (also digi-input and output)
40 # 1 = lower critical alarm or green area (on digi-input)
44 # 5 = upper critical or red area (on digi-input)
45 # .1.3.6.1.4.1.35491.30.3.1.7.0 Sensor 1 LoLimitAlarmInt
46 # .1.3.6.1.4.1.35491.30.3.1.8.0 Sensor 1 LoLimitWarnInt
47 # .1.3.6.1.4.1.35491.30.3.1.9.0 Sensor 1 HiLimitWarnInt
48 # .1.3.6.1.4.1.35491.30.3.1.10.0 Sensor 1 HiLimitAlarmInt
49 # .1.3.6.1.4.1.35491.30.3.1.11.0 Sensor 1 HysterInt
51 # .1.3.6.1.4.1.35491.30.3.2.1.0 Sensor 2 ID
55 # Here a List of known sensors
57 # 20: ("digital", "Schloss"),
58 # 22: ("digital", "Relaisadapter AC"),
59 # 23: ("digital", "Digitalausgang"),
60 # 24: ("digital", "Steckdosenleiste"),
61 # 38: ("digital", "Transponderleser"),
62 # 39: ("digital", "Tastatur"),
63 # 50: ("analog", "Temperatursensor"),
64 # 51: ("digital", "Digitaleingang"),
65 # 60: ("analog", "Feuchtesensor"),
66 # 61: ("digital", "Netzspannungs Messadapter"),
67 # 62: ("digital", "Sauerstoffsensor"),
68 # 63: ("analog", "Analogsensor"),
69 # 64: ("digital", "Wechselstromzaehler"),
70 # 70: ("digital", "Zugangssensor (Tuerkontakt)"),
71 # 71: ("digital", "Erschuetterungssensor"),
72 # 72: ("digital", "Rauchmelder"),
73 # 80: ("digital", "LHX 20 RS232"),
75 # also only one sensor group is supported with this plugin!
78 def parse_security_master(info
):
86 for value
in supported_sensors
.itervalues():
89 for oid
, sensor
in info
[0]:
90 if ".5.0" not in str(oid
):
93 sensor_num
= saveint(oid
.split(".")[0])
94 service_name
= "%d %s" % (sensor_num
, sensor
)
95 num
= oid
.split(".")[0]
96 value
, sensor_id
, warn_low
, warn_high
, crit_low
, crit_high
, alarm
= (None,) * 7
98 for oid_second
, sensor_second
in info
[0]:
99 if num
+ ".1.0" == oid_second
:
100 sensor_id
= saveint(sensor_second
[0].encode('hex'))
101 elif num
+ ".2.0" == oid_second
:
103 value
= float(sensor_second
)
106 elif num
+ ".6.0" == oid_second
:
108 alarm
= int(sensor_second
)
111 elif num
+ ".7.0" == oid_second
:
112 crit_low
= savefloat(saveint(sensor_second
) / 1000.)
113 elif num
+ ".8.0" == oid_second
:
114 warn_low
= savefloat(saveint(sensor_second
) / 1000.)
115 elif num
+ ".9.0" == oid_second
:
116 warn_high
= savefloat(saveint(sensor_second
) / 1000.)
117 elif num
+ ".10.0" == oid_second
:
118 crit_high
= savefloat(saveint(sensor_second
) / 1000.)
120 if sensor_id
in supported_sensors
.keys():
121 parsed
[supported_sensors
[sensor_id
]][service_name
] = {
125 'levels_low': (warn_low
, crit_low
),
126 'levels': (warn_high
, crit_high
),
133 def inventory_security_master_sensors(parsed
, sensor_type
):
134 for sensor
in parsed
[sensor_type
]:
138 def check_security_master(item
, _no_params
, parsed
):
139 sensor
= parsed
['smoke'].get(item
)
141 return 3, "Sensor no found in SNMP output"
143 if sensor
['alarm'] == 99:
144 return 3, "Smoke Sensor is not ready or bus element removed"
146 value
= sensor
['value']
148 status
, msg
= 0, "No Smoke"
150 status
, msg
= 2, "Smoke detected"
152 status
, msg
= 3, "No Value for Sensor"
157 check_info
["security_master"] = {
158 'parse_function': parse_security_master
,
159 'check_function': check_security_master
,
160 'inventory_function': lambda parsed
: inventory_security_master_sensors(parsed
, "smoke"),
161 'service_description': 'Sensor %s',
162 'snmp_info': [('.1.3.6.1.4.1.35491.30', [OID_END
,'3']),],
163 'snmp_scan_function': lambda oid
: oid(".1.3.6.1.2.1.1.2.0").startswith("1.3.6.1.4.1.35491"),
164 'has_perfdata': False,
168 # .--humidity------------------------------------------------------------.
170 # | | |__ _ _ _ __ ___ (_) __| (_) |_ _ _ |
171 # | | '_ \| | | | '_ ` _ \| |/ _` | | __| | | | |
172 # | | | | | |_| | | | | | | | (_| | | |_| |_| | |
173 # | |_| |_|\__,_|_| |_| |_|_|\__,_|_|\__|\__, | |
175 # '----------------------------------------------------------------------'
178 def check_security_master_humidity(item
, params
, parsed
):
179 sensor
= parsed
['humidity'].get(item
)
181 return 3, "Sensor not found in SNMP output"
183 if sensor
['alarm'] is not None and sensor
['alarm'] > -1:
184 if not params
.get("levels"):
185 params
['levels'] = sensor
.get('levels')
187 if not params
.get("levels_lower"):
188 params
['levels_lower'] = sensor
.get('levels_low')
190 return check_humidity(sensor
['value'], params
)
193 check_info
["security_master.humidity"] = {
194 'inventory_function': lambda parsed
: inventory_security_master_sensors(parsed
, "humidity"),
195 'check_function': check_security_master_humidity
,
196 'service_description': 'Sensor %s',
197 'has_perfdata': True,
199 'includes': ['humidity.include'],
203 # .--temp----------------------------------------------------------------.
205 # | | |_ ___ _ __ ___ _ __ |
206 # | | __/ _ \ '_ ` _ \| '_ \ |
207 # | | || __/ | | | | | |_) | |
208 # | \__\___|_| |_| |_| .__/ |
210 # '----------------------------------------------------------------------'
213 factory_settings
['security_master_temp_default_levels'] = {
214 "device_levels_handling": "worst", # this variable is required, in order to define,
215 # which status limits are used, also 'levels' are
216 # added via WATO, if needed
220 def check_security_master_temperature(item
, params
, parsed
):
221 sensor
= parsed
['temp'].get(item
)
223 return 3, "Sensor not found in SNMP output"
225 sensor_value
= sensor
['value']
226 if sensor_value
is None:
227 return 3, "Sensor value is not in SNMP-WALK"
229 return check_temperature(reading
=sensor_value
,
233 dev_levels
=sensor
['levels'],
234 dev_levels_lower
=sensor
['levels_low'])
237 check_info
['security_master.temp'] = {
238 'inventory_function': lambda parsed
: inventory_security_master_sensors(parsed
, "temp"),
239 'check_function': check_security_master_temperature
,
240 'service_description': 'Sensor %s',
241 'has_perfdata': True,
242 'group': 'temperature',
243 'includes': ['temperature.include'],
244 'default_levels_variable': 'security_master_temp_default_levels',