Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: raidctl -s being privileged considered unnneesssary
hello. I wrote the following script to run periodically on all the
systems on which I run raidframe to provide notification of errors vie
e-mail. It seems like it could be modified to update a file which Nagios
could read to provide the needed status. Yes, it's another moving part,
but means we don't need to maintain two interfaces for the raidframe
driver.
-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="<e-mail address here>"
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 sstatus"|\
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
Home |
Main Index |
Thread Index |
Old Index