#!/bin/sh NAME="cciss-vol-statusd" STATUSFILE=/var/run/$NAME.status # Do not touch you can configure this in /etc/default/cciss-vol-statusd MAILTO=root # Where to report problems PERIOD=600 # Seconds between each check (default 10 minutes) REMIND=7200 # Seconds between each reminder (default 2 hours) ID=/dev/cciss/c0d0 [ -e /etc/default/cciss-vol-statusd ] && . /etc/default/cciss-vol-statusd # Gracefully exit if the package has been removed. test -x /usr/bin/cciss_vol_status || exit 0 while true ; do # Check ever $PERIOD seconds, send email on every status # change and repeat ever $REMIND seconds if the raid is still # bad. if (cciss_vol_status $ID); then BADRAID=false else BADRAID=true logger -t cciss-vol-statusd "detected non-optimal RAID status" fi STATUSCHANGE=false if [ true = "$BADRAID" ] ; then # RAID not OK (cciss_vol_status $ID) > $STATUSFILE.new if [ ! -f $STATUSFILE ] ; then # RAID just became broken STATUSCHANGE=true mv $STATUSFILE.new $STATUSFILE elif cmp -s $STATUSFILE $STATUSFILE.new ; then # No change. Should we send reminder? LASTTIME="`stat -c '%Z' $STATUSFILE`" NOW="`date +%s`" SINCELAST="`expr $NOW - $LASTTIME`" if [ $REMIND -le "$SINCELAST" ]; then # Time to send reminder STATUSCHANGE=true mv $STATUSFILE.new $STATUSFILE else rm $STATUSFILE.new fi else STATUSCHANGE=true mv $STATUSFILE.new $STATUSFILE fi else # RAID OK if [ -f $STATUSFILE ] ; then rm $STATUSFILE STATUSCHANGE=true fi fi if [ true = "$STATUSCHANGE" ]; then hostname="`uname -n`" ( cat <