Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / papouch_th2e_sensors
blob84c7637b7b7ddab3a313aafae896db15a5e2e0f9
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
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 # ails. 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.18248.20.1.2.1.1.1.1 0
28 # .1.3.6.1.4.1.18248.20.1.2.1.1.1.2 0
29 # .1.3.6.1.4.1.18248.20.1.2.1.1.1.3 0
30 # .1.3.6.1.4.1.18248.20.1.2.1.1.2.1 249
31 # .1.3.6.1.4.1.18248.20.1.2.1.1.2.2 317
32 # .1.3.6.1.4.1.18248.20.1.2.1.1.2.3 69
33 # .1.3.6.1.4.1.18248.20.1.2.1.1.3.1 0
34 # .1.3.6.1.4.1.18248.20.1.2.1.1.3.2 3
35 # .1.3.6.1.4.1.18248.20.1.2.1.1.3.3 0
38 def parse_papouch_th2e_sensors(info):
39 map_sensor_type = {
40 "1": "temp",
41 "2": "humidity",
42 "3": "dewpoint",
45 map_units = {
46 "0": "c",
47 "1": "f",
48 "2": "k",
49 "3": "percent",
52 map_states = {
53 "0": (0, "OK"),
54 "1": (3, "not available"),
55 "2": (1, "over-flow"),
56 "3": (1, "under-flow"),
57 "4": (2, "error"),
60 parsed = {}
61 for oidend, state, reading_str, unit in info:
62 if state != "3":
63 sensor_ty = map_sensor_type[oidend]
64 sensor_unit = map_units[unit]
65 parsed.setdefault(sensor_ty, {})
66 parsed[sensor_ty].setdefault("Sensor %s" % oidend, (
67 map_states[state],
68 float(reading_str) / 10,
69 sensor_unit,
72 return parsed
75 # .--temperature---------------------------------------------------------.
76 # | _ _ |
77 # | | |_ ___ _ __ ___ _ __ ___ _ __ __ _| |_ _ _ _ __ ___ |
78 # | | __/ _ \ '_ ` _ \| '_ \ / _ \ '__/ _` | __| | | | '__/ _ \ |
79 # | | || __/ | | | | | |_) | __/ | | (_| | |_| |_| | | | __/ |
80 # | \__\___|_| |_| |_| .__/ \___|_| \__,_|\__|\__,_|_| \___| |
81 # | |_| |
82 # +----------------------------------------------------------------------+
83 # | main check |
84 # '----------------------------------------------------------------------'
87 def inventory_papouch_th2e_sensors_temp(parsed, what):
88 for item in parsed[what]:
89 yield item, {}
92 def check_papouch_th2e_sensors_temp(item, params, parsed, what):
93 if item in parsed[what]:
94 (state, state_readable), reading, unit = parsed[what][item]
95 return check_temperature(
96 reading,
97 params,
98 "papouch_th2e_sensors_%s_%s" % (what, item),
99 dev_unit=unit,
100 dev_status=state,
101 dev_status_name=state_readable)
104 check_info['papouch_th2e_sensors'] = {
105 'parse_function' : parse_papouch_th2e_sensors,
106 'inventory_function' : lambda parsed: \
107 inventory_papouch_th2e_sensors_temp(parsed, "temp"),
108 'check_function' : lambda item, params, parsed: \
109 check_papouch_th2e_sensors_temp(item, params, parsed, "temp"),
110 'service_description' : 'Temperature %s',
111 'has_perfdata' : True,
112 'snmp_info' : (".1.3.6.1.4.1.18248.20.1.2.1.1", [
113 OID_END,
114 "1", # the_v01-MIB::inChStatus
115 "2", # the_v01-MIB::inChValue
116 "3", # the_v01-MIB::inChUnits
118 'snmp_scan_function' : lambda oid: "th2e" in oid(".1.3.6.1.2.1.1.1.0").lower() and \
119 oid(".1.3.6.1.2.1.1.2.0").startswith(".0.10.43.6.1.4.1"),
120 'includes' : [ 'temperature.include' ],
121 'group' : 'temperature',
125 # .--dew point-----------------------------------------------------------.
126 # | _ _ _ |
127 # | __| | _____ __ _ __ ___ (_)_ __ | |_ |
128 # | / _` |/ _ \ \ /\ / / | '_ \ / _ \| | '_ \| __| |
129 # | | (_| | __/\ V V / | |_) | (_) | | | | | |_ |
130 # | \__,_|\___| \_/\_/ | .__/ \___/|_|_| |_|\__| |
131 # | |_| |
132 # '----------------------------------------------------------------------'
135 check_info['papouch_th2e_sensors.dewpoint'] = {
136 'inventory_function' : lambda parsed: \
137 inventory_papouch_th2e_sensors_temp(parsed, "dewpoint"),
138 'check_function' : lambda item, params, parsed: \
139 check_papouch_th2e_sensors_temp(item, params, parsed, "dewpoint"),
140 'service_description' : 'Dew point %s',
141 'has_perfdata' : True,
142 'includes' : [ 'temperature.include' ],
143 'group' : 'temperature',
147 # .--humidity------------------------------------------------------------.
148 # | _ _ _ _ _ |
149 # | | |__ _ _ _ __ ___ (_) __| (_) |_ _ _ |
150 # | | '_ \| | | | '_ ` _ \| |/ _` | | __| | | | |
151 # | | | | | |_| | | | | | | | (_| | | |_| |_| | |
152 # | |_| |_|\__,_|_| |_| |_|_|\__,_|_|\__|\__, | |
153 # | |___/ |
154 # '----------------------------------------------------------------------'
156 # Suggested by customer
157 papouch_th2e_sensors_humidity_default_levels = (8, 12, 30, 35)
160 def inventory_papouch_th2e_sensors_humidity(parsed):
161 for item in parsed["humidity"]:
162 yield item, "papouch_th2e_sensors_humidity_default_levels"
165 def check_papouch_th2e_sensors_humidity(item, params, parsed):
166 if item in parsed["humidity"]:
167 (state, state_readable), reading, _unit = parsed["humidity"][item]
168 yield state, "Status: %s" % state_readable
169 yield check_humidity(reading, params)
172 check_info['papouch_th2e_sensors.humidity'] = {
173 'inventory_function': inventory_papouch_th2e_sensors_humidity,
174 'check_function': check_papouch_th2e_sensors_humidity,
175 'service_description': 'Humidity %s',
176 'has_perfdata': True,
177 'includes': ['humidity.include'],
178 'group': 'humidity',