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_hwstatus>>>
29 # DPE7 Bus 0 Enclosure 0
30 # Enclosure Drive Type: SAS
31 # Current Speed: 6Gbps
32 # Maximum Speed: 6Gbps
35 # Bus 0 Enclosure 0 Power A State: Present
36 # Bus 0 Enclosure 0 Power B State: Present
37 # Bus 0 Enclosure 0 SPS A State: Present
38 # Bus 0 Enclosure 0 SPS B State: Present
39 # Bus 0 Enclosure 0 SPS A Cabling State: Valid
40 # Bus 0 Enclosure 0 SPS B Cabling State: Valid
41 # Bus 0 Enclosure 0 CPU Module A State: Present
42 # Bus 0 Enclosure 0 CPU Module B State: Present
43 # Bus 0 Enclosure 0 SP A I/O Module 0 State: Present
44 # Bus 0 Enclosure 0 SP A I/O Module 1 State: Empty
45 # Bus 0 Enclosure 0 SP B I/O Module 0 State: Present
46 # Bus 0 Enclosure 0 SP B I/O Module 1 State: Empty
47 # Bus 0 Enclosure 0 DIMM Module A State: Present
48 # Bus 0 Enclosure 0 DIMM Module B State: Present
50 # DAE6S Bus 0 Enclosure 1
51 # Enclosure Drive Type: SAS, NL SAS
52 # Current Speed: 6Gbps
53 # Maximum Speed: 6Gbps
54 # Bus 0 Enclosure 1 Power A State: Present
55 # Bus 0 Enclosure 1 Power B State: Present
56 # Bus 0 Enclosure 1 LCC A State: Present
57 # Bus 0 Enclosure 1 LCC B State: Present
58 # Bus 0 Enclosure 1 LCC A Revision: 1.33
59 # Bus 0 Enclosure 1 LCC B Revision: 1.33
60 # Bus 0 Enclosure 1 LCC A Serial #: US1V2120601546
61 # Bus 0 Enclosure 1 LCC B Serial #: US1V2120602428
62 # Bus 0 Enclosure 1 LCC A Current Speed: 6Gbps
63 # Bus 0 Enclosure 1 LCC B Current Speed: 6Gbps
64 # Bus 0 Enclosure 1 LCC A Maximum Speed: 6Gbps
65 # Bus 0 Enclosure 1 LCC B Maximum Speed: 6Gbps
67 # DAE6S Bus 1 Enclosure 0
68 # Enclosure Drive Type: SAS, NL SAS
69 # Current Speed: 6Gbps
70 # Maximum Speed: 6Gbps
71 # Bus 1 Enclosure 0 Power A State: Present
73 # Parse agent output into a dict of the form:
76 # "Power A" : "Present",
77 # "Power B" : "Present",
83 def parse_emcvnx_hwstatus(info
):
86 # recognice Enclosures by a line like
87 # DAE6S Bus 0 Enclosure 1
88 # with maybe an additional error message if Overall Status is not ok
89 if len(line
) > 3 and line
[1] == "Bus" and line
[3] == "Enclosure":
90 encid
= line
[2] + "/" + line
[4]
94 enc
["Overall Status"] = line
[5].replace("*", "")
96 enc
["Overall Status"] = "No Errors Reported"
97 # recognice Enclosures by a line like
99 # with maybe an additional error message if Overall Status is not ok
100 elif len(line
) > 2 and line
[1] == "Enclosure":
105 enc
["Overall Status"] = line
[3].replace("*", "")
107 enc
["Overall Status"] = "No Errors Reported"
108 # gather additional information about an Enclosure found in one
110 elif len(line
) > 2 and line
[-2] == "State:":
112 device
= line
[0] + " " + line
[1]
114 device
= " ".join(line
[4:-2])
120 def inventory_emcvnx_hwstatus(info
):
121 parsed
= parse_emcvnx_hwstatus(info
)
123 for enclosure
in parsed
:
124 for device
in parsed
[enclosure
]:
125 if parsed
[enclosure
][device
] != "Empty":
126 inventory
.append((enclosure
+ " " + device
, None))
130 def check_emcvnx_hwstatus(item
, _no_params
, info
):
131 enc
, device
= item
.split(" ", 1)
133 devstate
= parse_emcvnx_hwstatus(info
)[enc
][device
]
134 if devstate
in ("Present", "Valid", "No Errors Reported"):
138 return nagstate
, "Enclosure %s is %s" % (item
, devstate
)
141 return 3, "Enclosure %s not found in agent output" % item
144 check_info
['emcvnx_hwstatus'] = {
145 "inventory_function": inventory_emcvnx_hwstatus
,
146 "check_function": check_emcvnx_hwstatus
,
147 "service_description": "Enclosure %s", # Example for Item: "0/1 Power A"