"MySQL"-Configure Zabbix monitoring @20210228

This note records how to use Zabbix to monitor the MySQL database . Although Zabbix has built-in MySQL monitoring templates out of the box, the "out of the box" itself is somewhat difficult.

We did not record how Zabbix added and used templates, and most of the content was the preparations needed to use MySQL monitoring templates.

CentOS Linux release 7.5.1804 (Core) with Zabbix 4.0.1

Steps

1) Add the Teamplate DB MySQL monitoring template for the host;
2) Create the /var/lib/zabbix/.my.cnf configuration file in the monitored host to connect to the database to obtain information:

[client]
user='username'
password='password'

Precautions

1) Refer to the /etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf file;
2) For the MySQL users used for monitoring, the document does not explain, you need to analyze the userparameter_mysql.conf file by yourself. We use the root account directly, but this is not recommended. In Zabbix 4.0, stability has a detailed description, but there are other problems.

CentOS release 6.5 (Final) with Zabbix 4.4.3

Refer to the official Zabbix Documentation 4.4/Requirements for MySQL by Zabbix agent template document.

Summary of common problems

#1 sh: mysql: command not found

When executing the zabbix_get -s 127.0.0.1 -k'mysql.get_status_variables["localhost","3306"] 'command, it prompts:

sh: mysql: command not found

This is because the default environment variable of zabbix agent is PATH=/sbin:/usr/sbin:/bin:/usr/bin , and the mysql command is not in the path.

Create /etc/sysconfig/zabbix-agent file, append PATH=$PATH:/path/to/mysql/bin

#2 ERROR 1045 (28000): Access denied for user 'zabbix'@'x.x.x.x' (using password: NO)

Preprocessing failed for: ERROR 1045 (28000): Access denied for user 'zabbix'@'10.10.50.188' (using password: NO)
1. Failed: cannot extract XML value with xpath "/resultset/row[field/text()='Aborted_clients']/field[@name='Value']/text()": cannot parse xml value: Start tag expected, '<' not found

The database check uses passive mode. Zabbix Server cannot connect to Zabbix Agent due to the wrong configuration of the Zabbix Agent address, and instead connects to the local Zabbix Agent service (this error is usually not encountered).

Guess you like

Origin blog.csdn.net/u013670453/article/details/114229968