dmraid is a software raid/fakeraid/onboard raid tool.
As far as I can tell, the only error reporting that dmraid does is by hooking into logwatch – which emails me a very long file I don’t often read and I would like to know immediately if my raid array is degraded.
This works for me on CentOS 5.6 with dmraid installed – no guarantees on other flavours/combinations. My dmraid version is dmraid-1.0.0.rc13-63.el5. I haven’t tested the output from other versions of dmraid, but it would be pretty trivial to update the script if they are different (or your path is different).
So what we are going to do is write a simple shell script that checks the array status and emails if there is a problem. Then we run the script every 15 (or whatever) minutes.
The dmraid needs to be run as root, so you might as well
su - for the whole of this.
To create the file just
vi /raid_status.sh, hit i to insert and paste this:
# check raid status and email if not ok
STATUS=`/sbin/dmraid -s | grep "status"`
if [ "$STATUS" != "status : ok" ]
/sbin/dmraid -s | mail -s "RAID ERROR ON `hostname`: $STATUS" email@example.com
Hit Esc, ZZ to save, then make the file executable:
chmod 755 /raid_status.sh
Now add it to cron so that it runs regularly:
…and insert the line (i to insert – Esc, ZZ to save):
00,15,30,45 * * * * /raid_status.sh
Voila! dmraid with email error reporting.