监控MYSQL主从复制时,SLAVE状态的简单脚本
时间:2010-08-05 来源:liyongfeng410799624
#!/bin/bash
user=***
password=*** echo -e "please inpute slave portarl ip:"
read host
cd `dirname $0`
mysql -u$user -p$password -h$host -e "show slave status\G;" | grep -i running >slave.log
#grep -i, --ignore-case
# 忽略大小写,包含要搜寻的样式及被搜寻的档案。 if [ `cat slave.log | grep -i io | awk '{print $2}'` = Yes ]
then
echo "slave IO process is OK"
else
echo "slave IO process is error"
fi if [ `cat slave.log | grep -i sql | awk '{print $2}'` = Yes ]
then
echo "slave SQL process is OK"
else
echo "slave SQL process is error"
fi rm -rf slave_status
user=***
password=*** echo -e "please inpute slave portarl ip:"
read host
cd `dirname $0`
mysql -u$user -p$password -h$host -e "show slave status\G;" | grep -i running >slave.log
#grep -i, --ignore-case
# 忽略大小写,包含要搜寻的样式及被搜寻的档案。 if [ `cat slave.log | grep -i io | awk '{print $2}'` = Yes ]
then
echo "slave IO process is OK"
else
echo "slave IO process is error"
fi if [ `cat slave.log | grep -i sql | awk '{print $2}'` = Yes ]
then
echo "slave SQL process is OK"
else
echo "slave SQL process is error"
fi rm -rf slave_status
相关阅读 更多 +