# Created by Bruce 2011-05-11
# To determine whether slave is running or not
#!/bin/sh
STATUS_LOGS="/var/lib/mysql/mysql_status.log"
USERNAME=dev
PASSWD=chuan5616
ADMIN="bruce.zuo@csoftintl.com"
DATA=`date '+%Y%m%d %X'` #`date '+%Y%m%d%k%M'`
IP=("192.168.215.80" "192.168.215.28")
#lenIP=${#IP}
lenIP=${#IP[@]}
cd /usr/bin/
i=0
while [ $i -lt $lenIP ]
do
HOSTNAME=${IP[$i]}
./mysql -u$USERNAME -p$PASSWD -h$HOSTNAME -e "show slave status \G" >/tmp/Slave_Status
RESULT=`cat /tmp/Slave_Status|grep Running |grep Yes|wc -l`
if [ "$RESULT" == 2 ]
then
echo -e "$HOSTNAME $DATA Slave is running!" >> $STATUS_LOGS
else
echo -e "$HOSTNAME $DATA Slave is not running!">> $STATUS_LOGS
echo "================================Error Describe Start======================================" >> $STATUS_LOGS
cat /tmp/Slave_Status >> $STATUS_LOGS
echo "================================Error Describe End========================================" >> $STATUS_LOGS
/bin/mail -s "SLAVE STATUS REPORT FROM DB:192.168.215.80" $ADMIN < $STATUS_LOGS >>$STATUS_LOGS
fi
sleep 1
let i++
done
阅读(483) | 评论(1) | 转发(0) |