我到目前为止所执行的步骤:-
在我的数据库机[mysql]中安装了Zabbix代理。
使用Zabbix代理将template_db_mysql.conf复制到文件夹中 配置(/etc/zabbix/zabbix_agentd.d /)
创建的mysql用户
创建用户'zbx_monitor'@'%'标识为“”;授权使用,复制客户端,过程,显示数据库,上的显示视图。到'zbx_monitor'@'%';
在/ var / lib / zabbix文件夹中使用用户详细信息创建.my.cnf
我的template_db_mysql.conf文件是:-
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 COALESCE(SUM(DATA_LENGTH + INDEX_LENGTH),0) 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"```
cat /var/lib/zabbix/.my.cnf
[client]
user='zbx_monitor'
password='<password>'
post restarting the zabbix-agent getting below errors
Preprocessing failed for: sh: mysql: command not found
1. Failed: cannot extract XML value with xpath "/resultset/row[field/text()='Connection_errors_internal']/field[@name='Value']/text()": cannot parse xml value: Start tag expected, '<' not found
Value "sh: mysql: command not found" of type "string" is not suitable for value type "Numeric (unsigned)"
[enter image description here][1]
[1]: https://i.stack.imgur.com/Jxwux.png