Automatic Notification of Degraded RAID Array in Ubuntu

6

3

I'm running Ubuntu 10.04 on top of a RAID-1 array. Out of curiosity, I decided to bring up the "Disk Utility" program to inspect the status of my array. To my surprise, the array was listed as "Degraded", with one of the drives being faulty. Had my other drive failed, I would have lost all my data. Is there a way to setup Ubuntu to automatically notify me via email or some other means when RAID is degraded?

It seems strange to have such great software RAID support in Ubuntu, and then throw it all away by not communicating RAID failures to the user. I was thinking of writing a cron job to monitor "cat /proc/mdstat" and send me an email if the "failed drive" pattern was seen, but I don't want to reinvent the wheel.

Cerin

Posted 2010-08-14T00:53:57.363

Reputation: 6 081

Answers

3

By default, /etc/mdadm/mdadm.conf contains the line

MAILADDR root

I can confirm that on Ubuntu 8.04, this does result in mail being sent to root when the array is degraded (and I don't see why this would work differently in other releases).

The problem is that the mail is sent to root, and Ubuntu doesn't seem to have set up anything so that administrator users would read root's mail. It used to; I see that on a machine whose initial installation was Ubuntu 4.10, /etc/aliases contains

# Added by Ubuntu installer
root:   myusername

which does result in root's mail being redirected to my local mailbox, which I do read.

Maybe Ubuntu stopped setting up /etc/aliases because most people aren't even aware that there is such a thing as local mailboxes. But it would be a good idea for Ubuntu to arrange that administrators receive root's mail somehow. Maybe you could make a feature request (or add your voice to an existing one, I haven't looked). (Strictly speaking, it's a regression from warty!)

Gilles 'SO- stop being evil'

Posted 2010-08-14T00:53:57.363

Reputation: 58 319

I've asked how to read root's mail on a modern Ubuntu at the dedicated SE site. – Gilles 'SO- stop being evil' – 2010-08-14T11:44:19.767

Yeah, I never read my local mailbox. I ended up creating a simple script to send email to my normal mailbox, and setup a cron job to run mdadm regularly, using the --program param to execute my email script to notify me. – Cerin – 2010-08-14T13:20:43.083

I have a degraded array but "no mail for root" – Bryce – 2012-10-30T23:16:43.567

@Bryce That's probably because you aren't getting mail for root at all. See the question I linked to on the Ubuntu site (which sadly doesn't have up-to-date answers). – Gilles 'SO- stop being evil' – 2012-10-30T23:19:53.993

You have to install and configure an MTA to send mail to root off the system. The package postfix is a good choice for this. – milli – 2014-02-15T08:57:37.610