2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
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.
28 def scan_didactum(oid
):
29 return "didactum" in oid(".1.3.6.1.2.1.1.1.0").lower()
32 # elements (not excatly sensors!) can be:
33 # temperature, analog voltage, usb-cam, reader, GSM modem, magnet,
34 # smoke, unknown, induct relay, pushbutton, timer
35 def parse_didactum_sensors(info
):
51 ty
, name
, status
= line
[:3]
52 if status
in map_states
:
53 state
= map_states
[status
]
54 state_readable
= status
57 state_readable
= "unknown[%s]" % status
59 parsed
.setdefault(ty
, {})
60 parsed
[ty
].setdefault(name
, {
62 "state_readable": state_readable
,
67 if value_str
.isdigit():
68 value
= int(value_str
)
71 value
= float(value_str
)
74 parsed
[ty
][name
].update({"value": value
})
77 crit_lower
, warn_lower
, warn
, crit
= line
[4:]
78 parsed
[ty
][name
].update({
79 "levels": (float(warn
), float(crit
)),
80 "levels_lower": (float(warn_lower
), float(crit_lower
)),
86 def inventory_didactum_sensors(parsed
, what
):
87 return [(sensorname
, {})
88 for sensorname
, attrs
in parsed
.get(what
, {}).items()
89 if attrs
["state_readable"] not in ["off", "not connected"]]
92 def check_didactum_sensors_temp(item
, params
, parsed
):
93 if item
in parsed
["temperature"]:
94 data
= parsed
["temperature"][item
]
95 return check_temperature(
98 "didactum_can_sensors_analog_temp.%s" % item
,
99 dev_levels
=data
["levels"],
100 dev_levels_lower
=data
["levels_lower"],
101 dev_status
=data
["state"],
102 dev_status_name
=data
["state_readable"])
105 def check_didactum_sensors_humidity(item
, params
, parsed
):
106 if item
in parsed
["humidity"]:
107 return check_humidity(parsed
["humidity"][item
]["value"], params
)
110 def check_didactum_sensors_voltage(item
, params
, parsed
):
111 if item
in parsed
["voltage"]:
112 data
= parsed
["voltage"][item
]
113 return check_elphase(
116 "voltage": (data
["value"], (data
["state"], data
["state_readable"]))