Module: check_mk
Branch: master
Commit: 3a75b3c98d4574f5756664131615025a0d1b7624
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3a75b3c98d4574…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Feb 17 12:13:04 2011 +0100
Improved 3ware_units check
* 3ware_units: Handling INITIALIZING state as warning now
* 3ware_units: Better handling of outputs from different tw_cli versions now
Thanks to Matthias Henze <lists(a)mhcsoftware.de> for reporting and the
original patch.
Signed-off-by: Lars Michelsen <lm(a)mathias-kettner.de>
---
ChangeLog | 2 ++
checks/3ware_units | 28 +++++++++++++++++++++++++---
2 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 8afea28..25c8098 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -21,6 +21,8 @@
* df, df_netapp, df_netapp32, hr_fs, vms_df: all filesystem checks now support
trends. Please look at check manpage of df for details.
* FIX: heartbeat_nodes: Fixed error handling when node is active but at least one
link is dead
+ * 3ware_units: Handling INITIALIZING state as warning now
+ * 3ware_units: Better handling of outputs from different tw_cli versions now
Multisite:
* FIX: fix "too many values to unpack" when editing views in single layout
diff --git a/checks/3ware_units b/checks/3ware_units
index f6e38eb..1b0cd4d 100644
--- a/checks/3ware_units
+++ b/checks/3ware_units
@@ -29,6 +29,14 @@
# u0 RAID-5 OK - - 64K 1788.08 ON OFF
# u1 RAID-5 INOPERABLE - - 64K 1788.08 OFF OFF
+# Different versions of tw_cli have different outputs. This means the size column
+# used by this check is in different places. Here is a an example:
+#
+# Unit UnitType Status %Cmpl Stripe Size(GB) Cache AVerify IgnECC
+# u0 RAID-5 INITIALIZING 84 64K 1396.95 ON ON OFF
+#
+# Unit UnitType Status %RCmpl %V/I/M Stripe Size(GB) Cache AVrfy
+# u0 RAID-5 OK - - 64K 1396.95 ON ON
# inventory
def inventory_3ware_units(checkname, info):
@@ -42,12 +50,26 @@ def inventory_3ware_units(checkname, info):
def check_3ware_units(item, param, info):
for line in info:
if line[0] == item:
- status = line[2]
unit_type = line[1]
- size = line[6]
- infotext = "%s (type: %s, size: %s GB)" % (status, unit_type,
size)
+ status = line[2]
+ complete = line[3]
+
+ # Handle different outputs of tw_cli
+ try:
+ size = float(line[6])
+ except ValueError:
+ size = float(line[5])
+
+ complete_txt = ''
+ if complete != '-':
+ complete_txt = ' complete: %s%%' % complete
+
+ infotext = "%s (type: %s, size: %sGB%s)" % (status, unit_type,
size, complete_txt)
+
if status == "OK":
return (0, "OK - unit status is " + infotext)
+ elif status == "INITIALIZING":
+ return (1, "WARNING - unit status is " + infotext)
else:
return (2, "CRITICAL - unit status is " + infotext)
return (3, "UNKNOWN - unit %s not found in agent output" % item)