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:
28 # <<<emcvnx_raidgroups>>>
31 # Server IP Address: 172.16.8.82
32 # Agent Rev: 7.32.27 (0.14)
35 # All RAID Groups Information
36 # ----------------------------
41 # RaidGroup State: Explicit_Remove
43 # List of disks: Bus 0 Enclosure 0 Disk 0
44 # Bus 0 Enclosure 0 Disk 1
45 # Bus 0 Enclosure 0 Disk 2
46 # Bus 0 Enclosure 0 Disk 3
48 # Max Number of disks: 16
49 # Max Number of luns: 256
50 # Raw Capacity (Blocks): 702504960
51 # Logical Capacity (Blocks): 526878720
52 # Free Capacity (Blocks,non-contiguous): 0
53 # Free contiguous group of unbound segments: 0
54 # Defrag/Expand priority: Medium
55 # Percent defragmented: 100
56 # Percent expanded: N/A
57 # Disk expanding onto: N/A
58 # Lun Expansion enabled: NO
59 # Legal RAID types: r5
62 # RaidGroup Type: hot_spare
65 # Parse agent output into a dict of the form:
66 # (where the RAID Group ID is used as key)
67 # parsed = {'0': {'luns': '4'},
68 # '1': {'luns': '0,1'},
69 # '124': {'luns': '4089'},
70 # '2': {'luns': '2,3'}}
73 def parse_emcvnx_raidgroups(info
):
77 if len(line
) > 2 and line
[0] == "RaidGroup" and line
[1] == "ID:":
80 elif len(line
) > 3 and line
[0] == "List" and line
[1] == "of" and line
[2] == "luns:":
81 rg
["luns"] = ",".join(line
[3:])
82 elif len(line
) > 8 and line
[0] == "List" and line
[1] == "of" and line
[2] == "disks:":
84 disk
= line
[4] + "/" + line
[6] + " Disk " + line
[8]
88 elif append
is True and len(
89 line
) > 5 and line
[0] == "Bus" and line
[2] == "Enclosure" and line
[4] == "Disk":
90 disk
= line
[1] + "/" + line
[3] + " Disk " + line
[5]
95 line
) > 3 and line
[0] == "Raw" and line
[1] == "Capacity" and line
[2] == "(Blocks):":
96 rg
["capacity_raw_blocks"] = line
[3]
98 ) > 3 and line
[0] == "Logical" and line
[1] == "Capacity" and line
[2] == "(Blocks):":
99 rg
["capacity_logical_blocks"] = line
[3]
100 elif len(line
) > 3 and line
[0] == "Free" and line
[1] == "Capacity" and line
[
101 2] == "(Blocks,non-contiguous):":
102 rg
["capacity_free_total_blocks"] = line
[3]
103 elif len(line
) > 6 and line
[0] == "Free" and line
[1] == "contiguous" and line
[
104 4] == "unbound" and line
[5] == "segments:":
105 rg
["capacity_free_contiguous_blocks"] = line
[6]
109 def inventory_emcvnx_raidgroups(info
):
110 parsed
= parse_emcvnx_raidgroups(info
)
113 inventory
.append((rg
, None))
117 # .--list of LUNs--------------------------------------------------------.
118 # | _ _ _ __ _ _ _ _ _ |
119 # | | (_)___| |_ ___ / _| | | | | | | \ | |___ |
120 # | | | / __| __| / _ \| |_ | | | | | | \| / __| |
121 # | | | \__ \ |_ | (_) | _| | |__| |_| | |\ \__ \ |
122 # | |_|_|___/\__| \___/|_| |_____\___/|_| \_|___/ |
124 # '----------------------------------------------------------------------'
127 def check_emcvnx_raidgroups_list_luns(item
, _no_params
, info
):
128 parsed
= parse_emcvnx_raidgroups(info
)
129 if item
not in parsed
:
130 return 3, "RAID Group %s not found in agent output" % item
131 return 0, "List of LUNs: " + parsed
[item
]["luns"]
134 check_info
['emcvnx_raidgroups.list_luns'] = {
135 "inventory_function": inventory_emcvnx_raidgroups
,
136 "check_function": check_emcvnx_raidgroups_list_luns
,
137 "service_description": "RAID Group %s LUNs"
141 # .--list of disks-------------------------------------------------------.
143 # | | (_)___| |_ ___ / _| __| (_)___| | _____ |
144 # | | | / __| __| / _ \| |_ / _` | / __| |/ / __| |
145 # | | | \__ \ |_ | (_) | _| | (_| | \__ \ <\__ \ |
146 # | |_|_|___/\__| \___/|_| \__,_|_|___/_|\_\___/ |
148 # '----------------------------------------------------------------------'
151 def check_emcvnx_raidgroups_list_disks(item
, _no_params
, info
):
152 parsed
= parse_emcvnx_raidgroups(info
)
153 if item
not in parsed
:
154 return 3, "RAID Group %s not found in agent output" % item
158 for disk
in sorted(parsed
[item
]["disks"]):
161 enc_id
, disk_id
= disk
.split(' ', 1)
165 message
+= "Enclosure " + enc_id
+ " " + disk_id
168 return 0, "List of Disks: " + message
171 check_info
['emcvnx_raidgroups.list_disks'] = {
172 "inventory_function": inventory_emcvnx_raidgroups
,
173 "check_function": check_emcvnx_raidgroups_list_disks
,
174 "service_description": "RAID Group %s Disks"
178 # .--capacity------------------------------------------------------------.
180 # | ___ __ _ _ __ __ _ ___(_) |_ _ _ |
181 # | / __/ _` | '_ \ / _` |/ __| | __| | | | |
182 # | | (_| (_| | |_) | (_| | (__| | |_| |_| | |
183 # | \___\__,_| .__/ \__,_|\___|_|\__|\__, | |
185 # '----------------------------------------------------------------------'
188 def inventory_emcvnx_raidgroups_capacity(info
):
189 parsed
= parse_emcvnx_raidgroups(info
)
192 inventory
.append((rg
, {}))
196 def check_emcvnx_raidgroups_capacity(item
, params
, info
):
197 parsed
= parse_emcvnx_raidgroups(info
)
198 if item
not in parsed
:
199 return 3, "RAID Group %s not found in agent output" % item
202 # Blocksize in Bytes, seems to be fix
203 # (is not listed in the naviseccli output anywhere)
205 size_mb
= int(parsed
[item
]["capacity_logical_blocks"]) * blocksize
/ 1048576.0
206 avail_mb
= int(parsed
[item
]["capacity_free_total_blocks"]) * blocksize
/ 1048576.0
207 fslist
.append((item
, size_mb
, avail_mb
, 0))
209 # variable name in perfdata is not allowed to be just a number
210 # especially 0 does not work, so prefix it generally with "rg"
211 rc
, message
, perfdata
= df_check_filesystem_list(item
, params
, fslist
)
212 # note: on very first run perfdata is empty
213 if len(perfdata
) > 0:
214 perfdata
[0] = ("rg" + perfdata
[0][0], perfdata
[0][1], perfdata
[0][2], perfdata
[0][3],
215 perfdata
[0][4], perfdata
[0][5])
216 return rc
, message
, perfdata
219 check_info
['emcvnx_raidgroups.capacity'] = {
220 "inventory_function": inventory_emcvnx_raidgroups_capacity
,
221 "check_function": check_emcvnx_raidgroups_capacity
,
222 "service_description": "RAID Group %s Capacity",
223 "has_perfdata": True,
224 "group": "filesystem",
225 "includes": ["size_trend.include", "df.include"],
226 "default_levels_variable": "filesystem_default_levels",
230 # .--capacity contiguous-------------------------------------------------.
232 # | ___ ___ _ __ | |_(_) __ _ _ _ ___ _ _ ___ |
233 # | / __/ _ \| '_ \| __| |/ _` | | | |/ _ \| | | / __| |
234 # | | (_| (_) | | | | |_| | (_| | |_| | (_) | |_| \__ \ |
235 # | \___\___/|_| |_|\__|_|\__, |\__,_|\___/ \__,_|___/ |
237 # '----------------------------------------------------------------------'
240 def inventory_emcvnx_raidgroups_capacity_contiguous(info
):
241 parsed
= parse_emcvnx_raidgroups(info
)
244 inventory
.append((rg
, {}))
248 def check_emcvnx_raidgroups_capacity_contiguous(item
, params
, info
):
249 parsed
= parse_emcvnx_raidgroups(info
)
250 if item
not in parsed
:
251 return 3, "RAID Group %s not found in agent output" % item
254 # Blocksize in Bytes, seems to be fix
255 # (is not listed in the naviseccli output anywhere)
257 size_mb
= int(parsed
[item
]["capacity_logical_blocks"]) * blocksize
/ 1048576.0
258 avail_mb
= int(parsed
[item
]["capacity_free_contiguous_blocks"]) * blocksize
/ 1048576.0
259 fslist
.append((item
, size_mb
, avail_mb
, 0))
261 # variable name in perfdata is not allowed to be just a number
262 # especially 0 does not work, so prefix it generally with "rg"
263 rc
, message
, perfdata
= df_check_filesystem_list(item
, params
, fslist
)
264 perfdata
[0] = ("rg" + perfdata
[0][0], perfdata
[0][1], perfdata
[0][2], perfdata
[0][3],
265 perfdata
[0][4], perfdata
[0][5])
266 return rc
, message
, perfdata
269 check_info
['emcvnx_raidgroups.capacity_contiguous'] = {
270 "inventory_function": inventory_emcvnx_raidgroups_capacity_contiguous
,
271 "check_function": check_emcvnx_raidgroups_capacity_contiguous
,
272 "service_description": "RAID Group %s Capacity Contiguous",
273 "has_perfdata": True,
274 "group": "filesystem",
275 "includes": ["size_trend.include", "df.include"],
276 "default_levels_variable": "filesystem_default_levels",