mysql主從監控mysql
#腳本以下,截取主從關鍵字nginx
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文件的配置以下:sql
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'
#建立自定義模板:數組
#建立應用集:tomcat
#建立監控項:bash
#建立觸發器:tcp
#添加mysql-slave監控圖形:ide
#查看圖形監控效果:
spa
模板文件下載:3d