监控myqsl主从

 # !/bin/sh

declare -a slave_is
slave_is=($(/usr/local/mysql/bin/mysql -uroot -pcwaimy -e "show slave status\G"|grep Running|awk '{print $2}'))
if [ "${slave_is[0]}" = "Yes" -a "${slave_is[1]}" = "Yes" ];then
echo "OK -slave is running"
exit 0
else
echo "Critical -slave is error" | mail -s "warn! 103-MySQL Slave is not running" [email protected]
exit 2
fi
 

你可能感兴趣的:(监控)