Check hardware RAID array status on Ubuntu Server

Here’s a post I’ve been sitting on for a bit over two years.  I was doing some clean-up/organization on my hard drive today and I ran across the text file with the notes that I made.  :-P

We have some Dell servers running Ubuntu Server on a RAID array.  It is necessary to be able to check on the status of the RAID array programmatically¬†and fire off alerts if one of the disks fails.

This is actually pretty easy to accomplish.

First, install the mpt-status package (sudo aptitude install mpt-status).

Then, load the mptctl kernel module (sudo modprobe mptctl).

Find the SCSI ID for your disk array (sudo mpt-status -p).  For me, it was “2.”

Get a RAID status report with¬†mpt-status -i 2 (where “2” is the SCSI ID from the previous step).  mpt-status should be run as the root user. You can add the -n flag to get some additional information in the output, including the percent completion of an in-progress rebuild operation.

The exit code for mpt-status will be 0 if everything looks good or something else if there is a problem.