Desktop notification of RAID status failure

Despite there are some attempts (raid-notify, raidmonitor) to provide a GUI-enabled mechanism that warns users about software-RAID failures, I think there is an alternative for some of us that want a simpler solution, just because it's simple or because our distribution of choice doesn't offer an apropriate package.

Once properly installed, the following script will show a pop-up message in the event of RAID status changes:

# PREREQUISITE: aptitude install libnotify-bin

# is somebody running an X server?
USER=($(/usr/bin/w | awk '($3==":0"){print $1" "$3}'))

export XAUTHORITY=/home/$USER/.Xauthority
export DISPLAY=${USER[1]}

if [ ! -f $XAUTHORITY ] ; then
exit 1


for arg in "$@"

sudo -u $USER /usr/bin/notify-send -u $LEVEL -i $ICON -t $TIMEOUT "$SUBJECT" "$MESSAGE"

Save it to ~/bin/ To install it, follow this steps as root user:

$ chmod +x /home/user/bin/
$ echo "PROGRAM /home/user/bin/" >> /etc/mdadm/mdadm.conf
$ /etc/init.d/mdadm reload

To test if it works correctly:

$ mdadm --monitor /dev/md2 -t

That's all. My original article (in Spanish) is located at

Excellent article! Delivering

melanie14's picture

Excellent article! Delivering maximum value is something you are an expert at. Thanks!

Free Dummies Books
Continuous Engineering


  • What continuous engineering is
  • How to continuously improve complex product designs
  • How to anticipate and respond to markets and clients
  • How to get the most out of your engineering resources

Get your free book now

Sponsored by IBM

Free Dummies Books
Service Virtualization

Learn to:

  • Define service virtualization
  • Select the most beneficial services to virtualize
  • Improve your traditional approach to testing
  • Deliver higher-quality software faster

Get your free book now

Sponsored by IBM