Added missing states
Message-ID: <58d90ace.ZaLXJNGoBiCHZbGL%si(a)mathias-kettner.de>
User-Agent: Heirloom mailx 12.5 6/20/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Module: check_mk
Branch: master
Commit: 7f2b88a773ba5a901cd7e2dcf263dbfc1a21b522
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7f2b88a773ba5a…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Mon Mar 27 14:46:57 2017 +0200
4529 FIX hp_proliant_raid: Fixed incomplete raid detection; Added missing states
Change-Id: I579af05382f7dfca5f0c119f3514655351beb519
---
.werks/4529 | 11 +++++
checks/hp_proliant_raid | 113 +++++++++++++++++++++++++++++-------------------
2 files changed, 80 insertions(+), 44 deletions(-)
diff --git a/.werks/4529 b/.werks/4529
new file mode 100644
index 0000000..74c0b04
--- /dev/null
+++ b/.werks/4529
@@ -0,0 +1,11 @@
+Title: hp_proliant_raid: Fixed incomplete raid detection; Added missing states
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i1
+Date: 1490618589
+
+
diff --git a/checks/hp_proliant_raid b/checks/hp_proliant_raid
index 7552273..5d7cf3b 100644
--- a/checks/hp_proliant_raid
+++ b/checks/hp_proliant_raid
@@ -25,54 +25,79 @@
# Boston, MA 02110-1301 USA.
-def inventory_hp_proliant_raid(info):
- if len(info) > 0:
- inventory = []
- for line in info:
- inventory.append((line[0], None))
- return inventory
+def parse_hp_proliant_raid(info):
+ parsed = {}
+ for number, name, status, size_str, rebuild in info:
+ if name in parsed:
+ itemname = "%s %s" % (name, number)
+ else:
+ itemname = name
-def check_hp_proliant_raid(item, _no_params, info):
- hp_proliant_raid_statusmap = {
- 3 : "More physical drives have failed than the fault tolerance mode can
handle.",
- 4 : "Logical drive is not configured.",
- 5 : "Recovery for at least one physical drive hasfailed. No data loss
currently.",
- 6 : "Logical drive is ready for recovery but is still operating in Interim
Recovery Mode.",
- 8 : "The wrong physical drive was replaced after failure.",
- 9 : "A physical drive is not responding.",
- 10 : "Enclosue is overheated but drives still functioning and should be
shutdown.",
- 11 : "Enclosure is overheated and drives are shutdown.",
- 12 : "Logical drive is currently doing Automatic Data Expansion.",
- 13 : "Logical drive is currently unavailable.",
- 14 : "Logical drive is in the queue for expansion.",
+ parsed.setdefault(itemname.strip(), {
+ "status" : status,
+ "size" : int(size_str) * 1024 * 1024,
+ "rebuild_perc" : rebuild,
+ })
+ return parsed
+
+
+def inventory_hp_proliant_raid(parsed):
+ for raid in parsed:
+ yield raid, None
+
+
+def check_hp_proliant_raid(item, _no_params, parsed):
+ map_states = {
+ "1" : (3, "other"),
+ "2" : (0, "OK"),
+ "3" : (2, "failed"),
+ "4" : (1, "unconfigured"),
+ "5" : (1, "recovering"),
+ "6" : (1, "ready for rebuild"),
+ "7" : (1, "rebuilding"),
+ "8" : (2, "wrong drive"),
+ "9" : (2, "bad connect"),
+ "10" : (2, "overheating"),
+ "11" : (1, "shutdown"),
+ "12" : (1, "automatic data expansion"),
+ "13" : (2, "not available"),
+ "14" : (1, "queued for expansion"),
+ "15" : (1, "multi-path access degraded"),
+ "16" : (1, "erasing"),
}
- for line in info:
- if line[0] == item:
- state, size_mb, percent_rebuild = map(saveint, line[1:])
- drive_size = "Logical Volume Size: %s" %
get_bytes_human_readable(size_mb * 1024 * 1024 )
- if state == 7:
- return 1, "Rebuild: %d%% finished. %s" % ( percent_rebuild,
drive_size )
- if state == 2:
- return 0, "In normal operation mode. " + drive_size
- if state in [ 4, 5, 6, 12, 14 ]:
- return 1, hp_proliant_raid_statusmap[state] + drive_size
- if state in [ 3, 8, 9, 10, 12, 13 ]:
- return 2, hp_proliant_raid_statusmap[state] + drive_size
- return (3, "Drive not found or Uknown state")
+
+ if item in parsed:
+ data = parsed[item]
+ dev_status = data["status"]
+ state, state_readable = map_states[dev_status]
+ infotext = "Status: %s, Logical volume size: %s" % \
+ (state_readable, get_bytes_human_readable(data["size"]))
+
+ # From CPQIDA-MIB:
+ # This value is the percent complete of the rebuild.
+ # This value is only valid if the Logical Drive Status is
+ # rebuilding (7) or expanding (12).
+ # If the value cannot be determined or a rebuild is not active,
+ # the value is set to 4,294,967,295.
+ if dev_status in [ "7", "12" ]:
+ infotext += "Rebuild: %s%%" % data["rebuild_perc"]
+
+ return state, infotext
+
check_info["hp_proliant_raid"] = {
- 'check_function': check_hp_proliant_raid,
- 'inventory_function': inventory_hp_proliant_raid,
- 'service_description': 'Logical Device %s',
- 'snmp_info': (
- ".1.3.6.1.4.1.232.3.2.3.1.1", [
- 14, # Drive Name
- 4, # Logical Drive status
- 9, # Drive Size
- 12, # Percent rebuild
- ]
- ),
- 'snmp_scan_function': \
+ 'parse_function' : parse_hp_proliant_raid,
+ 'check_function' : check_hp_proliant_raid,
+ 'inventory_function' : inventory_hp_proliant_raid,
+ 'service_description' : 'Logical Device %s',
+ 'snmp_info' : (".1.3.6.1.4.1.232.3.2.3.1.1", [
+ "2", # CPQIDA-MIB::cpqDaLogDrvIndex
+ "14", # CPQIDA-MIB::cpqDaLogDrvOsName
+ "4", # CPQIDA-MIB::cpqDaLogDrvStatus
+ "9", # CPQIDA-MIB::cpqDaLogDrvSize
+ "12", #
CPQIDA-MIB::cpqDaLogDrvPercentRebuild
+ ]),
+ 'snmp_scan_function' : \
lambda oid: "proliant" in oid(".1.3.6.1.4.1.232.2.2.4.2.0",
"").lower(),
}