Cleanup config.nodes_of
[check_mk.git] / checks / hp_blade_blades
blobe188cce4f57c1868765864520b2f21f12af90660
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 # Blades:
30 # '.1.3.6.1.4.1.232.22.2.4.1.1.1.3' => 'cpqRackServerBladeIndex',
31 # '.1.3.6.1.4.1.232.22.2.4.1.1.1.4' => 'cpqRackServerBladeName',
32 # '.1.3.6.1.4.1.232.22.2.4.1.1.1.6' => 'cpqRackServerBladePartNumber',
33 # '.1.3.6.1.4.1.232.22.2.4.1.1.1.7' => 'cpqRackServerBladeSparePartNumber',
34 # '.1.3.6.1.4.1.232.22.2.4.1.1.1.8' => 'cpqRackServerBladePosition',
35 # '.1.3.6.1.4.1.232.22.2.4.1.1.1.12' => 'cpqRackServerBladePresent',
36 # '.1.3.6.1.4.1.232.22.2.4.1.1.1.16' => 'cpqRackServerBladeSerialNum',
37 # '.1.3.6.1.4.1.232.22.2.4.1.1.1.17' => 'cpqRackServerBladeProductId',
38 # Seems not to be implemented:
39 # '.1.3.6.1.4.1.232.22.2.4.1.1.1.21' => 'cpqRackServerBladeStatus',
40 # '.1.3.6.1.4.1.232.22.2.4.1.1.1.22' => 'cpqRackServerBladeFaultMajor',
41 # '.1.3.6.1.4.1.232.22.2.4.1.1.1.23' => 'cpqRackServerBladeFaultMinor',
42 # '.1.3.6.1.4.1.232.22.2.4.1.1.1.24' => 'cpqRackServerBladeFaultDiagnosticString',
43 # '.1.3.6.1.4.1.232.22.2.4.1.1.1.25' => 'cpqRackServerBladePowered',
45 # GENERAL MAPS:
47 hp_blade_present_map = {1: 'other', 2: 'absent', 3: 'present'}
48 hp_blade_status_map = {1: 'Other', 2: 'Ok', 3: 'Degraded', 4: 'Failed'}
50 hp_blade_status2nagios_map = {
51 'Other': 2,
52 'Ok': 0,
53 'Degraded': 1,
54 'Failed': 2,
58 def inventory_hp_blade_blades(info):
59 return [
60 (line[0], None) for line in info if hp_blade_present_map.get(int(line[1]), "") == 'present'
64 def check_hp_blade_blades(item, params, info):
65 for line in info:
66 if line[0] == item:
67 present_state = hp_blade_present_map[int(line[1])]
68 if present_state != 'present':
69 return (2, 'Blade was present but is not available anymore'
70 ' (Present state: %s)' % present_state)
72 # Status field can be an empty string.
73 # Seems not to be implemented. The MIB file tells me that this value
74 # should represent a state but is empty. So set it to "fake" OK and
75 # display the other gathered information.
76 state = 2 if line[2] == '' else line[2]
77 state = saveint(state)
79 snmp_state = hp_blade_status_map[state]
80 status = hp_blade_status2nagios_map[snmp_state]
81 return (status, 'Blade status is %s (Product: %s Name: %s S/N: %s)' %
82 (snmp_state, line[3], line[4], line[5]))
83 return (3, "item not found in snmp data")
86 check_info["hp_blade_blades"] = {
87 'check_function': check_hp_blade_blades,
88 'inventory_function': inventory_hp_blade_blades,
89 'service_description': 'Blade %s',
90 'snmp_info': ('.1.3.6.1.4.1.232.22.2.4.1.1.1', ['3', '12', '21', '17', '4', '16']),
91 'snmp_scan_function': lambda oid: ".11.5.7.1.2" in oid(".1.3.6.1.2.1.1.2.0"),