1. Modify Zabbix_agent.conf
[email protected] etc]# cat zabbix_agentd.conf
Logfile=/tmp/zabbix_agentd.log
#被动模式填服务器的IP
server=192.168.1.111
#主动模式, fill in the IP of the server
serveractive=192.168.1.111
#这里设置的name必须和web界面的一样
hostname=192.168.1.24
#打开以下两项
include=/usr/local/zabbix-agent/etc/zabbix_agentd.conf.d/
Unsafeuserparameters=1
2. Create a monitoring file in the/USR/LOCAL/ZABBIX-AGENT/ETC/ZABBIX_AGENTD.CONF.D directory mysql_status.conf
[email protected] zabbix_agentd.conf.d]# cat mysql_status.conf
#UserParameter =mysql.version,mysql-v
#UserParameter =mysql.ping,mysql-urepl-phipiao Ping | Grep-c Alive
Userparameter=mysql.status[*],/usr/local/zabbix-agent/scripts/checkmysqlperformance.sh $
3. Write a script to take the value of the monitoring item
cat/usr/local/zabbix-agent/scripts/checkmysqlperformance.sh
#!/bin/sh
mysql_sock= "/var/lib/mysql/mysql.sock"
Mysql_pwd= ' Cat/usr/local/zabbix-agent/scripts/mysqlpass.txt '
Args=1
Host= "192.168.1.24"
If [$#-ne "$ARGS"];then
echo "Please input onearguement:"
Fi
Case $ in
Mysql_replication)
result= ' Mysql-urepl-h${host}-p${mysql_pwd}-e ' show slave status\g ' | Grep-e "Slave_io_running| Slave_sql_running "|awk ' {print $} ' | Grep-c Yes '
Echo $result
;;
Mysql_delay)
result= ' Mysql-urepl-h${host}-p${mysql_pwd}-e ' show slave status\g ' | Grep-e "Seconds_behind_master" |awk ' {print $} '
Echo $result
Esac
4. Restart the service
/usr/local/zabbix-agent/sbin/zabbix_agentd/usr/local/zabbix-agent/etc/zabbix_agentd.conf
5. Set the monitoring item mysql_replication in the Web interface
This article is from the "jiazheming" blog, make sure to keep this source http://8888866666.blog.51cto.com/6988153/1765452
ZABBIXL monitoring MySQL