Cleanup config.nodes_of
[check_mk.git] / checks / cmctc_output
blob63936c103dcf11baef37baa919daa659128f3fdd
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
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.
27 # .1.3.6.1.4.1.2606.4.2.5.6.2.1.1.1 1
28 # .1.3.6.1.4.1.2606.4.2.5.6.2.1.1.2 2
29 # .1.3.6.1.4.1.2606.4.2.5.6.2.1.1.3 3
30 # .1.3.6.1.4.1.2606.4.2.5.6.2.1.2.1 18
31 # .1.3.6.1.4.1.2606.4.2.5.6.2.1.2.2 18
32 # .1.3.6.1.4.1.2606.4.2.5.6.2.1.2.3 18
33 # .1.3.6.1.4.1.2606.4.2.5.6.2.1.3.1 PSM On/Off
34 # .1.3.6.1.4.1.2606.4.2.5.6.2.1.3.2 PSM On/Off
35 # .1.3.6.1.4.1.2606.4.2.5.6.2.1.3.3 PSM On/Off
36 # .1.3.6.1.4.1.2606.4.2.5.6.2.1.4.1 6
37 # .1.3.6.1.4.1.2606.4.2.5.6.2.1.4.2 6
38 # .1.3.6.1.4.1.2606.4.2.5.6.2.1.4.3 6
39 # .1.3.6.1.4.1.2606.4.2.5.6.2.1.5.1 1
40 # .1.3.6.1.4.1.2606.4.2.5.6.2.1.5.2 1
41 # .1.3.6.1.4.1.2606.4.2.5.6.2.1.5.3 1
42 # .1.3.6.1.4.1.2606.4.2.5.6.2.1.6.1 2
43 # .1.3.6.1.4.1.2606.4.2.5.6.2.1.6.2 2
44 # .1.3.6.1.4.1.2606.4.2.5.6.2.1.6.3 2
45 # .1.3.6.1.4.1.2606.4.2.5.6.2.1.7.1 1
46 # .1.3.6.1.4.1.2606.4.2.5.6.2.1.7.2 1
47 # .1.3.6.1.4.1.2606.4.2.5.6.2.1.7.3 1
48 # .1.3.6.1.4.1.2606.4.2.5.6.2.1.8.1 0
49 # .1.3.6.1.4.1.2606.4.2.5.6.2.1.8.2 0
50 # .1.3.6.1.4.1.2606.4.2.5.6.2.1.8.3 0
51 # .1.3.6.1.4.1.2606.4.2.5.6.2.1.9.1 1
52 # .1.3.6.1.4.1.2606.4.2.5.6.2.1.9.2 1
53 # .1.3.6.1.4.1.2606.4.2.5.6.2.1.9.3 1
56 def parse_cmctc_output(info):
57 def parse_output_sensor(sensor):
58 type_map = {
59 #ID Type Unit Perfkey
60 "4": ("Door locking TS8 Ergoform", "", None),
61 "5": ("Universal lock 1 lock with power", "", None),
62 "6": ("Universal lock 2 unlock with power", "", None),
63 "7": ("Fan relay", "", None),
64 "8": ("Fan controlled", "", None),
65 "9": ("Universal relay output", "", None),
66 "10": ("Room door lock", "", None),
67 "11": ("Power output", "", None),
68 "12": ("Door lock with Master key", "", None),
69 "13": ("Door lock FR(i)", "", None),
70 "14": ("Setpoint", "", None),
71 "15": ("Setpoint temperature monitoring", u" °C", "temp"),
72 "16": ("Hysteresis of setpoint", "", None),
73 "17": ("Command for remote control of RCT", "", None),
74 "18": ("Relay", "", None),
75 "19": ("High setpoint current monitoring", " A", "current"),
76 "20": ("Low setpoint current monitoring", " A", "current"),
77 "21": ("Retpoint temperature RTT", u" °C", "temp"),
78 "22": ("Setpoint temperature monitoring RTT", u" °C", "temp"),
79 "23": ("Power output 20A", u" A", "current"),
80 "24": ("Door magnet automatic door release", "", None),
81 "30": ("Control mode", "", None),
82 "31": ("Min fan speed", " RPM", "rpm"),
83 "32": ("Min delta T", u" °C", "temp"),
84 "33": ("Max delta T", u" °C", "temp"),
85 "34": ("PID controller", "", None),
86 "35": ("PID controller", "", None),
87 "36": ("PID controller", "", None),
88 "37": ("Flowrate flowmeter", " l/min", "flow"),
89 "38": ("Cw value of water", "", ""),
90 "39": ("deltaT", u" °C", "temp"),
91 "40": ("Control mode", "", None),
92 "42": ("Setpoint high voltage PSM", "V", "voltage"),
93 "43": ("Setpoint low voltage PSM", "V", "voltage"),
94 "44": ("Setpoint high current PSM", "A", "current"),
95 "45": ("Setpoint low current PSM", "A", "current"),
96 "46": ("Command PSM", "", None),
99 status_map = {
100 '1': 'not available',
101 '2': 'lost',
102 '3': 'changed',
103 '4': 'ok',
104 '5': 'off',
105 '6': 'on',
106 '7': 'set off',
107 '8': 'set on',
110 command_map = {
111 '1': 'off',
112 '2': 'on',
113 '3': 'lock',
114 '4': 'unlock',
115 '5': 'unlock delay',
118 config_map = {
119 '1': 'disable remote control',
120 '2': 'enable remote control',
123 timeout_map = {
124 '1': 'stay',
125 '2': 'off',
126 '3': 'on',
129 (index, sensor_type_id, description, status, value, command, config, delay,
130 timeout_action) = sensor
132 sensor_type, unit, perfkey = type_map.get(sensor_type_id, ("Unknown output", "", None))
134 parsed = {
135 'status': status_map.get(status),
136 'value': int(value),
137 'unit': unit,
138 'perfkey': perfkey,
139 'command': command_map.get(command),
140 'config': config_map.get(config),
141 'delay': int(delay),
142 'timeout_action': timeout_map.get(timeout_action),
143 'description': description
146 if parsed['status'] == 'not available':
147 return None
149 name = '%s %s' % (sensor_type, index)
151 return name, parsed
153 parsed = {}
154 for sensor in info:
155 parsed_sensor = parse_output_sensor(sensor)
156 if parsed_sensor:
157 name, data = parsed_sensor
158 parsed[name] = data
160 return parsed
163 def inventory_cmctc_output(parsed):
164 for entry in parsed:
165 yield entry, {}
168 def check_cmctc_output(item, params, parsed):
169 sensor = parsed.get(item)
171 status_map = {
172 'ok': 0,
173 'on': 0,
174 'set off': 0,
175 'set on': 0,
176 'changed': 1,
177 'lost': 2,
178 'off': 2,
179 'not available': 3,
182 state = status_map.get(sensor['status'], 3)
183 infotext = '[%(description)s] %(value)d%(unit)s, %(status)s' % sensor
184 if sensor['perfkey'] is None:
185 yield state, infotext
186 else:
187 yield state, infotext, [(sensor['perfkey'], sensor['value'])]
189 yield 0, ('Command: %(command)s, Config: %(config)s, '
190 'Delay: %(delay)d, Timeout action: %(timeout_action)s') % sensor
193 check_info['cmctc_output'] = {
194 "parse_function": parse_cmctc_output,
195 "inventory_function": inventory_cmctc_output,
196 "check_function": check_cmctc_output,
197 "service_description": "%s",
198 "has_perfdata": True,
199 "snmp_scan_function": cmctc_snmp_scan_function,
200 "snmp_info": (
201 ".1.3.6.1.4.1.2606.4.2", # RITTAL-CMC-TC-MIB
203 "3", # cmcTcUnit1OutputTable
204 "4", # cmcTcUnit2OutputTable
205 "5", # cmcTcUnit3OutputTable
206 "6", # cmcTcUnit4OutputTable
209 "6.2.1.1", # unit1OutputIndex
210 "6.2.1.2", # unit1OutputType
211 "6.2.1.3", # unit1OutputText
212 "6.2.1.4", # unit1OutputStatus
213 "6.2.1.5", # unit1OutputValue
214 "6.2.1.6", # unit1OutputSet
215 "6.2.1.7", # unit1OutputConfig
216 "6.2.1.8", # unit1OutputDelay
217 "6.2.1.9", # unit1OutputTimeoutAction
219 "includes": ["cmctc.include"],