Random Project

Excellent plugin

This plugin works as expected.
Great job.

You’ll find above a small patch of a modification I did to ignore “active, checking” states being identified as critical.
Every weeks all my servers using MD are being checked at night, which triggers tons of unwanted notifications about “raid recovery”.
The patch also include a workaround to a wrong information (recovering) provided by mdadm with raid10 while in check state.

Regards,
Benjamin

— check_md_raid 2012-08-02 12:31:25.900899840 +0200
+++ check_md_raid.new 2012-08-02 14:08:01.873932844 +0200
@@ -35,6 +35,9 @@

# Full path to the mdadm utility check on the Raid state
BIN = “/sbin/mdadm”
+SYNCACTION = “/sys/block/%s/md/sync_action”
+READLINK = “/bin/readlink”
+CAT = “/bin/cat”

def end(status, message):
“””exits the plugin with first arg as the return code and the second
@@ -119,7 +122,13 @@
# This happens when the array is under heavy usage but it’s
# normal and the array recovers within seconds
continue
– elif “recovering” in state:
+ elif “recovering” in state or “check” in state:
+ real_array_path = os.popen(“%s -f %s ” % (READLINK, array) ).readlines()[0].split()[0]
+ real_array_id = real_array_path.split(“/”)[-1]
+ real_state = os.popen( ( “%s ” + SYNCACTION ) % (CAT,real_array_id) ).readlines()[0].split()[0]
+ if “check” in real_state:
+ message += ‘Array “%s” is in state “checking”, ‘ % shortname
+ continue
extra_info = None
for line in detailed_output:
if “Rebuild Status” in line:
@@ -141,8 +150,8 @@
message += ‘Array %s is in state “%s” (%s), ‘
% (shortname, state, raidlevel)
status = CRITICAL

– message = message.rstrip(“, “)
+ if not status == OK and message:
+ message = message.rstrip(“, “)

if status == OK:
message += “All arrays OK”