Chinaunix首页 | 论坛 | 博客
  • 博客访问: 490137
  • 博文数量: 99
  • 博客积分: 3621
  • 博客等级: 中校
  • 技术积分: 1089
  • 用 户 组: 普通用户
  • 注册时间: 2010-06-22 16:29
文章存档

2012年(21)

2011年(28)

2010年(50)

分类: Mysql/postgreSQL

2011-05-11 15:07:42

# 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) |
给主人留下些什么吧!~~

9094133352011-06-30 14:31:04

邮件发出去后,应该把临时文件删除掉

rm -f /tmp/Slave_Status
rm -f $STATUS_LOGS