mysql同步检测的sh脚本


#!/bin/bash 
# check mysql slave status
# crontab time 00:08
# path 80 /data0/sh/shell_mysql_slave.sh

# log path /data0/mysql/3306/check_mysql_slave.log

mysql_path=/usr/local/webserver/mysql/bin/mysql
user="admin" 
password="password" 
[email protected] 
date=`(date +%y-%m-%d--%H:%M:%S)` 
ip=$(/sbin/ifconfig | grep "inet addr" | grep -v "127.0.0.1" | awk '{print $2;}' | awk -F':' '{print $2;}' | head -1)  
Slave_IO_Running=$($mysql_path -u$user -p$password -e 'show slave status\G' | grep "Slave_IO_Running" | awk '{print $2}') 
Slave_SQL_Running=$($mysql_path -u$user -p$password -e 'show slave status\G' | grep "Slave_SQL_Running" | awk '{print $2}') 
if [ "$Slave_IO_Running" = "Yes" -a "$Slave_SQL_Running" = "Yes" ] 
then 
  echo "Slave is running!" 
else 
  echo "#######  $date  #########">> /data0/mysql/3306/check_mysql_slave.log 
  echo "Slave is not running!" >> /data0/mysql/3306/check_mysql_slave.log 
  /bin/mail -s {$ip}_replicate_error $email 
fi


你可能感兴趣的:(mysql,status,email,password,admin)