自动监控主从MySQL同步的SHELL脚本
时间:2021-07-01 10:21:17
帮助过:23人阅读
time 00:
10
MYSQLPORT=`netstat -na|
grep "LISTEN"|
grep "3306"|
awk -F[:
" "]+
‘{print $4}‘`
MYSQLIP=`
ifconfig eth0|
grep "inet addr" |
awk -F[:
" "]+
‘{print $4}‘`
STATUS=$(/usr/local/mysql/bin/mysql -u root -p000000 -S /tmp/mysql.sock -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}‘`
DATA=`
date +
"%y-%m-%d %H:%M:%S"`
if [
"$MYSQLPORT" ==
"3306" ]
then
echo "mysql is running"
else
/usr/local/bin/sendEmail -f ieee8023@
163.com -t
1290517248@qq.com -s smtp.
163.com -u
"mysql is not running " -o message-content-type=html -o message-charset=utf8 -xu ieee8023@
163.com -xp Syhy2yH -m
"warn!server: $MYSQLIP mysql is down"
fi
if [
"$IO_env" =
"Yes" -a
"$SQL_env" =
"Yes" ]
then
echo "Slave is running!"
else
echo "####### $DATA #########">> /data/data/
check_mysql_slave.log
echo "Slave is not running!" >> /data/data/
check_mysql_slave.log
echo "Slave is not running!" | /usr/local/bin/sendEmail -f ieee8023@
163.com -t
1290517248@qq.com -s smtp.
163.com -u
"slave is not running!" -o message-content-type=html -o message-charset=utf8 -xu ieee8023@
163.com -xp Syhy2yH -m
"warn!server: $MYSQLIP mysql is down"
fi
自动监控主从MySQL同步的SHELL脚本
标签: