mysql主从状态监控脚本报警脚本
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql主从状态监控脚本报警脚本相关的知识,希望对你有一定的参考价值。
#!/bin/bash
mysqlPORT=`netstat -antlp |grep "LISTEN" ` |grep "3306" |awk -F[:""]+ ‘{print $4}‘
MYSQLIP = `ifconfig eth0` |grep "inet addr" |awk -F[:""]+ ‘{print $4}‘
STATUS = $(/usr/local/mysql/bin/mysql -uroot -ppassword -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}‘`
if [ "$ MYSQLPORT == "3306"" ]
then
echo "mysql is runing"
else
mail -s "warn! server: $MYSQLIP mysql is down" [email protected]
fi
if ["$IO_env" ="yes" -a "$SQL_env" = "yes"]
then
echo "Slave is running!"
else
echo "##### $date####" >>/tmp/check_mysql_slave.log
echo"SLAVE is not runing !" >>/data/data/chek_mysql_slave.log
mail -s "warn!" $MYSQLIP_replicate_error" [email protected] <</tmp/check_mysql_slave.log
fi
crontal -l
*/15 * * * * /bin/sh /root/mysql.sh
本文出自 “11324462” 博客,请务必保留此出处http://11334462.blog.51cto.com/11324462/1752361
以上是关于mysql主从状态监控脚本报警脚本的主要内容,如果未能解决你的问题,请参考以下文章