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主从状态监控脚本报警脚本的主要内容,如果未能解决你的问题,请参考以下文章

使用zabbix监控mysql主从状态

编写脚本实现MySQL主从复制状态监控

Mysql主从状态监控脚本

Shell脚本监控Mysql主从同步状态+钉钉提醒

zabbix监控Mysql主从状态

监控MySQL主从复制状态的脚本