I use the MD (multiple device) logical volume manager to mirror the boot devices on the Linux servers I support. When I first started using MD, the mdadm utility was not available to manage and monitor MD devices. Since disk failures are relatively common in large shops, I used the shell script from my SysAdmin article Monitoring and Managing Linux Software RAID to send E-mail when a device entered the failed state. While reading through the mdadm(8) manual page, I came across the “–monitor” and “–mail” options. These options can be used to monitor the operational state of the MD devices in a server, and generate E-mail notifications if a problem is detected. E-mail notification support can be enabled by running mdadm with the “–monitor” option to monitor devices, the “–daemonise” option to create a daemon process, and the “–mail” option to generate E-mail:
$ /sbin/mdadm --monitor --scan --daemonise --mail=root@localhost
Once mdadm is daemonized, an E-mail similar to the following will be sent each time a failure is detected:
From: mdadm monitoring
To: root@localhost.localdomain
Subject: Fail event on /dev/md1:biscuit
This is an automatically generated mail message from mdadm
running on biscuit
A Fail event had been detected on md device /dev/md1.
Faithfully yours, etc.
I digs me some mdadm!