网上搜到的基本是zabbix4.0的配置,照搬就会出现一堆不支持的监控项,按照模组信息下载官方的 Template_DB_MySQL.conf也会有一堆报错,记录一下处理方法
默认zabbix路径为/etc/zabbix,mysql为/usr/local/mysql,请按照自己的情况修改
首先在/etc/zabbix下创建.my.cnf
[client]
user='zbx_monitor'
password='<password>'
然后在/etc/zabbix/zabbix_agent.d下创建template_db_mysql.conf
#template_db_mysql.conf created by Zabbix for "Template DB MySQL" and Zabbix 4.2
#For OS Linux: You need create .my.cnf in zabbix-agent home directory (/var/lib/zabbix by default)
#For OS Windows: You need add PATH to mysql and mysqladmin and create my.cnf in %WINDIR%\my.cnf,C:\my.cnf,BASEDIR\my.cnf https://dev.mysql.com/doc/refman/5.7/en/option-files.html
#The file must have three strings:
#[client]
#user=zabbix
#password=123456
#
UserParameter=mysql.ping[*], HOME=/etc/zabbix/ /usr/local/mysql/bin/mysqladmin -h"$1" -P"$2" ping
UserParameter