Cleanup config.nodes_of
[check_mk.git] / checks / hp_blade_psu
blob0df84edc557ba8170fc98dcfd0e15b217d8442ba
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.
27 # Author: Lars Michelsen <lm@mathias-kettner.de>
29 # PSU:
30 # '.1.3.6.1.4.1.232.22.2.5.1.1.1.3' => 'cpqRackPowerSupplyIndex',
31 # '.1.3.6.1.4.1.232.22.2.5.1.1.1.5' => 'cpqRackPowerSupplySerialNum',
32 # '.1.3.6.1.4.1.232.22.2.5.1.1.1.6' => 'cpqRackPowerSupplyPartNumber',
33 # '.1.3.6.1.4.1.232.22.2.5.1.1.1.7' => 'cpqRackPowerSupplySparePartNumber',
34 # '.1.3.6.1.4.1.232.22.2.5.1.1.1.10' => 'cpqRackPowerSupplyCurPwrOutput',
35 # '.1.3.6.1.4.1.232.22.2.5.1.1.1.14' => 'cpqRackPowerSupplyStatus',
36 # '.1.3.6.1.4.1.232.22.2.5.1.1.1.15' => 'cpqRackPowerSupplyInputLineStatus',
37 # '.1.3.6.1.4.1.232.22.2.5.1.1.1.16' => 'cpqRackPowerSupplyPresent',
38 # '.1.3.6.1.4.1.232.22.2.5.1.1.1.17' => 'cpqRackPowerSupplyCondition',
40 # GENERAL MAPS:
42 hp_blade_present_map = {1: 'other', 2: 'absent', 3: 'present'}
43 hp_blade_status_map = {1: 'Other', 2: 'Ok', 3: 'Degraded', 4: 'Failed'}
45 hp_blade_status2nagios_map = {
46 'Other': 2,
47 'Ok': 0,
48 'Degraded': 1,
49 'Failed': 2,
52 # PSU MAPS:
54 hp_blade_psu_status = {
55 1: 'noError',
56 2: 'generalFailure',
57 3: 'bistFailure',
58 4: 'fanFailure',
59 5: 'tempFailure',
60 6: 'interlockOpen',
61 7: 'epromFailed',
62 8: 'vrefFailed',
63 9: 'dacFailed',
64 10: 'ramTestFailed',
65 11: 'voltageChannelFailed',
66 12: 'orringdiodeFailed',
67 13: 'brownOut',
68 14: 'giveupOnStartup',
69 15: 'nvramInvalid',
70 16: 'calibrationTableInvalid',
73 hp_blade_psu_inputline_status = {
74 1: 'noError',
75 2: 'lineOverVoltage',
76 3: 'lineUnderVoltage',
77 4: 'lineHit',
78 5: 'brownOut',
79 6: 'linePowerLoss',
83 def inventory_hp_blade_psu(info):
84 return [(line[0], None) for line in info if hp_blade_present_map[int(line[1])] == 'present']
87 def check_hp_blade_psu(item, params, info):
88 for line in info:
89 if line[0] == item:
90 present_state = hp_blade_present_map[int(line[1])]
91 if present_state != 'present':
92 return (2, 'PSU was present but is not available anymore.'
93 ' (Present state: %s' % present_state)
95 snmp_state = hp_blade_status_map[int(line[2])]
96 status = hp_blade_status2nagios_map[snmp_state]
98 detail_output = ''
99 if status == 0:
100 detail_output = ', Output: %sW' % line[3]
101 else:
102 # FIXME: This should probably append strings, not overwrite them...
103 detail_output = (' (%s)' % hp_blade_psu_status[4]) if int(line[4]) >= 1 else ''
104 detail_output = (', Inputline: %s' %
105 hp_blade_psu_inputline_status[5]) if int(line[5]) >= 1 else ''
107 perfdata = [('output', line[3])]
109 return (status, 'PSU is %s%s (S/N: %s)' % (snmp_state, detail_output, line[6]),
110 perfdata)
111 return (3, "item not found in snmp data")
114 check_info["hp_blade_psu"] = {
115 'check_function': check_hp_blade_psu,
116 'inventory_function': inventory_hp_blade_psu,
117 'service_description': 'PSU %s',
118 'has_perfdata': True,
119 'snmp_info': ('.1.3.6.1.4.1.232.22.2.5.1.1.1', ['3', '16', '17', '10', '14', '15', '5']),
120 'snmp_scan_function': lambda oid: ".11.5.7.1.2" in oid(".1.3.6.1.2.1.1.2.0"),