Refactoring: Changed remaining check parameters starting with an 's' to the new rules...
[check_mk.git] / checks / emcvnx_info
blob9228d2aad8b765b1883ac5777c97c152954e7497
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 # Example output from agent:
28 # <<<emcvnx_info>>>
31 # Server IP Address: 10.1.36.13
32 # Agent Rev: 7.32.25 (1.56)
35 # Agent/Host Information
36 # -----------------------
40 # Agent Rev: 7.32.25 (1.56)
41 # Name: K10
42 # Desc:
43 # Node: A-CKM00114701225
44 # Physical Node: K10
45 # Signature: 3195192
46 # Peer Signature: 3187006
47 # Revision: 05.32.000.5.201
48 # SCSI Id: 0
49 # Model: VNX5300
50 # Model Type: Rackmount
51 # Prom Rev: 7.00.00
52 # SP Memory: 8192
53 # Serial No: CKM00114701225
54 # SP Identifier: A
55 # Cabinet: DPE7
57 # Name of the software package: -Compression
58 # Revision of the software package: -
59 # Commit Required: NO
60 # Revert Possible: NO
61 # Active State: YES
62 # Is installation completed: YES
63 # Is this System Software: NO
65 # [... more software packages follow ...]
68 def parse_emcvnx_info(info):
69 parsed = {
70 'info': [],
71 'storage': [],
72 'link': [],
73 'config': [],
74 'io': [],
76 key_to_subcheck = {
77 'System Fault LED': 'info',
78 'Server IP Address': 'info',
79 'System Date': 'info',
80 'System Time': 'info',
81 'Serial Number For The SP': 'info',
82 'Storage Processor': 'storage',
83 'Storage Processor Network Name': 'storage',
84 'Storage Processor IP Address': 'storage',
85 'Storage Processor Subnet Mask': 'storage',
86 'Storage Processor Gateway Address': 'storage',
87 'Storage Processor IPv6 Mode': 'storage',
88 'Link Status': 'link',
89 'Current Speed': 'link',
90 'Requested Speed': 'link',
91 'Auto-Negotiate': 'link',
92 'Capable Speeds': 'link',
93 'Statistics Logging': 'config',
94 'SP Read Cache State': 'config',
95 'SP Write Cache State': 'config',
96 'Hw_flush_on': 'config',
97 'Idle_flush_on': 'config',
98 'Lw_flush_off': 'config',
99 'Max Requests': 'io',
100 'Average Requests': 'io',
101 'Hard errors': 'io',
102 'Total Reads': 'io',
103 'Total Writes': 'io',
104 'Read_requests': 'io',
105 'Write_requests': 'io',
106 'Blocks_read': 'io',
107 'Blocks_written': 'io',
108 'Sum_queue_lengths_by_arrivals': 'io',
109 'Arrivals_to_non_zero_queue': 'io',
110 'Write_cache_flushes': 'io',
111 'Write_cache_blocks_flushed': 'io',
114 preparsed, errors = preparse_emcvnx_info(info)
116 for key, value in preparsed:
117 subcheck = key_to_subcheck.get(key)
118 if subcheck:
119 parsed[subcheck].append((key, value))
120 return parsed, errors
123 def inventory_emcvnx_info(parsed, subcheck):
124 output, _errors = parsed
125 if output[subcheck]:
126 return [(None, None)]
129 # .--Info----------------------------------------------------------------.
130 # | ___ __ |
131 # | |_ _|_ __ / _| ___ |
132 # | | || '_ \| |_ / _ \ |
133 # | | || | | | _| (_) | |
134 # | |___|_| |_|_| \___/ |
135 # | |
136 # '----------------------------------------------------------------------'
139 def check_emcvnx_info(item, _no_params, parsed):
140 output, errors = parsed
142 if errors:
143 yield 2, ('Error(s) while parsing the output. This may effect the '
144 'discovery of other emcvnx services. Please check your naviseccli '
145 'configuration. Errors are: %s' % (' '.join(errors)))
147 for key, value in output['info']:
148 status = 0
149 if key == 'System Fault LED' and value != 'OFF':
150 status = 2
151 yield status, "%s: %s" % (key, value)
154 check_info['emcvnx_info'] = {
155 "parse_function": parse_emcvnx_info,
156 "inventory_function": lambda x: inventory_emcvnx_info(x, 'info'),
157 "check_function": check_emcvnx_info,
158 "service_description": "EMC VNX Info",
159 "includes": ["emcvnx.include"],
162 # .--Storage-------------------------------------------------------------.
163 # | ____ _ |
164 # | / ___|| |_ ___ _ __ __ _ __ _ ___ |
165 # | \___ \| __/ _ \| '__/ _` |/ _` |/ _ \ |
166 # | ___) | || (_) | | | (_| | (_| | __/ |
167 # | |____/ \__\___/|_| \__,_|\__, |\___| |
168 # | |___/ |
169 # '----------------------------------------------------------------------'
172 def check_emcvnx_storage(item, params, parsed):
173 output, _ = parsed
174 for key, value in output['storage']:
175 yield 0, '%s: %s' % (key, value)
178 check_info['emcvnx_info.storage'] = {
179 "inventory_function": lambda x: inventory_emcvnx_info(x, 'storage'),
180 "check_function": check_emcvnx_storage,
181 "service_description": "EMC VNX Storage Processor"
184 # .--Link----------------------------------------------------------------.
185 # | _ _ _ |
186 # | | | (_)_ __ | | __ |
187 # | | | | | '_ \| |/ / |
188 # | | |___| | | | | < |
189 # | |_____|_|_| |_|_|\_\ |
190 # | |
191 # '----------------------------------------------------------------------'
194 def check_emcvnx_link(item, params, parsed):
195 output, _ = parsed
196 for key, value in output['link']:
197 status = 0
198 if key == u'Link Status' and value != u'Link-Up':
199 status = 2
200 yield status, '%s: %s' % (key, value)
203 check_info['emcvnx_info.link'] = {
204 "inventory_function": lambda x: inventory_emcvnx_info(x, 'link'),
205 "check_function": check_emcvnx_link,
206 "service_description": "EMC VNX Link"
209 # .--Config--------------------------------------------------------------.
210 # | ____ __ _ |
211 # | / ___|___ _ __ / _(_) __ _ |
212 # | | | / _ \| '_ \| |_| |/ _` | |
213 # | | |__| (_) | | | | _| | (_| | |
214 # | \____\___/|_| |_|_| |_|\__, | |
215 # | |___/ |
216 # '----------------------------------------------------------------------'
219 def check_emcvnx_config(item, params, parsed):
220 output, _ = parsed
221 for key, value in output['config']:
222 yield 0, '%s: %s' % (key, value)
225 check_info['emcvnx_info.config'] = {
226 "inventory_function": lambda x: inventory_emcvnx_info(x, 'config'),
227 "check_function": check_emcvnx_config,
228 "service_description": "EMC VNX Config"
231 # .--IO------------------------------------------------------------------.
232 # | ___ ___ |
233 # | |_ _/ _ \ |
234 # | | | | | | |
235 # | | | |_| | |
236 # | |___\___/ |
237 # | |
238 # '----------------------------------------------------------------------'
241 def check_emcvnx_io(item, params, parsed):
242 output, _ = parsed
243 for key, value in output['io']:
244 status = 0
245 if key == 'Hard errors' and value != 'N/A':
246 status = 2
247 yield status, '%s: %s' % (key, value)
250 check_info['emcvnx_info.io'] = {
251 "inventory_function": lambda x: inventory_emcvnx_info(x, 'io'),
252 "check_function": check_emcvnx_io,
253 "service_description": "EMC VNX IO"