2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2017 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 def preparse_emcvnx_info(info
):
39 preparsed
, errors
, skip_lines
= [], set(), 0
41 line
= [x
.strip() for x
in line
]
43 key
, value
= line
[0], None
45 # the value can contain the separator ':'
46 key
, value
= line
[0], ':'.join(line
[1:])
48 # fix naviseccli error that does not output a colon for some values
49 if value
is None and (key
.startswith('SP Read Cache State') or
50 key
.startswith('SP Write Cache State')):
52 key
, value
= ' '.join(tmp
[:-1]), tmp
[-1]
54 if key
.startswith('Error'):
55 skip_lines
, error
= 1, []
56 elif key
.startswith('Unable to validate the identity of the server'):
57 # assumes that certificate errors are always 10 lines long
58 skip_lines
, error
= 10, []
61 if key
.startswith('---'): # remove headline
64 elif value
is None: # append in case of a line continuation
66 old_key
, old_value
= preparsed
[-1]
67 preparsed
[-1] = (old_key
, ', '.join([old_value
, value
]))
68 elif not value
: # remove subheader
71 preparsed
.append((key
, convert(value
)))
73 error
.append(': '.join(line
))
76 errors
.add(' '.join(error
))
79 return preparsed
, list(errors
)