针对于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
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
相关文章推荐
- 针对于lvs分发mysql的监控
- 小型架构数据走向图“”迷你CND加速,keepalived+lvs,Nginx分发,web负载,mysql读写分离,ABB“”
- 对于MySQL,你该知道的这里都有了
- 对于MYSQL数据操作语句的总结
- [转贴]对于Mysql你该知道的,这本书都有了
- Nagios:监控Mysql服务器
- Mysql查询时,对于数值型字段加单引号会引起的误解~
- 监控mysql服务器状态
- 监控修改版(带listboxview分发功能)
- Nagios实战全解(四):监控Mysql服务器
- nagios3.20安装配置笔记(带飞信短信报警,mssql和mysql监控)
- 用mysqladmin -i10 processlist extended-status监控MySQL的状态。
- mysql:使用源码分发版还是二进制分发版
- 在ORALCE中对于 like 'str%' like '%str' 都可以用到索引 但MySQL不是这样
- cacti+apache+php+mysql+rrdtool搭建流量监控平台
- 写了一个简单的shell脚本监控mysql服务器运行状态
- MySQL复制 自动监控脚本
- mysql 对于表结构的修改
- LR9.0监控mysql性能指标
- nagios监控mysql主从复制