Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / hp_proliant_da_phydrv
blob565d455776341772317fad284289c5400273a828
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 hp_proliant_da_phydrv_condition_status2nagios = {
28 'other': 3,
29 'ok': 0,
30 'degraded': 2,
31 'failed': 2,
33 hp_proliant_da_phydrv_condition = {
34 0: 'n/a',
35 1: 'other',
36 2: 'ok',
37 3: 'degraded',
38 4: 'failed',
41 hp_proliant_da_phydrv_status = {
42 1: 'other',
43 2: 'ok',
44 3: 'failed',
45 4: 'predictiveFailure',
46 5: 'erasing',
47 6: 'eraseDone',
48 7: 'eraseQueued',
49 8: 'ssdWearOut',
50 9: 'notAuthenticated',
53 hp_proliant_da_phydrv_smart_status = {
54 1: 'other',
55 2: 'ok',
56 3: 'replaceDrive',
60 def inventory_hp_proliant_da_phydrv(info):
61 return [(line[0] + '/' + line[1], None) for line in info]
64 def check_hp_proliant_da_phydrv(item, _no_params, info):
65 for line in info:
66 # First condition is for legacy discovered services
67 if line[1] == item or (line[0] + '/' + line[1]) == item:
68 _cntlr_index, _index, bay, status, ref_hours, size, condition, \
69 bus_number, smart_status = line
71 snmp_status = hp_proliant_da_phydrv_status[int(status)]
73 condition = hp_proliant_da_phydrv_condition[int(condition)]
74 status = hp_proliant_da_phydrv_condition_status2nagios[condition]
76 return (
77 status, 'Bay: %s, Bus number: %s, Status: %s, '
78 'Smart status: %s, Ref hours: %s, Size: %sMB, Condition: %s' %
79 (bay, bus_number, snmp_status,
80 hp_proliant_da_phydrv_smart_status[int(smart_status)], ref_hours, size, condition))
81 return (3, "item not found in snmp data")
84 check_info["hp_proliant_da_phydrv"] = {
85 'inventory_function': inventory_hp_proliant_da_phydrv,
86 'check_function': check_hp_proliant_da_phydrv,
87 'service_description': 'HW Phydrv %s',
88 # If something changes here please adopt the related inventory plugin
89 'snmp_info': (
90 ".1.3.6.1.4.1.232.3.2.5.1.1",
92 "1", # CPQIDA-MIB::cpqDaPhyDrvCntlrIndex
93 "2", # CPQIDA-MIB::cpqDaPhyDrvIndex
94 "5", # CPQIDA-MIB::cpqDaPhyDrvBay
95 "6", # CPQIDA-MIB::cpqDaPhyDrvStatus
96 "9", # CPQIDA-MIB::cpqDaPhyDrvRefHours
97 "45", # CPQIDA-MIB::cpqDaPhyDrvSize
98 "37", # CPQIDA-MIB::cpqDaPhyDrvCondition
99 "50", # CPQIDA-MIB::cpqDaPhyDrvBusNumber
100 "57", # CPQIDA-MIB::cpqDaPhyDrvSmartStatus
102 'snmp_scan_function': lambda oid: "proliant" in oid(".1.3.6.1.4.1.232.2.2.4.2.0", "").lower(),