Hi, i know it is a recurent post about Mysql Template, but i didn't find any answer in other posts.
So i am sorry after so many tries and researches i finally come there to try to find a solution for my trouble:
The Mysql Server is distant (with zabbix agent) to zabbix server, and Zabbix server seems to try to connect with info server side instead of client side (zabbix agent) credentials
1 - Environement
Zabbix server version 4.4.6 (now updated to 5.2.4)
Zabbix agent version 3.2.11
Using agent on port 10050
Template name Template DB MySQL (original not modified)
Other templates are working well
Server side
Client side
2 - Configuration
3 - Checks
Web interface don't warn about no data collected for 30 min
When i try the commands agent side they seems to works:
4 - Errors
Zabbix agent side i have no errors
Zabbix server side i have errors like zabbix server can't connect to mysql using wrong credential
But i think it shoud not be zabbix but zabbix-agent from agent /var/lib/zabbix/.my.cnf
And it should not be server.host.name (Host {HOST.DNS} or {HOST.NAME} ) but {$MYSQL.HOST} instead from macro
If you have any idea about what i am doing wrong, thanks a lot in advance.
==> Finally SOLVED... the agent version must match a client version
So i am sorry after so many tries and researches i finally come there to try to find a solution for my trouble:
The Mysql Server is distant (with zabbix agent) to zabbix server, and Zabbix server seems to try to connect with info server side instead of client side (zabbix agent) credentials
1 - Environement
Zabbix server version 4.4.6 (now updated to 5.2.4)
Zabbix agent version 3.2.11
Using agent on port 10050
Template name Template DB MySQL (original not modified)
Other templates are working well
Server side
appliance@zabbix:~$ zabbix_server --version
zabbix_server (Zabbix) 5.2.4
Revision e9f58de09c 25 January 2021, compilation time: Jan 7 2021 13:16:25
Copyright (C) 2021 Zabbix SIA
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it according to
the license. There is NO WARRANTY, to the extent permitted by law.
This product includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit (http://www.openssl.org/).
Compiled with OpenSSL 1.1.1f 31 Mar 2020
Running with OpenSSL 1.1.1f 31 Mar 2020
zabbix_server (Zabbix) 5.2.4
Revision e9f58de09c 25 January 2021, compilation time: Jan 7 2021 13:16:25
Copyright (C) 2021 Zabbix SIA
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it according to
the license. There is NO WARRANTY, to the extent permitted by law.
This product includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit (http://www.openssl.org/).
Compiled with OpenSSL 1.1.1f 31 Mar 2020
Running with OpenSSL 1.1.1f 31 Mar 2020
Client side
└─ # zabbix_agentd --version
zabbix_agentd (daemon) (Zabbix) 3.2.11
Revision 76339 27 December 2017, compilation time: Dec 27 2017 15:13:43
Copyright (C) 2017 Zabbix SIA
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it according to
the license. There is NO WARRANTY, to the extent permitted by law.
zabbix_agentd (daemon) (Zabbix) 3.2.11
Revision 76339 27 December 2017, compilation time: Dec 27 2017 15:13:43
Copyright (C) 2017 Zabbix SIA
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it according to
the license. There is NO WARRANTY, to the extent permitted by law.
2 - Configuration
- zabbix-agent side: (agent has been restart after conf has been set)
Added user to Mysql server credentials
Credentials added to .my.cnf (path /var/lib/zabbix checked in cat /etc/passwd | grep zabbix)
With content
The file /etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf is present with content
Code:
[FONT=Calibri][FONT=Consolas]CREATE USER 'zabbixagent'@'%' IDENTIFIED BY 'mypass';[/FONT][/FONT] [FONT=Calibri][FONT=Consolas]GRANT REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW ON *.* TO 'zabbixagent'@'%';[/FONT][/FONT] [FONT=Calibri][FONT=Consolas]FLUSH PRIVILEGES;[/FONT][/FONT]
Code:
[FONT=Calibri][FONT=Consolas]mkdir /var/lib/zabbix[/FONT][/FONT] [FONT=Calibri][FONT=Consolas]nano /var/lib/zabbix/.my.cnf[/FONT][/FONT] [FONT=Calibri][FONT=Consolas]chown -R zabbix:zabbix /var/lib/zabbix/[/FONT][/FONT]
Code:
[FONT=Calibri][FONT=Consolas][client][/FONT][/FONT] [FONT=Calibri][FONT=Consolas]user='zabbixagent'[/FONT][/FONT] [FONT=Calibri][FONT=Consolas]password='mypass'[/FONT][/FONT] [FONT=Calibri][FONT=Consolas]socket=/var/lib/mysql/mysql.sock[/FONT][/FONT]
Code:
# For all the following commands HOME should be set to the directory that has .my.cnf file with password information.
# Flexible parameter to grab global variables. On the frontend side, use keys like mysql.status[Com_insert].
# Key syntax is mysql.status[variable].
UserParameter=mysql.status[*],echo "show global status where Variable_name='$1';" | HOME=/var/lib/zabbix mysql -N | awk '{print $$2}'
# Flexible parameter to determine database or table size. On the frontend side, use keys like mysql.size[zabbix,history,data].
# Key syntax is mysql.size[<database>,<table>,<type>].
# Database may be a database name or "all". Default is "all".
# Table may be a table name or "all". Default is "all".
# Type may be "data", "index", "free" or "both". Both is a sum of data and index. Default is "both".
# Database is mandatory if a table is specified. Type may be specified always.
# Returns value in bytes.
# 'sum' on data_length or index_length alone needed when we are getting this information for whole database instead of a single table
UserParameter=mysql.size[*],bash -c 'echo "select sum($(case "$3" in both|"") echo "data_length+index_length";; data|index) echo "$3_length";; free) echo "data_free";; esac)) from information_schem$
UserParameter=mysql.ping,HOME=/var/lib/zabbix mysqladmin ping | grep -c alive
UserParameter=mysql.version,mysql -V
UserParameter=mysql.get_status_variables[*], mysql -h"$1" -P"$2" -sNX -e "show global status"
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"
- zabbix web interface:
Host configuration
added the template Template DB MySQL
added the macro {$MYSQL.HOST} with value the IP of the Server with MySQL & zabbix-agent
added the template Template DB MySQL
added the macro {$MYSQL.HOST} with value the IP of the Server with MySQL & zabbix-agent
3 - Checks
Web interface don't warn about no data collected for 30 min
When i try the commands agent side they seems to works:
Code:
zabbix_agentd -t "mysql.ping" mysql.ping [t|1]
Code:
zabbix_agentd -t "mysql.status[Bytes_sent]" mysql.status[Bytes_sent] [t|212012265274]
Zabbix agent side i have no errors
Zabbix server side i have errors like zabbix server can't connect to mysql using wrong credential
Code:
parser error : Start tag expected, '<' not found ERROR 1045 (28000): Access denied for user 'zabbix'@'server.host.name' ( ^ noname.xml:1: parser error : Start tag expected, '<' not found ERROR 1045 (28000): Access denied for user 'zabbix'@'server.host.name' ( ^ noname.xml:1: noname.xml:1: parser parser error : error : Start tag expected, '<' not found Start tag expected, '<' not found ERROR 1045 (28000): Access denied for user 'zabbix'@'server.host.name' ( ERROR 1045 (28000): Access denied for user 'zabbix'@'server.host.name'
But i think it shoud not be zabbix but zabbix-agent from agent /var/lib/zabbix/.my.cnf
And it should not be server.host.name (Host {HOST.DNS} or {HOST.NAME} ) but {$MYSQL.HOST} instead from macro
If you have any idea about what i am doing wrong, thanks a lot in advance.
==> Finally SOLVED... the agent version must match a client version
Comment