mysql主从监控
#脚本如下,截取主从关键字
cat check_mysql_slave.sh #!/bin/bash # declare -a 定义数组,slave_is 会被视为数组 declare -a slave_is slave_is=($(/data/mysql/bin/mysql -e "show slave status\G"|grep -E "Slave_IO_Running|Slave_SQL_Running:"|awk ‘{print $2}‘)) if [ "${slave_is[0]}" = "Yes" -a "${slave_is[1]}" = "Yes" ];then echo "ok -slave is running" exit 0 else echo "down -slave is not running" exit 2 fi
#zabbix_agentd.conf文件的配置如下:
cat zabbix_agentd.conf | grep -v "^#" | grep -v "^$" LogFile=/tmp/zabbix_agentd.log EnableRemoteCommands=1 Server=10.74.246.70 ListenPort=10050 ServerActive=10.74.246.70 Hostname=10.74.244.33 AllowRoot=1 Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/*.conf UnsafeUserParameters=1 UserParameter=tomcat_port,/usr/local/zabbix/share/zabbix/alertscripts/tomcat_port.sh $1 UserParameter=tcp[*],/usr/local/zabbix/share/zabbix/alertscripts/tcp_connection.sh $1 UserParameter=nginx_port,/usr/local/zabbix/share/zabbix/alertscripts/nginx_port.sh $1 UserParameter=erro_log[*],/usr/local/zabbix/share/zabbix/alertscripts/error_log.sh $1 #mysql主从监控脚本,grep -c "ok",ok出现的次数 UserParameter=mysql.slave,/usr/local/zabbix/share/zabbix/alertscripts/check_mysql_slave.sh | grep -c ‘ok‘
#创建自定义模板:
#创建应用集:
#创建监控项:
#创建触发器:
#添加mysql-slave监控图形:
#查看图形监控效果:
本文出自 “LINUX Super梦” 博客,请务必保留此出处http://215687833.blog.51cto.com/6724358/1899478
原文地址:http://215687833.blog.51cto.com/6724358/1899478