Check Mysql Status

#!/bin/bash   

#  Check MySQL Slave Runnning Status 
#  crontab :*/10 * * * * 
#  show slave status


IP=`ifconfig eth0|grep "inet addr" | awk -F[:" "]+ '{print $4}'`  
STATUS=$(/usr/bin/mysql -uroot -p11111 -e "show slave status\G" | grep -i "running")  
IO_env=`echo $STATUS | grep IO | awk  ' {print $2}'`  
SQL_env=`echo $STATUS | grep SQL | awk  '{print $2}'`  

logFile=/data/mysqlbackup/logs/CheckMysqlStatus.log
DATE=`date +"%Y%m%d_%H:%M:%S"` 
  
if [ "$IO_env" = "Yes" -a "$SQL_env" = "Yes" ]  
then  
  echo "MySQL Slave is running!"  
else  
  echo "####### $DATE #########">> $logFile
  echo "MySQL Slave is not running!" >>    $logFile
  echo "MySQL Slave is not running!" | mail -s "WARN! $IP MySQL Slave is not running." admin@yourdomain.com  
fi  

上一篇:《Android和PHP开发最佳实践》一2.2 Android系统框架


下一篇:使用Cacti监控Esxi