mysql主从监控
#脚本如下,截取主从关键字
1
2
3
4
5
6
7
8
9
10
11
12
|
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文件的配置如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
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监控图形:
#查看图形监控效果:
模板文件下载:
附件:http://down.51cto.com/data/2366444
本文转自青衫解衣 51CTO博客,原文链接:http://blog.51cto.com/215687833/1899478