Search All Sites
Nagios Live WebinarsLet our experts show you how Nagios can help your organization.
Don't miss your chance to attend the 2014 Nagios World Conference, Oct 13-16th. Informative Sessions, Networking, Food and Cocktails! Visit go.nagios.com/conference/ for more information or to register.
Checks Linux Software Raid (also known as MD Raid). Works on both 32-bit and 64-bit systems
Run the plugin is as follows:
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:
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...)
If you have any issues, contact me at hpsekhon(AT)googlemail.com
state = line.split(":")[-1][1:-1]
just add after this line :
state = state.strip()
and it works very fine now :-)
Thanks for this work!
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?
@@ -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.split()[-1]
shortname = array.split("/")[-1].upper()
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.
--- 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
- elif "recovering" in state:
+ elif "recovering" in state or "check" in state:
+ real_array_path = os.popen("%s -f %s " % (READLINK, array) ).readlines().split()
+ real_array_id = real_array_path.split("/")[-1]
+ real_state = os.popen( ( "%s " + SYNCACTION ) % (CAT,real_array_id) ).readlines().split()
+ if "check" in real_state:
+ message += 'Array "%s" is in state "checking", ' % shortname
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"
Using on Ubuntu server 10.10 client side, and Ubuntu server 10.4 Nagios3 server.
Simple and effective, as the subject states.
10 minutes from download to active monitoring, provided you already have nrpe running of course.
-- Trev Thorpe
- 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.
(took me 10 minutes to find out ;-) )
Great plugin though