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:

#!/bin/bash
#
# 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
fi

LEVEL=critical
ICON=gtk-stop
TIMEOUT=0
SUBJECT="Warning!"

for arg in "$@"
do
MESSAGE="$MESSAGE ${arg}"
done

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

Save it to ~/bin/desktop-notify.sh. To install it, follow this steps as root user:

$ chmod +x /home/user/bin/desktop-notify.sh
$ echo "PROGRAM /home/user/bin/desktop-notify.sh" >> /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

http://minglanillosesferoides.blogspot.com/2010/09/notificar-estado-raid...

Excellent article! Delivering

melanie14's picture

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

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix