Configure userparameter_mysql.conf# Move to the zabbix decompression path
cd /usr/local/src/zabbix-3.0.3/conf/zabbix_agentd
# Copy the file to/opt/zabbix/etc/zabbix_agentd.conf.d/# specify your own zabbix installation directory
cp userparameter_mysql.conf /opt/zabbix/etc/zabbix_agentd.conf.d/
# Add the configuration file my. cnf used to associate mysql, and modify the mysql path in the template configuration file
cd /opt/zabbix/etc/
vim .my.cnf
# Zabbix Agent
[mysql]host=localhostuser=zabbixpassword=@Zabbix..0socket=/data/mysql/mysql.sock[mysqladmin]host=localhostuser=zabbixpassword=@Zabbix..0socket=/data/mysql/mysql.sock
# Use the find/-name mysql. sock file to find the path
# Modify userparameter_mysql.conf:
sudo sed -i ‘s@/var/lib/zabbix@/opt/zabbix/etc@g‘ /opt/zabbix/etc/zabbix_agentd.d/userparameter_mysql.conf
# Modify userparameter_mysql.conf as follows:
UserParameter=mysql.status[*],echo "show global status where Variable_name='$1';" | HOME=/opt/zabbix/etc mysql -N | awk '{print $$2}'UserParameter=mysql.size[*],bash -c 'echo "select sum($(case "$3" in both|"") echo "data_length+index_length";; data|index) echo "$3_length";; free) echo "data_free";; esac)) from information_schema.tables$([[ "$1" = "all" || ! "$1" ]] || echo " where table_schema=\"$1\"")$([[ "$2" = "all" || ! "$2" ]] || echo "and table_name=\"$2\"");" | HOME=/var/lib/zabbix mysql -N'UserParameter=mysql.ping,HOME=/opt/zabbix/etc mysqladmin ping | grep -c alive# The HOME directory is the directory where the. my. cnf file is added.
# Modify the zabbix_agentd.conf file and add the following line
Include=/opt/zabbix/etc/zabbix_agentd.conf.d/
# Restart zabbix-agentd
/etc/init.d/zabbix_agentd restart
# Test
# /opt/zabbix/bin/zabbix_get -s 127.0.0.1 -p 10050 -k mysql.ping1
# /opt/zabbix/bin/zabbix_get -s 127.0.0.1 -p 10050 -k mysql.version/data/mysql/bin/mysql Ver 14.14 Distrib 5.7.12, for Linux (x86_64) using EditLine wrapper
# Note: if the following error is reported during the test: sh: mysql: command not found, sh: mysqladmin: command not found, modify the path of mysql and mysqladmin commands in userparameter_mysql.conf and use the absolute path.
Zabbix-web page settings# Configuration-Hosts-Zabbix server-Tempaltes, search for MySQL, add the pop-up template, and then update
# Monitoring-Graphs: select a group, and then select host and the displayed image.
# Use the Zabbix built-in template to monitor MySQL.
Original address: http://www.linuxprobe.com/monitor-mysql-with-zabbix.html