Module: check_mk
Branch: master
Commit: d9a54e1eefb1a8e891eccaa5f7af4bc1fcfe2bf7
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d9a54e1eefb1a8…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Thu Mar 7 09:06:39 2019 +0100
7119 FIX ibm_svc_enclosure: Incorrect parsed agent output led to a false report 'Only
0 of X canisters are online'
Change-Id: I9af61a74cb5bed590197db56a1d09c863bb7d4ef
---
.werks/7119 | 11 ++++++++
checks/ibm_svc_enclosure | 70 ++++++++++++++++++------------------------------
2 files changed, 37 insertions(+), 44 deletions(-)
diff --git a/.werks/7119 b/.werks/7119
new file mode 100644
index 0000000..80889a8
--- /dev/null
+++ b/.werks/7119
@@ -0,0 +1,11 @@
+Title: ibm_svc_enclosure: Incorrect parsed agent output led to a false report 'Only 0
of X canisters are online'
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1551880134
+
+
diff --git a/checks/ibm_svc_enclosure b/checks/ibm_svc_enclosure
index 73cc5ad..9383cca 100644
--- a/checks/ibm_svc_enclosure
+++ b/checks/ibm_svc_enclosure
@@ -48,6 +48,7 @@
# IBM-FLASH900
# <<<ibm_svc_enclosure:sep(58)>>>
+#
id:status:type:product_MTM:serial_number:total_canisters:online_canisters:online_PSUs:drive_slots
# 1:online:control:9843-AE2:6860407:2:2:2:12
@@ -63,16 +64,18 @@ def check_ibm_svc_enclosure(item, _no_params, info):
for line in info:
if line[0] == item:
if len(line) == 9:
- line = line[:2] + [None, None, None
- ] + line[2:6] + ["0"] + line[6:] +
["0", "0", "0", "0"]
+ line = line[:3] + [None, None, None] + line[3:7] + [
+ None
+ ] + line[7:] + [None, None, None, None]
elif len(line) == 13:
- line = line + ["0", "0", "0",
"0"]
+ line = line + [None, None, None, None]
elif len(line) == 15:
- line = line + ["0", "0"]
+ line = line + [None, None]
elif len(line) == 17:
pass
else:
- return 3, "Unknown format"
+ yield 3, "Unknown format"
+ return
enclosure_id, enclosure_status, _enclosure_type, _managed, _IO_group_id, \
_IO_group_name, _product_MTM, _serial_number, total_canisters,
online_canisters, \
@@ -80,49 +83,28 @@ def check_ibm_svc_enclosure(item, _no_params, info):
total_secondary_expander_modules, online_secondary_expander_modules =
line
# Check status
- message = "Enclosure %s is %s" % (enclosure_id, enclosure_status)
if enclosure_status == "online":
status = 0
else:
status = 2
- message += "(!!)"
-
- # Check canisters
- if online_canisters == total_canisters:
- message += ", all %s canisters are online" % total_canisters
- else:
- status = 2
- message += ", only %s of %s canisters are online(!!)" %
(online_canisters,
-
total_canisters)
-
- # Check PSUs
- if online_PSUs == total_PSUs:
- message += ", all %s PSUs are online" % total_PSUs
- else:
- status = 2
- message += ", only %s of %s PSUs are online(!!)" %
(online_PSUs, total_PSUs)
-
- # Check FANs (only new firmware)
- if online_fan_modules == total_fan_modules:
- if total_fan_modules != "0":
- message += ", all %s fan modules are online" %
total_fan_modules
- else:
- status = 2
- message += ", only %s of %s fan modules are online(!!)" %
(online_fan_modules,
-
total_fan_modules)
-
- # Check SEMs (only firmware >= 7.8)
- if online_secondary_expander_modules == total_secondary_expander_modules:
- if total_secondary_expander_modules != "0":
- message += ", all %s secondary expander modules are online"
% total_secondary_expander_modules
- else:
- status = 2
- message += ", only %s of %s secondary expander modules are
online(!!)" % (
- online_secondary_expander_modules, total_secondary_expander_modules)
-
- return status, message
-
- return 3, "Enclosure %s not found in agent output" % item
+ yield status, "Status: %s" % enclosure_status
+
+ for online, total, text in [
+ (online_canisters, total_canisters, 'canisters'),
+ (online_PSUs, total_PSUs, "PSUs"),
+ (online_fan_modules, total_fan_modules, 'fan modules'),
+ (online_secondary_expander_modules,
+ total_secondary_expander_modules,
+ 'secondary expander modules'),
+ ]:
+ if online is None:
+ continue
+ state = 0
+ infotext = "Online %s: %s" % (text, online)
+ if total is not None and online != total:
+ state = 2
+ infotext += " of %s" % total
+ yield state, infotext
check_info["ibm_svc_enclosure"] = {