Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / perle_psmu
bloba2bc59f5bdd3f5e06432871c125fc30b8ec6d857
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 # 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 # .1.3.6.1.4.1.1966.21.1.1.1.1.2.1.2.1.1 1 --> PERLE-MCR-MGT-MIB::mcrPsmuIndex.1.a
28 # .1.3.6.1.4.1.1966.21.1.1.1.1.2.1.2.1.2 2 --> PERLE-MCR-MGT-MIB::mcrPsmuIndex.1.b
29 # .1.3.6.1.4.1.1966.21.1.1.1.1.2.1.3.1.1 MCR-ACPWR --> PERLE-MCR-MGT-MIB::mcrPsmuModelName.1.a
30 # .1.3.6.1.4.1.1966.21.1.1.1.1.2.1.3.1.2 MCR-ACPWR --> PERLE-MCR-MGT-MIB::mcrPsmuModelName.1.b
31 # .1.3.6.1.4.1.1966.21.1.1.1.1.2.1.5.1.1 104-101015T10175 --> PERLE-MCR-MGT-MIB::mcrPsmuPsuSerialNumber.1.a
32 # .1.3.6.1.4.1.1966.21.1.1.1.1.2.1.5.1.2 104-101015T10177 --> PERLE-MCR-MGT-MIB::mcrPsmuPsuSerialNumber.1.b
33 # .1.3.6.1.4.1.1966.21.1.1.1.1.2.1.9.1.1 1 --> PERLE-MCR-MGT-MIB::mcrPsmuPsuStatus.1.a
34 # .1.3.6.1.4.1.1966.21.1.1.1.1.2.1.9.1.2 1 --> PERLE-MCR-MGT-MIB::mcrPsmuPsuStatus.1.b
35 # .1.3.6.1.4.1.1966.21.1.1.1.1.2.1.10.1.1 12.05 --> PERLE-MCR-MGT-MIB::mcrPsmuPsuVoltage.1.a
36 # .1.3.6.1.4.1.1966.21.1.1.1.1.2.1.10.1.2 12.05 --> PERLE-MCR-MGT-MIB::mcrPsmuPsuVoltage.1.b
37 # .1.3.6.1.4.1.1966.21.1.1.1.1.2.1.11.1.1 6.75 --> PERLE-MCR-MGT-MIB::mcrPsmuPsuPowerUsage.1.a
38 # .1.3.6.1.4.1.1966.21.1.1.1.1.2.1.11.1.2 6.75 --> PERLE-MCR-MGT-MIB::mcrPsmuPsuPowerUsage.1.b
39 # .1.3.6.1.4.1.1966.21.1.1.1.1.2.1.12.1.1 1 --> PERLE-MCR-MGT-MIB::mcrPsmuFanStatus.1.a
40 # .1.3.6.1.4.1.1966.21.1.1.1.1.2.1.12.1.2 1 --> PERLE-MCR-MGT-MIB::mcrPsmuFanStatus.1.b
43 def parse_perle_psmu(info):
44 map_states = {
45 "0": (2, "not present"),
46 "1": (0, "good"),
47 "2": (2, "fail"),
50 parsed = {}
51 for index, modelname, descr, serial, psu_status, voltage_str, power_str, fan_status in info:
52 parsed.setdefault(
53 index, {
54 "model": modelname,
55 "descr": descr,
56 "serial": serial,
57 "fanstate": map_states.get(fan_status, (3, "unknown[%s]" % fan_status)),
58 "psustate": map_states.get(psu_status, (3, "unknown[%s]" % psu_status)),
60 for what, value_str in [("power", power_str), ("voltage", voltage_str)]:
61 try:
62 parsed[index].setdefault(what, float(value_str))
63 except ValueError:
64 pass
66 return parsed
69 def inventory_perle_psmu(parsed, what_state, params=None):
70 for unit, values in parsed.items():
71 if values[what_state][1] != "not present":
72 yield unit, params
75 def check_perle_psmu_powersupplies(item, params, parsed):
76 if item in parsed:
77 state, state_readable = parsed[item]["psustate"]
78 yield state, "Status: %s" % state_readable
79 for res in check_elphase(item, params, parsed):
80 yield res
83 check_info['perle_psmu'] = {
84 'parse_function': parse_perle_psmu,
85 'inventory_function': lambda info: inventory_perle_psmu(info, "psustate", {}),
86 'check_function': check_perle_psmu_powersupplies,
87 'service_description': 'Power supply %s',
88 # If you change snmp info please adapt the related inventory plugin
89 'snmp_info': (
90 '.1.3.6.1.4.1.1966.21.1.1.1.1.2.1',
92 '2', # PERLE-MCR-MGT-MIB::mcrPsmuIndex
93 '3', # PERLE-MCR-MGT-MIB::mcrPsmuModelName
94 '4', # PERLE-MCR-MGT-MIB::mcrPsmuModelDesc
95 '5', # PERLE-MCR-MGT-MIB::mcrPsmuPsuSerialNumber
96 '9', # PERLE-MCR-MGT-MIB::mcrPsmuPsuStatus
97 '10', # PERLE-MCR-MGT-MIB::mcrPsmuPsuVoltageUsage
98 '11', # PERLE-MCR-MGT-MIB::mcrPsmuPsuPowerUsage
99 '12', # PERLE-MCR-MGT-MIB::mcrPsmuFanStatus
101 'snmp_scan_function': perle_scan_function,
102 'has_perfdata': True,
103 'includes': ['elphase.include', 'perle.include'],
104 'group': 'el_inphase',
108 def check_perle_psmu_fans(item, _no_params, parsed):
109 if item in parsed:
110 state, state_readable = parsed[item]["fanstate"]
111 return state, "Status: %s" % state_readable
114 check_info['perle_psmu.fan'] = {
115 'inventory_function': lambda info: inventory_perle_psmu(info, "fanstate", {}),
116 'check_function': check_perle_psmu_fans,
117 'service_description': 'Fan %s',