Cleanup config.nodes_of
[check_mk.git] / checks / ispro_sensors_digital
blobed132727a0e0eb9ff1b4819bd8afd3a668a17ee4
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 # 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.19011.1.3.2.1.3.1.3.1.2.1 "Water Sensor-R" --> ISPRO-MIB::isDeviceMonitorDigitalInName
28 # .1.3.6.1.4.1.19011.1.3.2.1.3.1.3.1.4.1 1 --> ISPRO-MIB::isDeviceMonitorDigitalInAlarm
29 # .1.3.6.1.4.1.19011.1.3.2.1.3.2.4.1.3.1 2 --> ISPRO-MIB::isDeviceConfigDigitalInState
32 def inventory_ispro_sensors_digital(info):
33 return [(line[0], None) for line in info if line[0] and line[2] != "1"]
36 def check_ispro_sensors_digital(item, params, info):
37 map_states = {
38 "state": {
39 "1": "disabled",
40 "2": "normal open",
41 "3": "normal close",
43 "alarm": {
44 "1": (0, "normal", "active"),
45 "2": (2, "alarm", "inactive"),
49 for name, alarm, state in info:
50 if item == name:
51 # more readable, avoiding confusion
52 alarm_state, alarm_state_readable, alarm_device_state_readable = \
53 map_states["alarm"].get(alarm, (3, "unknown", "unexpected(%s)" % alarm))
54 return alarm_state, 'Status: %s, Alarm status: %s (device: %s)' % \
55 (map_states["state"].get(state, "unexpected(%s)" % state),
56 alarm_state_readable, alarm_device_state_readable )
59 check_info['ispro_sensors_digital'] = {
60 'inventory_function': inventory_ispro_sensors_digital,
61 'check_function': check_ispro_sensors_digital,
62 'service_description': 'Digital in %s',
63 'snmp_info': (
64 '.1.3.6.1.4.1.19011.1.3.2.1.3',
66 "1.3.1.2", # ISPRO-MIB::isDeviceMonitorDigitalInName
67 "1.3.1.4", # ISPRO-MIB::isDeviceMonitorDigitalInAlarm
68 "2.4.1.3", # ISPRO-MIB::isDeviceConfigDigitalInState
69 ]),
70 'snmp_scan_function': ispro_scan_function,
71 'includes': ['ispro.include'],