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.
27 # .--General-------------------------------------------------------------.
29 # | __ _ ___ _ __ ___ _ __ __ _| | |
30 # | / _` |/ _ \ '_ \ / _ \ '__/ _` | | |
31 # | | (_| | __/ | | | __/ | | (_| | | |
32 # | \__, |\___|_| |_|\___|_| \__,_|_| |
34 # +----------------------------------------------------------------------+
36 # States for sensors with levels as they are defined in SPAGENT-MIB
37 akcp_sensor_level_states
= {
38 "1": (2, "no status"),
40 "3": (1, "high warning"),
41 "4": (2, "high critical"),
42 "5": (1, "low warning"),
43 "6": (2, "low critical"),
44 "7": (2, "sensor error"),
48 def snmp_scan_akcp_sensor(oid
):
49 return oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.3854.1") \
50 and not oid(".1.3.6.1.4.1.3854.2.*")
53 def snmp_scan_akcp_exp(oid
):
54 return oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.3854.1") \
55 and oid(".1.3.6.1.4.1.3854.2.*")
58 def inventory_akcp_sensor_no_params(info
):
60 # "1" means online, "2" offline
66 # .--Humidity------------------------------------------------------------.
68 # | | |__ _ _ _ __ ___ (_) __| (_) |_ _ _ |
69 # | | '_ \| | | | '_ ` _ \| |/ _` | | __| | | | |
70 # | | | | | |_| | | | | | | | (_| | | |_| |_| | |
71 # | |_| |_|\__,_|_| |_| |_|_|\__,_|_|\__|\__, | |
73 # +----------------------------------------------------------------------+
75 akcp_humidity_defaultlevels
= (30, 35, 60, 65)
78 def inventory_akcp_humidity(info
):
79 for description
, _percent
, _status
, online
in info
:
81 yield description
, "akcp_humidity_defaultlevels"
84 def check_akcp_humidity(item
, params
, info
):
85 for description
, percent
, status
, online
in info
:
86 if description
== item
:
87 # Online is set to "2" if sensor is offline
89 yield 2, "sensor is offline"
91 if status
in ["1", "7"]:
92 state
, state_name
= akcp_sensor_level_states
[status
]
93 yield state
, "State: %s" % state_name
95 yield check_humidity(int(percent
), params
)
99 # .--Temperature---------------------------------------------------------.
101 # | | |_ ___ _ __ ___ _ __ ___ _ __ __ _| |_ _ _ _ __ ___ |
102 # | | __/ _ \ '_ ` _ \| '_ \ / _ \ '__/ _` | __| | | | '__/ _ \ |
103 # | | || __/ | | | | | |_) | __/ | | (_| | |_| |_| | | | __/ |
104 # | \__\___|_| |_| |_| .__/ \___|_| \__,_|\__|\__,_|_| \___| |
106 # +----------------------------------------------------------------------+
108 factory_settings
["akcp_temp_default_levels"] = {
113 def inventory_akcp_sensor_temp(info
):
115 # sensorProbeTempOnline or sensorTemperatureGoOffline has to be at last index
116 # "1" means online, "2" offline
121 def check_akcp_sensor_temp(item
, params
, info
):
122 for description
, degree
, unit
, status
, \
123 low_crit
, low_warn
, high_warn
, high_crit
, \
127 if description
== item
:
128 # Online is set to "2" if sensor is offline
130 return 2, "sensor is offline"
132 if status
in ["1", "7"]:
133 state
, state_name
= akcp_sensor_level_states
[status
]
134 return state
, "State: %s" % state_name
136 # Unit "F" or "0" stands for Fahrenheit and "C" or "1" for Celsius
139 unit_normalised
= "f"
141 unit_normalised
= "c"
142 low_crit
, low_warn
, high_warn
, high_crit
= \
143 map(float, (low_crit
, low_warn
, high_warn
, high_crit
))
145 unit_normalised
= unit
.lower()
146 if int(high_crit
) > 100:
147 # Devices with "F" or "C" have the levels in degrees * 10
148 low_crit
, low_warn
, high_warn
, high_crit
= \
149 [float(t
) / 10 for t
in (low_crit
, low_warn
, high_warn
, high_crit
)]
151 low_crit
, low_warn
, high_warn
, high_crit
= \
152 [float(t
) for t
in (low_crit
, low_warn
, high_warn
, high_crit
)]
154 if degreeraw
and degreeraw
!= "0":
155 temperature
= float(degreeraw
) / 10.0
157 return 3, "Temperature information not found"
159 temperature
= float(degree
)
161 return check_temperature(temperature
, params
, "akcp_sensor_temp_%s" % item
, unit_normalised
, \
162 (high_warn
, high_crit
), (low_warn
, low_crit
))
166 # .--Water & Smoke-------------------------------------------------------.
168 # |__ ____ _| |_ ___ _ __ ( _ ) ___ _ __ ___ ___ | | _____ |
169 # |\ \ /\ / / _` | __/ _ \ '__| / _ \/\ / __| '_ ` _ \ / _ \| |/ / _ \ |
170 # | \ V V / (_| | || __/ | | (_> < \__ \ | | | | | (_) | < __/ |
171 # | \_/\_/ \__,_|\__\___|_| \___/\/ |___/_| |_| |_|\___/|_|\_\___| |
173 # +----------------------------------------------------------------------+
176 def check_akcp_sensor_relay(item
, _no_params
, info
):
177 # States for sensors with relays as they are defined in SPAGENT-MIB
179 "1": (2, "no status"),
181 "4": (2, "high critical"),
182 "6": (2, "low critical"),
183 "7": (2, "sensor error"),
184 "8": (2, "relay on"),
185 "9": (0, "relay off"),
188 for description
, status
, online
in info
:
189 if description
== item
:
190 # Online is set to "2" if sensor is offline
192 return 2, "sensor is offline"
194 state
, state_name
= relay_states
[status
]
195 return state
, "State: %s" % state_name
199 # .--Drycontact----------------------------------------------------------.
201 # | __| |_ __ _ _ ___ ___ _ __ | |_ __ _ ___| |_ |
202 # | / _` | '__| | | |/ __/ _ \| '_ \| __/ _` |/ __| __| |
203 # | | (_| | | | |_| | (_| (_) | | | | || (_| | (__| |_ |
204 # | \__,_|_| \__, |\___\___/|_| |_|\__\__,_|\___|\__| |
206 # +----------------------------------------------------------------------+
209 def check_akcp_sensor_drycontact(item
, _no_params
, info
):
210 # States which are not configurable by user as they are defined in SPAGENT-MIB
212 "1": (2, "no status"),
213 "7": (2, "sensor error"),
214 "8": (2, "output low"),
215 "9": (2, "output high"),
221 status
, crit_desc
, normal_desc
, online
= line
[1:]
223 status
, online
= line
[1:]
224 normal_desc
= "Drycontact OK"
225 crit_desc
= "Drycontact on Error"
228 infotext
= "Sensor is offline"
232 infotext
= normal_desc
233 elif status
in ["4", "6"]:
237 state
, infotext
= states
[status
]
239 return state
, infotext