Home Directory Plugins Operating Systems Linux Linux Software Raid Plugin for 32-bit and 64-bit systems

Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com


Remember Me

Linux Software Raid Plugin for 32-bit and 64-bit systems

Network Monitoring Software - Download Nagios XI
Log Management Software - Nagios Log Server - Download
Netflow Analysis Software - Nagios Network Analyzer - Download
19 votes
check_md_raidversion 0.7.2
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
Reviews (11)
byjurim, June 16, 2014
RAID CRITICAL: 1 array not ok - Array 0 is in state "clean " (raid1) [1 array checked]

To chomp spaces, if state = "clean " or "active "

if "State :" in line:
state = line.split(":")[-1][1:-1]
state = state[:-1]
byafernandez, October 22, 2013
Can anyone explain to me how exactly step by step i installed this in nagiosxi
byPracz, August 20, 2013

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?
bynickatnite, October 18, 2012
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()
bybmalynovytch, August 2, 2012
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.


--- 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()[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"
byminitux, February 28, 2012
2 of 2 people found this review helpful
line 111 :
state = line.split(":")[-1][1:-1]

just add after this line :

state = state.strip()

and it works very fine now :-)
byTrevThorpe, November 8, 2011
Very easy to get running.

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
byBlinkyn, February 21, 2011
...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.
byBhawks_2, September 26, 2010
Great plugin, does exactly what is needed. Would have given it maximum stars if you had added that you need to run the command with

sudo /path/to/check_md_raid

(took me 10 minutes to find out ;-) )

Great plugin though
bymomocello, September 4, 2010
A few array rebuilding later,
this plugin works perfectly.

byevlist, February 14, 2010
1 of 1 people found this review helpful
It is also well documented and can easily be used as a basis to write other plugins.

Thanks for this work!