2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
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 # Example output from agent:
30 # Raw Size: 140014MB [0x11177330 Sectors]
31 # Firmware state: Unconfigured(good)
32 # Inquiry Data: FUJITSU MBB2147RC 5204BS04P9104BV5
35 # Raw Size: 140014MB [0x11177330 Sectors]
36 # Firmware state: Unconfigured(good)
37 # Inquiry Data: FUJITSU MBB2147RC 5204BS04P9104BSC
39 # The agent provides some new information since 1.1.9.
40 # The dev2enc infos are sent from the agent to have the
41 # real enclosure numbers instead of the device ids which
42 # seem to be generated somehow.
44 # dev2enc Enclosure 0 Device ID 6
45 # dev2enc Enclosure 1 Device ID 252
47 # On new inventory runs the enclosure number is used as
48 # index and item part.
49 megaraid_pdisks_legacy_mode
= False
50 # This makes service descriptions backward compatible to match
51 # inventory made by older versions that didn't support multiple
53 megaraid_pdisks_adapterstr
= ['e', 'f', 'g', 'h', 'i', 'j', 'k', 'l']
56 def megaraid_pdisks_parse(info
):
58 current_adapter
= adapters
[0]
61 enclosure_devid
= -181
63 if line
[0] == 'adapter':
65 adapters
[int(line
[1])] = current_adapter
66 elif line
[0] == 'dev2enc':
68 current_adapter
[int(line
[5])] = int(line
[2])
69 elif line
[0] == 'Adapter' and len(line
) == 2:
70 current_adapter
= adapters
[int(line
[1][1:])] # Raute weglassen
71 adapter
= int(line
[1][1:])
72 elif line
[0] == "Enclosure" and line
[1] == "Device":
74 enclosure_devid
= int(line
[-1])
75 # this should fix inventory problems.
76 adapters
[adapter
][enclosure_devid
] = enclosure_devid
78 except: # no enclosure device
80 adapters
[adapter
][0] = 0
81 elif line
[0] == "Enclosure" and line
[1] == "Number:":
82 for devid
, number
in current_adapter
.items():
83 if number
== int(line
[-1]):
84 enclosure_devid
= devid
87 elif line
[0] == "Slot":
89 elif line
[0] == "Firmware" and line
[1] == "state:":
90 state
= line
[2].rstrip(',')
91 elif line
[0] == "Inquiry" and line
[1] == "Data:":
92 name
= " ".join(line
[2:])
93 #Adapter, Enclosure, Encolsure Device ID, Slot, State, Name
95 (megaraid_pdisks_adapterstr
[adapter
], adapters
[adapter
][enclosure_devid
],
96 enclosure_devid
, slot
, state
, name
))
101 def inventory_megaraid_pdisks(info
):
102 info
= megaraid_pdisks_parse(info
)
104 for adapter
, enclosure
, _enc_dev_id
, slot
, _state
, _name
in info
:
105 inventory
.append(("%s%s/%s" % (adapter
, enclosure
, slot
), None))
109 megaraid_pdisks_states
= {
112 'Unconfigured(good)': 0,
115 'Unconfigured(bad)': 1,
121 def check_megaraid_pdisks(item
, _no_params
, info
):
122 info
= megaraid_pdisks_parse(info
)
123 for adapter
, enclosure
, _enc_dev_id
, slot
, state
, name
in info
:
124 if "%s%s/%s" % (adapter
, enclosure
, slot
) == item
:
125 return megaraid_pdisks_states
.get(state
, 3), "%s (%s)" % (state
, name
)
126 return 3, "No disk in encl/slot %s found" % item
129 check_info
["megaraid_pdisks"] = {
130 'check_function': check_megaraid_pdisks
,
131 'inventory_function': inventory_megaraid_pdisks
,
132 'service_description': 'RAID PDisk Adapt/Enc/Sl %s',
133 'has_perfdata': False,