Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / storcli_vdrives
blobc61e67a2d94b8610c7be8906689a481207b882dd
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2016 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 factory_settings["storcli_vdrives_default_levels"] = {
28 "Optimal": 0,
29 "Partially Degraded": 1,
30 "Degraded": 2,
31 "Offline": 1,
32 "Recovery": 1,
36 def parse_storcli_vdrives(info):
38 raid_statenames = {
39 "optl": "Optimal",
40 "pdgd": "Partially Degraded",
41 "dgrd": "Degraded",
42 "ofln": "Offline",
43 "rec": "Recovery",
46 parsed = {}
48 separator_count = 0
49 for line in info:
50 if line[0].startswith("-----"):
51 separator_count += 1
52 elif separator_count == 2:
53 item, raid_type, rawstate, access, consistent = line[:5]
54 parsed[item] = {
55 "raid_type": raid_type,
56 "state": raid_statenames.get(rawstate.lower(), rawstate),
57 "access": access,
58 "consistent": consistent,
60 if separator_count == 3:
61 break
63 return parsed
66 def inventory_storcli_vdrives(parsed):
67 for item in parsed:
68 yield (item, {})
71 def check_storcli_vdrives(item, params, parsed):
73 yield 0, "Raid type is " + parsed[item]["raid_type"]
74 yield 0, "Access: " + parsed[item]["access"]
76 if parsed[item]["consistent"] == "Yes":
77 yield 0, "Drive is consistent"
78 else:
79 yield 1, "Drive is not consistent"
81 device_state = parsed[item]["state"]
82 infotext = "State is %s" % device_state
84 if device_state in params:
85 status = params[device_state]
86 else:
87 status = 3
88 infotext += " (unknown[%s])" % device_state
89 yield status, infotext
92 check_info["storcli_vdrives"] = {
93 "default_levels_variable": "storcli_vdrives_default_levels",
94 "parse_function": parse_storcli_vdrives,
95 "inventory_function": inventory_storcli_vdrives,
96 "check_function": check_storcli_vdrives,
97 "service_description": "RAID Virtual Drive %s",
98 "group": "storcli_vdrives",