Hello. You can put the following script into your crontab at the frequency you feel comfortable with. Be sure to set the MAILTO variable to the appropriate value before setting this up. -Brian
#!/bin/sh #$Id: raid-chk,v 1.5 2001/11/16 20:03:59 buhrow Exp $ #NAME: brian Buhrow #DATE: January 31, 2001 # #This shell script checks the health of the indicated raid device #and sends mail if anything looks amiss. #It requires /etc/$1.conf or it will complain and send mail. # #Usage: raid-chk <raid device> #raid-chk raid0 PATH=/bin:/usr/bin:/sbin:/usr/sbin; export PATH MAILTO="[email protected]" HOST=`hostname` if [ $# -lt 1 ]; then echo "Usage: $0 <raid number>" echo "For example: $0 raid0" exit 1 fi if [ ! -s /etc/$1.conf ]; then logger -i -p daemon.crit "/etc/$1.conf doesn't exist -- Unable to check raid status" echo "/etc/$1.conf doesn't exist -- Unable to check raid status"|\ mail -s "ERROR WITH $1 on $HOST" $MAILTO exit 5 fi touch /var/tmp/$myname.$$ date "+Date: %h %e, %Y" > /var/tmp/$myname.$$ raidctl -p /dev/r"$1"d >> /var/tmp/$myname.$$ if [ $? -ne 0 ]; then cat /var/tmp/$myname.$$ |mail -s "ERROR WITH $1 ON $HOST" $MAILTO logger -i -p daemon.crit `cat /var/tmp/$myname.$$` rm -f /var/tmp/$myname.$$ exit 5 fi rm -f /var/tmp/$myname.$$ date "+Date: %h %e, %Y" > /var/tmp/$myname.$$ raidctl -s /dev/r"$1"d |grep -i 'fail' >> /var/tmp/$myname.$$ if [ $? -eq 0 ]; then logger -i -p daemon.crit `cat /var/tmp/$myname.$$` cat /var/tmp/$myname.$$ |mail -s "ERROR WITH $1 ON $HOST" $MAILTO rm -f /var/tmp/$myname.$$ exit 5 fi #OK, we're good, exit quietly. rm -f /var/tmp/$myname.$$ exit 0
