GUI CSS: Removed snapin styles from py modules and added a _snapins.scss for the...
[check_mk.git] / checks / ewon
blob75aacf9265a4be69b6354297aec2a4fd01805cad
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
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.
28 # The ewon2005cd is a vpn that can also be used to expose data from a
29 # secondary device via snmp. Unfortunately there is no way to reliably
30 # identify that secondary device
33 ewon_discovery_rules = []
35 # configuration for the tags used in Wagner OxyReduct devices
36 # for analog measures, "levels" is provided as upper and lower bounds (warn and crit each)
37 # for digital bitfields the "expected" bitmask is provided, that is: the bits we expect to see,
38 # Anything that doesn't match this mask causes a crit status.
39 # Note: bitmasks are specified most-significant-bit to least-significant bit
40 # Some symbols have special meaning:
41 # "?" - we don't care about this flag
42 # "*" - add the flag to the infotext but don't derive a state from it
43 # "+" - add the flag to the infotext if it is set but don't derive a state from it
44 # Also, we provide the names of flags for proper info texts.
45 oxyreduct_tag_map = {
46 1: {
47 "name": "alarms",
48 "levels": (1, 2, -1, -1)
50 2: {
51 "name": "incidents",
52 "levels": (1, 2, -1, -1)
54 3: {
55 "name": "shutdown messages",
56 "levels": (1, 2, -1, -1)
58 4: {
59 "flags": "00000????0000000",
60 "flag_names": [
61 "buzzer",
62 "light test",
63 "luminous field",
64 "optical alarm",
65 "accustic alarm",
66 "",
67 "",
68 "",
69 "",
70 "warnings",
71 "shutdown",
72 "operation reports",
73 "incident",
74 "O2 high",
75 "O2 low",
76 "alarms",
79 5: {
80 "flags": "00??????00**0101",
81 "flag_names": [
82 "recovery", "maintenance", "", "", "", "", "", "", "warnings", "incidents",
83 "N2 to safe area", "N2 request from safe area", "N2 via outlet", "N2 via compressor",
84 "N2-supply locked", "N2-supply open"
87 6: {
88 "name": "O2 minimum",
89 "levels": (16, 17, 14, 13),
90 "scale": 0.01,
91 "unit": "%",
92 "perfvar": "o2_percentage",
93 "condition_flag": (1, 15)
95 7: {
96 "flags": "?????000??00000*",
97 "flag_names": [
98 "", "", "", "", "", "luminous field", "optical alarm", "acoustic alarm", "", "",
99 "warnings", "operation report", "shutdown", "incidents", "alarm", "O2 Sensor"
102 8: {
103 "same_as": 6
105 9: {
106 "same_as": 7
108 10: {
109 "name": "O2 average",
110 "levels_name": "o2_levels",
111 "levels": (16, 17, 14, 13),
112 "scale": 0.01,
113 "unit": "%",
114 "perfvar": "o2_percentage"
116 11: {
117 "name": "O2 target",
118 "scale": 0.01,
119 "unit": "%"
121 12: {
122 "name": "O2 for N2-in",
123 "scale": 0.01,
124 "unit": "%"
126 13: {
127 "name": "O2 for N2-out",
128 "scale": 0.01,
129 "unit": "%"
131 14: {
132 "name": "CO2 maximum",
133 "levels": (1500, 2000, -1, -1),
134 "unit": "ppm"
136 15: {
137 "flags": "????++++????++++",
138 "flag_names": [
143 "air control shutdown",
144 "air control closed",
145 "air control open",
146 "air control active",
151 "valve shutdown",
152 "valve closed",
153 "valve open",
154 "valve active",
157 16: {
158 "flags": "????++++????++++",
159 "flag_names": [
164 "access shutdown",
165 "access closed",
166 "access open",
167 "access active",
172 "air circulation shutdown",
173 "air circulation closed",
174 "air circulation open",
175 "air circulation active",
178 17: {
179 "flags": "??00++++0?000001",
180 "flag_names": [
181 "O2 ref sensors working",
182 "O2 ref sensors projected",
183 "BMZ quick reduction",
184 "key switch active",
185 "mode BK3",
186 "mode BK2",
187 "mode BK1",
188 "mode FB",
189 "operation mode change",
191 "warnings",
192 "operation reports",
193 "shutdown",
194 "incidents",
195 "alarm",
196 "active",
202 def parse_ewon(info):
203 result = {}
204 for tagid, value, name in info:
205 result.setdefault(name, {})[int(tagid)] = value
206 return result
209 def inventory_ewon(parsed):
210 settings = host_extra_conf(host_name(), ewon_discovery_rules)
211 deviceName = None
212 if settings:
213 deviceName = settings[0]
215 yield "eWON Status", {"device": deviceName}
217 if deviceName in set(["oxyreduct"]):
218 for res in globals()["inventory_%s" % deviceName](parsed):
219 item, params = res
220 params["device"] = deviceName
221 yield item, params
224 def check_ewon(item, params, parsed):
225 if item == "eWON Status":
226 if params["device"] is None:
227 return 1, "This device requires configuration. Plese pick the device type."
228 return 0, "Configured for %s" % params["device"]
230 deviceName = params["device"]
231 if deviceName in set(["oxyreduct"]):
232 return globals()["check_%s" % deviceName](item, params.get(deviceName, {}), parsed)
235 check_info["ewon"] = {
236 "check_function": check_ewon,
237 "inventory_function": inventory_ewon,
238 "parse_function": parse_ewon,
239 "service_description": "%s",
240 "has_perfdata": True,
241 "snmp_scan_function": lambda oid: oid(".1.3.6.1.2.1.1.2.0") == ".1.3.6.1.4.1.8284.2.1",
242 "snmp_info": (
243 ".1.3.6.1.4.1.8284.2.1.3.1.11.1",
245 2, #tagCfgId
246 4, #tagValue
247 16, #undocumented name field
249 "group": "ewon"