2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2014 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.
29 12: (None, "humidity"),
32 13: ("normally open", "user"),
33 14: ("normally closed", "user"),
37 30: (None, "current"),
39 32: (None, "position"),
52 48: ("Server in 1", "temp"),
53 49: ("Server out 1", "temp"),
54 50: ("Server in 2", "temp"),
55 51: ("Server out 2", "temp"),
56 52: ("Server in 3", "temp"),
57 53: ("Server out 3", "temp"),
58 54: ("Server in 4", "temp"),
59 55: ("Server out 4", "temp"),
62 56: ("Overview Server in", "temp"),
63 57: ("Overview Server out", "temp"),
66 58: ("Water in", "temp"),
67 59: ("Water out", "temp"),
71 61: (None, "blowergrade"),
72 62: (None, "regulator"),
76 def inventory_cmctc_lcp(info
, sensortype
):
78 for index
, typeid
, _status
, _value
, _high
, _low
, _warn
, _description
in info
:
79 typeid
= saveint(typeid
)
80 if typeid
in cmctc_lcp_sensors
:
81 item
, st
= cmctc_lcp_sensors
[typeid
]
84 item
= item
+ " - " + index
87 inventory
.append((item
, None))
91 def check_cmctc_lcp(item
, params
, info
, sensortype
):
93 "1": (3, "not available"),
101 "9": (2, "too high"),
119 itemindex
= item
.split(" - ")[-1]
120 for index
, _typeid
, statuscode
, value
, high
, low
, warn
, description
in info
:
121 if itemindex
== index
:
122 unit
= map_unit
[sensortype
]
126 infotext
+= "[%s] " % description
127 state
, extra_info
= map_sensor_state
[statuscode
]
128 yield state
, "%s%d%s" % (infotext
, value
, unit
)
133 perfdata
= [(sensortype
, value
, warn
, crit
)]
140 extra_info
+= " (warn/crit at %d/%d%s)" % (warn
, crit
, unit
)
142 perfdata
= [(sensortype
, value
)]
143 # Assumption: if high and low are both 0
144 # then there are no device levels
145 if not (int(high
) == 0 and int(low
) == 0) and int(high
) > int(low
):
146 if value
>= int(high
) or value
<= int(low
):
148 extra_info
+= " (device lower/upper crit at %s/%s%s)" % (low
, high
, unit
)
150 yield extra_state
, extra_info
, perfdata
153 def inventory_cmctc_lcp_temp(info
):
155 for index
, typeid
, _status
, _value
, _high
, _low
, _warn
, _description
in info
:
156 typeid
= saveint(typeid
)
157 if typeid
in cmctc_lcp_sensors
:
158 item
, st
= cmctc_lcp_sensors
[typeid
]
161 item
= item
+ " - " + index
164 inventory
.append((item
, None))
168 def check_cmctc_lcp_temp(item
, params
, info
):
169 itemindex
= item
.split(" - ")[-1]
170 for index
, _typeid
, statuscode
, value
, high
, low
, warn
, _description
in info
:
171 if itemindex
== index
:
172 status
= int(statuscode
)
173 levels
= None if high
== low
== warn
== "0" else \
174 (float(warn
), float(high
))
175 levels_low
= None if high
== low
== warn
== "0" else \
176 (float(low
), float("-inf")) # no lower critical level specified
177 return check_temperature(
180 "cmctc_lcp_temp_%s" % item
,
182 dev_levels_lower
=levels_low
,
183 dev_status
=cmctc_translate_status(status
),
184 dev_status_name
="Unit: %s" % cmctc_translate_status_text(status
))
185 return 3, "Sensor not found in SNMP output", []
188 snmp_scan_functions
["cmctc_lcp"] = cmctc_snmp_scan_function
190 snmp_info
["cmctc_lcp"] = (
191 ".1.3.6.1.4.1.2606.4.2",
193 "3", # cmcTcUnit1OutputTable
194 "4", # cmcTcUnit2OutputTable
195 "5", # cmcTcUnit3OutputTable
196 "6" # cmcTcUnit4OutputTable
200 "5.2.1.2", # Sensor Type
206 "7.2.1.2", # Description
209 check_info
['cmctc_lcp.access'] = {
210 "check_function": lambda item
, params
, info
: check_cmctc_lcp(item
, params
, info
, 'access'),
211 "inventory_function": lambda info
: inventory_cmctc_lcp(info
, 'access'),
212 "has_perfdata": True,
213 "service_description": "Access %s",
216 check_info
['cmctc_lcp.blower'] = {
217 "check_function": lambda item
, params
, info
: check_cmctc_lcp(item
, params
, info
, 'blower'),
218 "inventory_function": lambda info
: inventory_cmctc_lcp(info
, 'blower'),
219 "has_perfdata": True,
220 "service_description": "Blower %s",
223 check_info
['cmctc_lcp.blowergrade'] = {
224 "check_function": lambda item
, params
, info
: check_cmctc_lcp(item
, params
, info
, 'blowergrade'),
225 "inventory_function": lambda info
: inventory_cmctc_lcp(info
, 'blowergrade'),
226 "has_perfdata": True,
227 "service_description": "Blower Grade %s",
230 check_info
['cmctc_lcp.current'] = {
231 "check_function": lambda item
, params
, info
: check_cmctc_lcp(item
, params
, info
, 'current'),
232 "inventory_function": lambda info
: inventory_cmctc_lcp(info
, 'current'),
233 "has_perfdata": True,
234 "service_description": "Current %s",
237 check_info
['cmctc_lcp.flow'] = {
238 "check_function": lambda item
, params
, info
: check_cmctc_lcp(item
, params
, info
, 'flow'),
239 "inventory_function": lambda info
: inventory_cmctc_lcp(info
, 'flow'),
240 "has_perfdata": True,
241 "service_description": "Waterflow %s",
244 check_info
['cmctc_lcp.humidity'] = {
245 "check_function": lambda item
, params
, info
: check_cmctc_lcp(item
, params
, info
, 'humidity'),
246 "inventory_function": lambda info
: inventory_cmctc_lcp(info
, 'humidity'),
247 "has_perfdata": True,
248 "service_description": "Humidity %s",
251 check_info
['cmctc_lcp.position'] = {
252 "check_function": lambda item
, params
, info
: check_cmctc_lcp(item
, params
, info
, 'position'),
253 "inventory_function": lambda info
: inventory_cmctc_lcp(info
, 'position'),
254 "has_perfdata": True,
255 "service_description": "Position %s",
258 check_info
['cmctc_lcp.regulator'] = {
259 "check_function": lambda item
, params
, info
: check_cmctc_lcp(item
, params
, info
, 'regulator'),
260 "inventory_function": lambda info
: inventory_cmctc_lcp(info
, 'regulator'),
261 "has_perfdata": True,
262 "service_description": "Regulator %s",
265 check_info
['cmctc_lcp.status'] = {
266 "check_function": lambda item
, params
, info
: check_cmctc_lcp(item
, params
, info
, 'status'),
267 "inventory_function": lambda info
: inventory_cmctc_lcp(info
, 'status'),
268 "has_perfdata": True,
269 "service_description": "Status %s",
272 check_info
['cmctc_lcp.user'] = {
273 "check_function": lambda item
, params
, info
: check_cmctc_lcp(item
, params
, info
, 'user'),
274 "inventory_function": lambda info
: inventory_cmctc_lcp(info
, 'user'),
275 "has_perfdata": True,
276 "service_description": "User Sensor %s",
279 # temperature check is standardised
280 check_info
['cmctc_lcp.temp'] = {
281 "check_function": check_cmctc_lcp_temp
,
282 "inventory_function": inventory_cmctc_lcp_temp
,
283 "has_perfdata": True,
284 "service_description": "Temperature %s",
285 "group": "temperature",
286 "includes": ["temperature.include", "cmctc.include"]