Graduation of zabbix --- template comes with mysql content monitoring

Comes with templates is unable to establish a direct connection can be used

 

 

We must go through a few steps:

 

Establish user rights:

[[email protected] lib]$mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 105
Server version: 5.7.29-log Source distribution

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


mysql>  grant all on *.* to zabbix@'localhost' identified by 'zabbix2004';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)

 

We first copy the file to the installation directory first parameter

Source package copied to the installation directory

[[email protected] zabbix_agentd]$pwd
/data/packages/zabbix-4.4.5/conf/zabbix_agentd
[[email protected] zabbix_agentd]$cp userparameter_mysql.conf /usr/local/zabbix/etc/zabbix_agentd.conf.d/

 

Says:

#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=zbx_monitor
#password=<password>
#
UserParameter=mysql.ping[*], mysqladmin -h"$1" -P"$2" ping
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"
~                                                                                        

 

Modify the mysql configuration files:

[[email protected] zabbix_agentd]$vim /usr/local/mysql/etc/my.cnf 

#[client]
#port = 3306
#socket = /data/mysql/data/mysql.sock
#default-character-set = utf8

[client]
user='zabbix'                                                                                                                                                                                                    
password='zabbix2004'
default-character-set=utf8
socket=/data/mysql/data/mysql.sock

[mysqladmin]
default-character-set=utf8
socket=/data/mysql/data/mysql.sock
user='zabbix'
password='zabbix2004'

[mysql]
default-character-set=utf8
socket=/data/mysql/data/mysql.sock
user='zabbix'
password='zabbix2004'

 

Then restart mygslq

Restart zabbix_agentd

Then it

 

Guess you like

Origin www.cnblogs.com/betterquan/p/12449123.html