In Ubuntu, how to get email notifications about (software) RAID problems?

7,470

Solution 1

Add MAILADDR [email protected] to /etc/mdadm/mdadm.conf, then /etc/init.d/mdadm restart or it'll just start on next boot. There's also a munin plugin if you're running munin with email alerts.

Solution 2

I found a nice tip closely related to my question, and wanted to share it:

TomTheGeek: Pop up notification of software RAID problems in Ubuntu

It's not about email notifications, but as the blog post says, pop-up notifications (like in screenshot below) might be even better when we're talking about a workstation.

alt text

I'll summarise the main points here (in case that blog ever disappears). This uses notify-send, so you need to install notification-daemon package. Basically you add this in /etc/mdadm/mdadm.conf (along with MAILADDR):

# display local notification
PROGRAM /usr/sbin/mdadm-notify.sh

...and the mdadm-notify.sh script should be something like:

#!/bin/bash

#get dbus session
eval `dbus-launch --sh-syntax --exit-with-session`

#show alert
/usr/bin/notify-send -u critical -c device.error -i /usr/share/icons/Human/32x32/status/dialog-warning.png -t 0 "RAID Status" "<b>$2</b>: $1" -h int:x:1250 -h int:y:20
Share:
7,470

Related videos on Youtube

Assaf Levy
Author by

Assaf Levy

I'm a software developer by profession, and more active on Stack Overflow. I used to be more of a Linux geek, wasting a lot of free time tweaking my system, following Slashdot, etc. Fortunately I'm mostly past that. :) Nowadays I mainly use Mac at home, while still strongly preferring Linux (Ubuntu these days) for development at work and at work too.

Updated on September 17, 2022

Comments

  • Assaf Levy
    Assaf Levy almost 2 years

    I know getting email notifications should be possible, and perhaps even enabled by default... But how to make sure alerts are properly configured, and if, for any reason, they arent't, how to set them up?

    (I think it's not enabled on my machine, because earlier when I had some disk problems it turned out one of the disks had been long been off the RAID, and the one remaining in it got broken...)

    So, instead of periodically checking /proc/mdstat on my workstation to see that all RAID devices are nicely [UU]...

    $ cat /proc/mdstat
    Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] ...
    md1 : active raid1 sda3[0] sdb3[1]
          195310144 blocks [2/2] [UU]
    
    md0 : active raid1 sda1[0] sdb1[1]
          144448 blocks [2/2] [UU]
    

    ...how to set it up so that any irregularities are reported automatically by email? Specifically, I mean the situation that one disk "falls off" the RAID 1 array, for one reason or another, which shows up as something like [2/1] [U_] in /proc/mdstat. Also, instead of it sending email to local (root) user, can you configure an arbitrary email address?

    I'm using Ubuntu 8.04 (aka Hardy). Tell me if I should add more details about the workstation or RAID setup.

    • ChrisInEdmonton
      ChrisInEdmonton almost 15 years
      You may want to note that this is software RAID. Solutions for hardware RAID may be substantially different.
    • Assaf Levy
      Assaf Levy almost 15 years
      Good point; I tweaked the question title
  • Assaf Levy
    Assaf Levy almost 15 years
    Is that really necessary? I have the impression that the RAID tools themselves can do email notifications...
  • Assaf Levy
    Assaf Levy almost 15 years
    Thanks! Just curious - do you know of a quick and safe way to test if sending alert emails really works?
  • Assaf Levy
    Assaf Levy almost 15 years
    At least marking a device in an array as "faulty" (mdadm /dev/md0 -f /dev/sdb1) did not trigger any email. Hmm, does the machine need to have some SMTP server / MTA running for outgoing mail to work?
  • TRS-80
    TRS-80 almost 15 years
    Yes, you need a package that provides /usr/sbin/sendmail, ie any mail-transport-agent package like postfix, exim4 etc.
  • math
    math about 12 years
    I recommend SSMTP for sending mails. Very easy to configure as exim4 and postfix are full MTAs and very complex to configure.