脚本
cat /server/scripts/mysql.sh
#!/bin/bash
docker exec -t docke_mysql mysql -uroot -p123456 -e "show slave status\G"|grep "Running"|grep "Yes"|wc -l
为什么不用docker exec -i ?
这样会显示下面的结果
Warning: Using a password on the command line interface can be insecure.
2
zabbix会报错
Received value [Enter password: ERROR 1045 (28000): Access denied for user [email protected] (using password: NO)0] is not suitable for value type [Numeric (unsigned)] and data type [Decimal]
使用docker exec -t(分配一个伪终端,不需要保持STDIN打开,结果就正常了,我也是试了好久,改/etc/my.cnf,本人认为不安全,有其它见解的话,请高人指点下我的想法是否正确)
现在获取到数值了可以去设置你自己的zabbix了
【监控容器mysql,监控docker容器内mysql主从同步状态】原文:http://blog.51cto.com/11571922/2147147