21 Apr 2015
Setting up Software RAID / MDADM status alert Emails for failed drives in Centos, Ubuntu, and Debian
Easy instructions for setting up mdadm / software raid email alerts for failed drives in Centos, Ubuntu, and Debian:First off, start by editing the following file. On Centos:
nano /etc/mdadm.confOn Debian / Ubuntu:
nano /etc/mdadm/mdadm.confMake sure the configuration file it has the following line in it. If it doesn’t, copy and paste it in there:
DEVICE partitionsAlso add to this file the email address you’d like to have receive notifications:
MAILADDR firstname.lastname@example.orgAnd then save the file and exit. Next we run the process and make sure it runs without error.
/sbin/mdadm --monitor --scan --daemonizeIf this works correctly, we will want to make sure that this command runs at boot time. Edit the following file:
nano /etc/rc.localAnd copy and paste the line near the end of the file:
/sbin/mdadm --monitor --scan --daemonizeWARNING: The last line in /etc/rc.local for Debian (and possibly Ubuntu installs) is “exit 0” so you need to make sure that the command above goes BEFORE that line otherwise it will never run. Finally, if you’d like to test that emails are being sent properly, you can run the following command:
/sbin/mdadm --monitor --scan --testThis will send you an email regarding the current status of your raid arrays. Be sure to whitelist these emails so that when a real raid alert comes in, your email provider doesn’t send it to your spam box!
That’s it! You’ve now set up your server to send you email alerts whenever a failure event occurs in MDADM / software raid. The above instructions should work equally well for Centos, Ubuntu, and Debian. This is an easy, but often overlooked, important first step in ensuring your data security. In a future article, we’ll be discussing how to set up raid alerts for LSI-9271 hardware raid (hint: it’s not as easy), so stay tuned if you use LSI hardware raid cards.