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!

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState