Cleanup config.nodes_of
[check_mk.git] / checks / hp_proliant_raid
blob7bcdb48b42e615ee53147649e34134c4f999a03d
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.
28 def parse_hp_proliant_raid(info):
29 parsed = {}
30 for number, name, status, size_str, rebuild in info:
31 if name in parsed:
32 itemname = "%s %s" % (name, number)
33 else:
34 itemname = name
36 parsed.setdefault(itemname.strip(), {
37 "status": status,
38 "size": int(size_str) * 1024 * 1024,
39 "rebuild_perc": rebuild,
42 return parsed
45 def inventory_hp_proliant_raid(parsed):
46 for raid in parsed:
47 yield raid, None
50 def check_hp_proliant_raid(item, _no_params, parsed):
51 map_states = {
52 "1": (3, "other"),
53 "2": (0, "OK"),
54 "3": (2, "failed"),
55 "4": (1, "unconfigured"),
56 "5": (1, "recovering"),
57 "6": (1, "ready for rebuild"),
58 "7": (1, "rebuilding"),
59 "8": (2, "wrong drive"),
60 "9": (2, "bad connect"),
61 "10": (2, "overheating"),
62 "11": (1, "shutdown"),
63 "12": (1, "automatic data expansion"),
64 "13": (2, "not available"),
65 "14": (1, "queued for expansion"),
66 "15": (1, "multi-path access degraded"),
67 "16": (1, "erasing"),
70 if item in parsed:
71 data = parsed[item]
72 dev_status = data["status"]
73 state, state_readable = map_states[dev_status]
74 infotext = "Status: %s, Logical volume size: %s" % \
75 (state_readable, get_bytes_human_readable(data["size"]))
77 # From CPQIDA-MIB:
78 # This value is the percent complete of the rebuild.
79 # This value is only valid if the Logical Drive Status is
80 # rebuilding (7) or expanding (12).
81 # If the value cannot be determined or a rebuild is not active,
82 # the value is set to 4,294,967,295.
83 if dev_status in ["7", "12"]:
84 infotext += "Rebuild: %s%%" % data["rebuild_perc"]
86 return state, infotext
89 check_info["hp_proliant_raid"] = {
90 'parse_function': parse_hp_proliant_raid,
91 'check_function': check_hp_proliant_raid,
92 'inventory_function': inventory_hp_proliant_raid,
93 'service_description': 'Logical Device %s',
94 'snmp_info': (
95 ".1.3.6.1.4.1.232.3.2.3.1.1",
97 "2", # CPQIDA-MIB::cpqDaLogDrvIndex
98 "14", # CPQIDA-MIB::cpqDaLogDrvOsName
99 "4", # CPQIDA-MIB::cpqDaLogDrvStatus
100 "9", # CPQIDA-MIB::cpqDaLogDrvSize
101 "12", # CPQIDA-MIB::cpqDaLogDrvPercentRebuild
103 'snmp_scan_function': lambda oid: "proliant" in oid(".1.3.6.1.4.1.232.2.2.4.2.0", "").lower(),