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 # check_mk plugin to monitor Fujitsu storage systems supporting FJDARY-E60.MIB or FJDARY-E100.MIB
28 # Copyright (c) 2012 FuH Entwicklungsgesellschaft mbH, Umkirch, Germany. All rights reserved.
29 # Author: Philipp Hoefflin, 2012, hoefflin+cmk@fuh-e.de
31 # generic data structure widely used in the FJDARY-Mibs:
35 # the latter can be one of the following:
36 fjdarye_item_status
= {
46 # generic inventory item - status other than 'invalid' is ok for inventory
47 def inventory_fjdarye_item(info
):
48 return [(int(index
), '', None) for index
, status
in info
if int(status
) != 4]
51 # generic check_function returning the nagios-code and the status text
52 def check_fjdarye_item(index
, _no_param
, info
):
54 if int(line
[0]) == index
:
62 return (code
, "Status is %s" % (fjdarye_item_status
[status
]))
63 return (3, 'No status for item %d present' % index
)
67 # .--single disks--------------------------------------------------------.
69 # | ___(_)_ __ __ _| | ___ __| (_)___| | _____ |
70 # | / __| | '_ \ / _` | |/ _ \ / _` | / __| |/ / __| |
71 # | \__ \ | | | | (_| | | __/ | (_| | \__ \ <\__ \ |
72 # | |___/_|_| |_|\__, |_|\___| \__,_|_|___/_|\_\___/ |
74 # +----------------------------------------------------------------------+
75 # | disks main check |
76 # '----------------------------------------------------------------------'
78 fjdarye_disks_status
= {
79 "1": (0, 'available'),
81 "3": (1, 'notavailable'),
82 "4": (1, 'notsupported'),
85 "7": (1, 'recovering'),
86 "64": (1, 'partbroken'),
88 "66": (0, 'formatting'),
89 "67": (0, 'unformated'),
90 "68": (1, 'notexist'),
95 def parse_fjdarye_disks(info
):
97 for idx
, disk_state
in info
:
98 state
, state_readable
= fjdarye_disks_status
.get(disk_state
,
99 (3, "unknown[%s]" % disk_state
))
103 "state_readable": state_readable
,
104 "state_disk": disk_state
,
109 def inventory_fjdarye_disks(parsed
):
110 return [(idx
, repr(attrs
["state_readable"]))
111 for idx
, attrs
in parsed
.items()
112 if attrs
["state_disk"] != "3"]
115 def check_fjdarye_disks(item
, params
, parsed
):
116 if isinstance(params
, str):
117 params
= {"expected_state": params
}
121 state_readable
= attrs
["state_readable"]
122 expected_state
= params
.get("expected_state")
124 infotext
= "Status: %s" % state_readable
125 if params
.get("use_device_states"):
126 check_state
= attrs
["state"]
128 infotext
+= " (use device states)"
129 elif expected_state
and state_readable
!= expected_state
:
131 infotext
+= " (expected: %s)" % expected_state
132 return check_state
, infotext
134 return 3, "No status for disk number %s present" % item
138 # .--summary disks-------------------------------------------------------.
140 # | ___ _ _ _ __ ___ _ __ ___ __ _ _ __ _ _ |
141 # | / __| | | | '_ ` _ \| '_ ` _ \ / _` | '__| | | | |
142 # | \__ \ |_| | | | | | | | | | | | (_| | | | |_| | |
143 # | |___/\__,_|_| |_| |_|_| |_| |_|\__,_|_| \__, | |
146 # | __| (_)___| | _____ |
147 # | / _` | / __| |/ / __| |
148 # | | (_| | \__ \ <\__ \ |
149 # | \__,_|_|___/_|\_\___/ |
151 # '----------------------------------------------------------------------'
154 def fjdarye_disks_summary(parsed
):
156 for attrs
in parsed
.itervalues():
157 if attrs
["state_disk"] != "3":
158 states
.setdefault(attrs
["state_readable"], 0)
159 states
[attrs
["state_readable"]] += 1
163 def inventory_fjdarye_disks_summary(parsed
):
164 current_state
= fjdarye_disks_summary(parsed
)
165 if len(current_state
) > 0:
166 return [(None, current_state
)]
169 def fjdarye_disks_printstates(states
):
170 return ", ".join(["%s: %s" % (s
.title(), c
) for s
, c
in states
.items()])
173 def check_fjdarye_disks_summary(index
, params
, parsed
):
190 use_devices_states
= False
191 if "use_device_states" in params
:
192 use_devices_states
= params
["use_device_states"]
193 del params
["use_device_states"]
194 expected_state
= params
196 current_state
= fjdarye_disks_summary(parsed
)
197 infotext
= fjdarye_disks_printstates(current_state
)
198 if use_devices_states
:
200 for state_readable
in current_state
:
201 state
= max(state
, map_states
.get(state_readable
, 3))
202 infotext
+= " (ignore expected state)"
203 return state
, infotext
205 if current_state
== expected_state
:
209 for ename
, ecount
in expected_state
.items():
210 if current_state
.get(ename
, 0) < ecount
:
214 return result
, "%s (expected: %s)" % (infotext
, fjdarye_disks_printstates(expected_state
))
218 # .--rluns---------------------------------------------------------------.
220 # | _ __| |_ _ _ __ ___ |
221 # | | '__| | | | | '_ \/ __| |
222 # | | | | | |_| | | | \__ \ |
223 # | |_| |_|\__,_|_| |_|___/ |
225 # '----------------------------------------------------------------------'
228 def inventory_fjdarye_rluns(info
):
231 if rawdata
[3] == u
'\xa0': # RLUN is present
232 yield line
[0], "", None
235 def check_fjdarye_rluns(item
, _no_params
, info
):
239 if rawdata
[3] != u
'\xa0':
240 return (2, "RLUN is not present")
241 elif rawdata
[2] == u
'\x08':
242 return (1, "RLUN is rebuilding")
243 elif rawdata
[2] == u
'\x07':
244 return (1, "RLUN copyback in progress")
245 elif rawdata
[2] == u
'\x41':
246 return (1, "RLUN spare is in use")
247 elif rawdata
[2] == u
'B':
248 return (0, "RLUN is in RAID0 state") # assumption state 42
249 elif rawdata
[2] == u
'\x00':
250 return (0, "RLUN is in normal state") # assumption
251 return (2, "RLUN in unknown state %02x" % ord(rawdata
[2]))
256 fjdarye_sum_status
= {1: 'unknown', 2: 'unused', 3: 'ok', 4: 'warning', 5: 'failed'}
259 def inventory_fjdarye_sum(info
):
260 if len(info
[0]) == 1:
264 def check_fjdarye_sum(index
, _no_param
, info
):
266 if len(info
[0]) == 1:
267 status
= int(line
[0])
268 text
= "Status is %s" % fjdarye_sum_status
[status
]
271 return (0, "%s" % text
)
273 return (1, "%s" % text
)
274 return (2, "%s" % text
)
276 return (3, "No status summary present")