#!/bin/bash
DBuser=root
DBpasswd=123456
Mail="wang@163.com"
Result=/tmp/mysql.txt
State=`netstat -lnpt | grep 3306`
if [ -z "$State" ]
then
# mail -s "Can't connect to Mysql database" $Mail < /dev/null
echo "Can't connect to Mysql database"
else
mysql -u$DBuser -p$DBpasswd -e "show slave status\G" > $Result 2> /dev/null
Slave_IO_Running=`grep -i slave_io_running $Result | cut -d : -f 2`
Slave_SQL_Running=`grep -i slave_sql_running $Result | cut -d : -f 2`
if [ "$Slave_IO_Running" != ' Yes' -o "$Slave_SQL_Running" != ' Yes' ]
then
# mail -s "Mysql replication has stopped" $Mail < $Result
echo "Mysql replication has stopped"
fi
fi
Mysql 主从状态监控
最新推荐文章于 2024-07-15 11:48:23 发布