
Linux
Linux Software Raid Plugin for 32-bit and 64-bit systems
Description:
Checks Linux Software Raid (also known as MD Raid). Works on both 32-bit and 64-bit systems
Current Version
Last Release Date
June 12, 2009
Compatible With
Owner
Project Files
File | Description |
---|---|
check_md_raid | version 0.7.2 |
Project Notes
Usage
Run the plugin is as follows:
./check_md_raid
RAID OK: All arrays OK [1 array checked]
It requires the mdadm utility which is what you also used to create the raid array. If it is not in the standard location of /sbin/mdadm then just do the following
ln -s /path/to/mdadm /sbin/mdadm
and then run the plugin again.
This runs straight on both 32-bit and 64-bit systems and all modern linux distros that have Python.
This has been tested and all works nicely for me on servers of both architectures and across distros.
The plugin must be run as root in order to test the state of all the arrays. Use sudo to grant the nagios or nrpe user the rights to run it using sudo without a password like so:
visudo
add the following line:
nagios (ALL)=ALL NOPASSWD:/path/to/check_md_raid
Rewritten to work with python 2.3 as well (no longer uses subprocess for those of you on debian...)
Support
If you have any issues, contact me at hpsekhon(AT)googlemail.com
Reviews
(11)
Add a Review
Hello,
it seem's like there is some wrong output with your plugin:
root@h7 ~ # /usr/lib/nagios/plugins/check_md_raid
RAID CRITICAL: 5 arrays not ok - Array 0 is in state "clean " (raid1), Array 1 is in state "clean " (raid1), Array 2 is in state "clean " (raid1), Array 3 is in state "clean " (raid1), Array 4 is in state "active " (raid1) [5 arrays checked]
All arrays are ok but the plugin is saying they are not. Is this maybe some problem with LVM2?
it seem's like there is some wrong output with your plugin:
root@h7 ~ # /usr/lib/nagios/plugins/check_md_raid
RAID CRITICAL: 5 arrays not ok - Array 0 is in state "clean " (raid1), Array 1 is in state "clean " (raid1), Array 2 is in state "clean " (raid1), Array 3 is in state "clean " (raid1), Array 4 is in state "active " (raid1) [5 arrays checked]
All arrays are ok but the plugin is saying they are not. Is this maybe some problem with LVM2?
This is the patch I used to get it to properly read active and clean states.
--- check_md_raid.orig
+++ check_md_raid
@@ -110,7 +110,7 @@ def test_raid(verbosity):
if "State :" in line:
state = line.split(":")[-1][1:-1]
re_clean = re.compile('^clean(, no-errors)?$')
- if not re_clean.match(state) and state != "active":
+ if not re_clean.match(state) and state != "active" and state != "active " and state != "clean" and state != "clean ":
arrays_not_ok += 1
raidlevel = detailed_output[3].split()[-1]
shortname = array.split("/")[-1].upper()
--- check_md_raid.orig
+++ check_md_raid
@@ -110,7 +110,7 @@ def test_raid(verbosity):
if "State :" in line:
state = line.split(":")[-1][1:-1]
re_clean = re.compile('^clean(, no-errors)?$')
- if not re_clean.match(state) and state != "active":
+ if not re_clean.match(state) and state != "active" and state != "active " and state != "clean" and state != "clean ":
arrays_not_ok += 1
raidlevel = detailed_output[3].split()[-1]
shortname = array.split("/")[-1].upper()
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"
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"
...but, wanted to point out a couple of things I found while adding this plugin to my Nagios installation:
- Should use /usr/bin/sudo and not just sudo in your commands.cfg file.
- If while installing and testing this plugin, Nagios returns a warning for this service and "(null)" for a Status, then comment out "Defaults requiretty" in your /etc/sudoers. I spent a lot of time trying to get the plugin working, searching the web, debugging, etc. and finally found out it was just a setting in my sudoers file (I'm on FC12).
- FYI, I emailed the plugin support address and got no response. So, don't know if this plugin is supported anymore.
Hope this information is useful for others.
- Should use /usr/bin/sudo and not just sudo in your commands.cfg file.
- If while installing and testing this plugin, Nagios returns a warning for this service and "(null)" for a Status, then comment out "Defaults requiretty" in your /etc/sudoers. I spent a lot of time trying to get the plugin working, searching the web, debugging, etc. and finally found out it was just a setting in my sudoers file (I'm on FC12).
- FYI, I emailed the plugin support address and got no response. So, don't know if this plugin is supported anymore.
Hope this information is useful for others.
Add a Review
You must be logged in to submit a review.
Thank you for your review!
Your review has been submitted and is pending approval.
Recommend
To:
From:
Thank you for your recommendation!
Your recommendation has been sent.
Page Sections
Project Stats
Rating
4.5 (19)
Favorites
4
Views
120,914