您的位置:首页 > 数据库 > SQL

针对于lvs分发mysql的监控

2014-07-02 10:57 211 查看
#!/bin/bash

c=`cat /opt/duoyongtu/10/mysql.txt`
for i in $c
do
a=`mysql -uroot -h$i -p12345678 -P3306 -e "show slave status\G"|egrep '(Slave_IO_Running|Slave_SQL_Running)'|awk '{print $NF}'`
for k in $a
do
if [ "$k" != "Yes" ]; then
f=`ssh 192.168.0.146 "ip a|grep 192.168.1.5|wc -l"`
if [ "$f" -eq 1 ]; then
b=`ssh 192.168.0.146 "cat /opt/yanchao/xianzai.txt| wc -l"`
if [ "$b" -ge 2 ]; then
ssh $i "iptables -A INPUT -s 192.168.0.146 -p tcp -m tcp --dport 3306 -j DROP"
ssh $i "iptables -A INPUT -s 192.168.0.147 -p tcp -m tcp --dport 3306 -j DROP"
echo bad
else
echo good
fi
else
b=`ssh 192.168.0.147 "cat /opt/yanchao/xianzai.txt| wc -l"`
if [ "$b" -ge 2 ]; then
ssh $i "iptables -A INPUT -s 192.168.0.146 -p tcp -m tcp --dport 3306 -j DROP"
ssh $i "iptables -A INPUT -s 192.168.0.147 -p tcp -m tcp --dport 3306 -j DROP"
echo bad
else
echo good
fi
fi
else
d=`ssh $i "iptables -L -n|grep 192.168.0.146|wc -l"`
if [ "$d" -ge 1 ]; then
for e in 192.168.0.146 192.168.0.147
do
ssh $i "iptables -F"
done
fi
fi
done
done
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mysql 监控 status