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.
27 # .--example output------------------------------------------------------.
29 # | _____ ____ _ _ __ ___ _ __ | | ___ |
30 # | / _ \ \/ / _` | '_ ` _ \| '_ \| |/ _ \ |
31 # | | __/> < (_| | | | | | | |_) | | __/ |
32 # | \___/_/\_\__,_|_| |_| |_| .__/|_|\___| |
35 # | ___ _ _| |_ _ __ _ _| |_ |
36 # | / _ \| | | | __| '_ \| | | | __| |
37 # | | (_) | |_| | |_| |_) | |_| | |_ |
38 # | \___/ \__,_|\__| .__/ \__,_|\__| |
40 # +----------------------------------------------------------------------+
42 # '----------------------------------------------------------------------'
43 # .1.3.6.1.4.1.30155.2.1.2.1.2.18 temp0
44 # .1.3.6.1.4.1.30155.2.1.2.1.2.20 temp2
45 # .1.3.6.1.4.1.30155.2.1.2.1.2.27 fan3
46 # .1.3.6.1.4.1.30155.2.1.2.1.2.31 fan7
47 # .1.3.6.1.4.1.30155.2.1.2.1.2.40 VTT
48 # .1.3.6.1.4.1.30155.2.1.2.1.2.47 volt9
50 # .1.3.6.1.4.1.30155.2.1.2.1.3.18 0
51 # .1.3.6.1.4.1.30155.2.1.2.1.3.20 0
52 # .1.3.6.1.4.1.30155.2.1.2.1.3.27 1
53 # .1.3.6.1.4.1.30155.2.1.2.1.3.31 1
54 # .1.3.6.1.4.1.30155.2.1.2.1.3.40 2
55 # .1.3.6.1.4.1.30155.2.1.2.1.3.47 2
57 # .1.3.6.1.4.1.30155.2.1.2.1.5.18 -273.15
58 # .1.3.6.1.4.1.30155.2.1.2.1.5.20 56.00
59 # .1.3.6.1.4.1.30155.2.1.2.1.5.27 4179
60 # .1.3.6.1.4.1.30155.2.1.2.1.5.31 329
61 # .1.3.6.1.4.1.30155.2.1.2.1.5.40 1.15
62 # .1.3.6.1.4.1.30155.2.1.2.1.5.47 0.00
64 # .1.3.6.1.4.1.30155.2.1.2.1.6.18 degC
65 # .1.3.6.1.4.1.30155.2.1.2.1.6.20 degC
66 # .1.3.6.1.4.1.30155.2.1.2.1.6.27 RPM
67 # .1.3.6.1.4.1.30155.2.1.2.1.6.31 RPM
68 # .1.3.6.1.4.1.30155.2.1.2.1.6.40 V DC
69 # .1.3.6.1.4.1.30155.2.1.2.1.6.47 V DC
71 # .1.3.6.1.4.1.30155.2.1.2.1.7.18 0
72 # .1.3.6.1.4.1.30155.2.1.2.1.7.20 0
73 # .1.3.6.1.4.1.30155.2.1.2.1.7.27 0
74 # .1.3.6.1.4.1.30155.2.1.2.1.7.31 0
75 # .1.3.6.1.4.1.30155.2.1.2.1.7.40 0
76 # .1.3.6.1.4.1.30155.2.1.2.1.7.47 0
79 # .--parse---------------------------------------------------------------.
81 # | _ __ __ _ _ __ ___ ___ |
82 # | | '_ \ / _` | '__/ __|/ _ \ |
83 # | | |_) | (_| | | \__ \ __/ |
84 # | | .__/ \__,_|_| |___/\___| |
86 # +----------------------------------------------------------------------+
88 # '----------------------------------------------------------------------'
91 def parse_openbsd_sensors(info
):
93 used_descriptions
= set()
95 def get_item_name(name
):
99 if new_name
in used_descriptions
:
100 new_name
= "%s/%d" % (name
, idx
)
103 used_descriptions
.add(new_name
)
107 openbsd_map_state
= {
114 openbsd_map_type
= {'0': 'temp', '1': 'fan', '2': 'voltage'}
116 for descr
, sensortype
, value
, unit
, state
in info
:
117 if sensortype
not in openbsd_map_type
:
119 if (sensortype
== '0' and value
== '-273.15') or \
120 (sensortype
in [ '1', '2'] and float(value
) == 0):
123 item_name
= get_item_name(descr
)
124 parsed
[item_name
] = {
125 'state': openbsd_map_state
[state
],
126 'value': float(value
),
128 'type': openbsd_map_type
[sensortype
],
134 # .--inventory-----------------------------------------------------------.
136 # | (_)_ ____ _____ _ __ | |_ ___ _ __ _ _ |
137 # | | | '_ \ \ / / _ \ '_ \| __/ _ \| '__| | | | |
138 # | | | | | \ V / __/ | | | || (_) | | | |_| | |
139 # | |_|_| |_|\_/ \___|_| |_|\__\___/|_| \__, | |
141 # +----------------------------------------------------------------------+
143 # '----------------------------------------------------------------------'
146 def inventory_openbsd_sensors(parsed
, sensortype
):
148 for key
, values
in parsed
.items():
149 if values
['type'] == sensortype
:
150 inventory
.append((key
, {}))
155 # .--temperature---------------------------------------------------------.
157 # | | |_ ___ _ __ ___ _ __ ___ _ __ __ _| |_ _ _ _ __ ___ |
158 # | | __/ _ \ '_ ` _ \| '_ \ / _ \ '__/ _` | __| | | | '__/ _ \ |
159 # | | || __/ | | | | | |_) | __/ | | (_| | |_| |_| | | | __/ |
160 # | \__\___|_| |_| |_| .__/ \___|_| \__,_|\__|\__,_|_| \___| |
162 # +----------------------------------------------------------------------+
164 # '----------------------------------------------------------------------'
167 def check_openbsd_sensors(item
, params
, parsed
):
169 return check_temperature(parsed
[item
]['value'], params
, "openbsd_sensors_%s" % item
)
172 check_info
['openbsd_sensors'] = {
173 'parse_function': parse_openbsd_sensors
,
174 'inventory_function': lambda parsed
: inventory_openbsd_sensors(parsed
, 'temp'),
175 'check_function': check_openbsd_sensors
,
176 'service_description': 'Temperature %s',
177 'has_perfdata': True,
179 '.1.3.6.1.4.1.30155.2.1.2.1',
187 'snmp_scan_function': lambda oid
: oid(".1.3.6.1.4.1.30155.2.1.1.0"),
188 'group': 'temperature',
189 'includes': ['temperature.include'],
193 # .--fan-----------------------------------------------------------------.
196 # | | |_ / _` | '_ \ |
197 # | | _| (_| | | | | |
198 # | |_| \__,_|_| |_| |
200 # +----------------------------------------------------------------------+
202 # '----------------------------------------------------------------------'
204 factory_settings
['openbsd_sensors_fan_default_levels'] = {
206 'upper': (8000, 8400),
210 def check_openbsd_sensors_fan(item
, params
, parsed
):
212 return check_fan(parsed
[item
]['value'], params
)
215 check_info
['openbsd_sensors.fan'] = {
216 'inventory_function': lambda parsed
: inventory_openbsd_sensors(parsed
, 'fan'),
217 'check_function': check_openbsd_sensors_fan
,
218 'service_description': 'Fan %s',
219 'has_perfdata': True,
220 'default_levels_variable': 'openbsd_sensors_fan_default_levels',
222 'includes': ['fan.include'],
226 # .--voltage-------------------------------------------------------------.
228 # | __ _____ | | |_ __ _ __ _ ___ |
229 # | \ \ / / _ \| | __/ _` |/ _` |/ _ \ |
230 # | \ V / (_) | | || (_| | (_| | __/ |
231 # | \_/ \___/|_|\__\__,_|\__, |\___| |
233 # +----------------------------------------------------------------------+
235 # '----------------------------------------------------------------------'
238 def check_openbsd_sensors_voltage(item
, params
, parsed
):
242 item_elphase
['voltage'] = parsed
[item
]['value']
243 parsed_elphase
[item
] = item_elphase
245 return check_elphase(item
, params
, parsed_elphase
)
248 check_info
['openbsd_sensors.voltage'] = {
249 'inventory_function': lambda parsed
: inventory_openbsd_sensors(parsed
, 'voltage'),
250 'check_function': check_openbsd_sensors_voltage
,
251 'service_description': 'Voltage Type %s',
252 'has_perfdata': True,
253 'group': 'el_inphase',
254 'includes': ['elphase.include'],