Refactoring: Moved check parameters from unsorted.py to dedicated modules (CMK-1393)
[check_mk.git] / checks / netapp_volumes
blob94a537e3634284c05414e61ddcc57d2d1c7ea7a2
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 # .1.3.6.1.4.1.789.1.5.8.1.1.1 = INTEGER: 1
28 # .1.3.6.1.4.1.789.1.5.8.1.1.2 = INTEGER: 2
29 # .1.3.6.1.4.1.789.1.5.8.1.1.3 = INTEGER: 3
30 # .1.3.6.1.4.1.789.1.5.8.1.2.1 = STRING: "vol0"
31 # .1.3.6.1.4.1.789.1.5.8.1.2.2 = STRING: "RvRBackup"
32 # .1.3.6.1.4.1.789.1.5.8.1.2.3 = STRING: "RundV"
33 # .1.3.6.1.4.1.789.1.5.8.1.3.1 = STRING: "67155442"
34 # .1.3.6.1.4.1.789.1.5.8.1.3.2 = STRING: "2600515058"
35 # .1.3.6.1.4.1.789.1.5.8.1.3.3 = STRING: "788575730"
36 # .1.3.6.1.4.1.789.1.5.8.1.4.1 = INTEGER: 1
37 # .1.3.6.1.4.1.789.1.5.8.1.4.2 = INTEGER: 1
38 # .1.3.6.1.4.1.789.1.5.8.1.4.3 = INTEGER: 1
39 # .1.3.6.1.4.1.789.1.5.8.1.5.1 = STRING: "online"
40 # .1.3.6.1.4.1.789.1.5.8.1.5.2 = STRING: "online"
41 # .1.3.6.1.4.1.789.1.5.8.1.5.3 = STRING: "online"
42 # .1.3.6.1.4.1.789.1.5.8.1.6.1 = STRING: "raid_dp"
43 # .1.3.6.1.4.1.789.1.5.8.1.6.2 = STRING: "raid_dp"
44 # .1.3.6.1.4.1.789.1.5.8.1.6.3 = STRING: "raid_dp"
45 # .1.3.6.1.4.1.789.1.5.8.1.7.1 = STRING: "root, diskroot, nosnap=off,
46 # nosnapdir=off, minra=off, no_atime_update=off, raidtype=raid_dp, raidsize=16,
47 # nvfail=off, snapmirrored=off, resyncsnaptime=60, create_ucode=off,
48 # convert_ucode=off, maxdirsize=10485, fs_size_fixed=off, guarantee=volume,
49 # svo_enable=off, svo_checksum=off, svo_allow_rman=off, svo_reject_errors=off,
50 # no_i2p=off, fractional_reserve=100, extent=off, try_first=volume_grow"
51 # .1.3.6.1.4.1.789.1.5.8.1.7.2 = STRING: "nosnap=off, nosnapdir=off,
52 # minra=off, no_atime_update=off, raidtype=raid_dp, raidsize=16, nvfail=off,
53 # snapmirrored=off, resyncsnaptime=60, create_ucode=off, convert_ucode=off,
54 # maxdirsize=10485, fs_size_fixed=off, guarantee=volume, svo_enable=off,
55 # svo_checksum=off, svo_allow_rman=off, svo_reject_errors=off, no_i2p=off,
56 # fractional_reserve=100, extent=off, try_first=volume_grow"
57 # .1.3.6.1.4.1.789.1.5.8.1.7.3 = STRING: "nosnap=on, nosnapdir=on,
58 # minra=off, no_atime_update=off, raidtype=raid_dp, raidsize=16, nvfail=off,
59 # snapmirrored=off, resyncsnaptime=60, create_ucode=off, convert_ucode=off,
60 # maxdirsize=10485, fs_size_fixed=off, guarantee=volume, svo_enable=off,
61 # svo_checksum=off, svo_allow_rman=off, svo_reject_errors=off, no_i2p=off,
62 # fractional_reserve=100, extent=off, try_first=volume_grow"
63 # .1.3.6.1.4.1.789.1.5.8.1.8.1 = STRING: "1ddc9920-496e-11df-aae1-00a09800c998"
64 # .1.3.6.1.4.1.789.1.5.8.1.8.2 = STRING: "62ac1040-5a8d-11df-83fd-00a09800c998"
65 # .1.3.6.1.4.1.789.1.5.8.1.8.3 = STRING: "4edc66e0-d6a3-11df-8724-00a09800c998"
66 # .1.3.6.1.4.1.789.1.5.8.1.9.1 = STRING: "aggr0"
67 # .1.3.6.1.4.1.789.1.5.8.1.9.2 = STRING: "aggr0"
68 # .1.3.6.1.4.1.789.1.5.8.1.9.3 = STRING: "aggr0"
69 # .1.3.6.1.4.1.789.1.5.8.1.10.1 = INTEGER: 2
70 # .1.3.6.1.4.1.789.1.5.8.1.10.2 = INTEGER: 2
71 # .1.3.6.1.4.1.789.1.5.8.1.10.3 = INTEGER: 2
72 # .1.3.6.1.4.1.789.1.5.8.1.11.1 = INTEGER: 1
73 # .1.3.6.1.4.1.789.1.5.8.1.11.2 = INTEGER: 1
74 # .1.3.6.1.4.1.789.1.5.8.1.11.3 = INTEGER: 1
75 # .1.3.6.1.4.1.789.1.5.8.1.12.1 = ""
76 # .1.3.6.1.4.1.789.1.5.8.1.12.2 = ""
77 # .1.3.6.1.4.1.789.1.5.8.1.12.3 = ""
78 # .1.3.6.1.4.1.789.1.5.8.1.13.1 = ""
79 # .1.3.6.1.4.1.789.1.5.8.1.13.2 = ""
80 # .1.3.6.1.4.1.789.1.5.8.1.13.3 = ""
82 netapp_volumes_owner = {
83 '1': 'local',
84 '2': 'partner',
88 def inventory_netapp_volumes(info):
89 # Only inventorize local volumes
90 return [(line[0], None) for line in info if netapp_volumes_owner.get(line[2], '') == 'local']
93 def check_netapp_volumes(item, _not_used, info):
94 for line in info:
95 if line[0] == item:
96 _name, fsid, owner, state, status = line
98 output = 'FSID: %s, Owner: %s, ' % (fsid, netapp_volumes_owner.get(owner, 'UNKNOWN'))
100 ret_state = 0
101 output += 'State: %s' % state
102 if state == 'offline':
103 ret_state = 1
104 output += '(!)'
106 output += ', Status: %s' % status
107 if status == 'reconstructing':
108 ret_state = 1
109 output += '(!)'
110 elif status.split(',')[0] not in [
111 'normal', 'raid_dp', 'raid0', 'raid0, mirrored', 'raid4', 'mixed_raid_type'
113 ret_state = 2
114 output += '(!!)'
116 return (ret_state, output)
117 return 3, "Volume not found"
120 check_info["netapp_volumes"] = {
121 'check_function': check_netapp_volumes,
122 'inventory_function': inventory_netapp_volumes,
123 'service_description': 'NetApp Vol %s',
124 'snmp_info': (
125 '.1.3.6.1.4.1.789.1.5.8.1',
127 '2', # volName
128 '3', # volFSID
129 '4', # volOwningHost
130 '5', # volState
131 '6', # volStatus
133 'snmp_scan_function':
134 lambda oid: oid(".1.3.6.1.2.1.1.1.0").startswith('NetApp Release') and oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.789"),