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.
28 # <<<netapp_api_disk:sep(9)>>>
31 def inventory_netapp_api_disk_summary(info
):
35 def check_netapp_api_disk_summary(_no_item
, params
, info
):
38 disk_uid
= line
[0].split()[1]
39 disks_info
.setdefault(disk_uid
, {})
40 for entry
in line
[1:]:
41 tokens
= entry
.split(" ", 1)
42 disks_info
[disk_uid
][tokens
[0]] = tokens
[1]
44 # Convert legacy levels
45 if "broken_spare_ratio" in params
:
46 params
= {"failed_spare_ratio": params
["broken_spare_ratio"]}
50 # The device can contain disks who belongs to another filer. We only check the ones
51 # belonging to this filer.
52 # TODO Do we need that?
54 [disk
for disk
in disks
.items() if not disk
[1].get("raid-state") in ["remote", "partner"]])
57 for disk
in my_disks
.itervalues():
58 # Collection the disk identity
59 disk_info
= "Serial: %s" % disk
.get("serial-number")
60 if "physical-space" in disk
:
61 disk_info
+= ", Size: %s" % get_bytes_human_readable(int(disk
["physical-space"]))
62 disk
['capacity'] = int(disk
['physical-space'])
64 disk
['identifier'] = disk_info
66 raid_type
= disk
.get("raid-type")
67 raid_state
= disk
.get("raid-state")
68 if raid_state
== "broken":
69 disk
['state'] = 'failed'
70 elif disk
.get("prefailed", "false") not in ["false", "None"]:
71 disk
['state'] = 'prefailed'
72 elif raid_state
== "spare":
73 disk
['state'] = "spare"
77 if raid_type
in ["parity", "dparity"]:
78 disk
['type'] = 'parity'
79 elif raid_type
== "data":
82 disks_converted
.append(disk
)
84 return check_filer_disks(disks_converted
, params
)
87 check_info
["netapp_api_disk.summary"] = {
88 'check_function': check_netapp_api_disk_summary
,
89 'inventory_function': inventory_netapp_api_disk_summary
,
90 'service_description': 'NetApp Disks Summary',
91 'group': 'netapp_disks',
93 'default_levels_variable': 'filer_disks_default_levels',
94 'includes': ['filerdisks.include'],