Cleanup config.nodes_of
[check_mk.git] / checks / raritan_pdu_inlet
blob0ee468c9aa10111c673583de9798d9aceda35b8e
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 def parse_raritan_pdu_inlet(info):
29 precisions = dict([(oid_end, int(decimals)) for oid_end, decimals in info[0]])
30 parsed = {}
31 for oid_end, availability, sensor_state, value in info[1]:
32 if availability == '1':
33 phase_id, sensor_type = oid_end.split('.')[2:4]
34 phase = "Phase " + phase_id
35 if sensor_type in raritan_map_type:
36 parsed.setdefault(phase, {})
37 key, _key_info = raritan_map_type[sensor_type] # get key for elphase.include
38 value = float(value) / 10**precisions[oid_end]
39 state, state_info = raritan_map_state[sensor_state]
41 if state > 0:
42 parsed[phase][key] = (value, (state, state_info))
43 else:
44 parsed[phase][key] = (value, None)
45 return parsed
48 def check_raritan_pdu_inlet(item, params, info):
49 if not item.startswith("Phase"):
50 item = "Phase %s" % item
51 for res in check_elphase(item, params, info):
52 yield res
55 check_info['raritan_pdu_inlet'] = {
56 "parse_function": parse_raritan_pdu_inlet,
57 "inventory_function": inventory_elphase,
58 "check_function": check_raritan_pdu_inlet,
59 "service_description": "Input %s",
60 "has_perfdata": True,
61 "group": "el_inphase",
62 "snmp_info": [
64 ".1.3.6.1.4.1.13742.6.3.3.6.1",
66 OID_END,
67 "7", # inletPoleSensorDecimalDigits
68 ]),
70 ".1.3.6.1.4.1.13742.6.5.2.4.1",
72 OID_END,
73 2, # availability
74 3, # state
75 4, # value
78 "snmp_scan_function": lambda oid: oid(".1.3.6.1.2.1.1.2.0") == ".1.3.6.1.4.1.13742.6",
79 "includes": ['raritan.include', 'elphase.include']