#创建一个mysql用户 GRANT ALL ON . TO'zbx_monitor'@'%' IDENTIFIED BY 'zbx_monitor'; FLUSH PRIVILEGES; #在zabbix_agentd服务目录下创建my.cnf 目前我使用的是windows系统,zabbix_agentd安装在C盘,故而在C盘顶层创建,内容为: [client] user=zbx_monitor password=zbx_monitor
#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 (/etc/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=zbx_monitor #password=<password> UserParameter=mysql.ping[*], mysqladmi UserParameter=mysql.get_status_variables[*], mysql -h"$1" -P"$2" -sNX -e "show global status" UserParameter=mysql.version[*], mysqladmin -s -h"$1" -P"$2" version UserParameter=mysql.db.discovery[*], mysql -h"$1" -P"$2" -sN -e "show databases" UserParameter=mysql.dbsize[*], mysql -h"$1" -P"$2" -sN -e "SELECT SUM(DATA_LENGTH + INDEX_LENGTH) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='$3'" UserParameter=mysql.replication.discovery[*], mysql -h"$1" -P"$2" -sNX -e "show slave status" UserParameter=mysql.slave_status[*], mysql -h"$1" -P"$2" -sNX -e "show slave status"