I have a server with a zabbix agent installed, this is working fine.
I want to monitor a database on the server, I have followed the documentation of MySQL by Zabbix agent
.
I have an error inside the log
mysqladmin: connect to server at '127.0.0.1' failed
error: 'Access denied for user 'zabbix'@'localhost' (using password: NO)'
Here is a longer part of the logs:
15110:20220919:154820.657 In zbx_waitpid()
15110:20220919:154820.657 zbx_waitpid() exited, status:0
15110:20220919:154820.658 End of zbx_waitpid():15142
15110:20220919:154820.658 Run remote command [ mysqladmin -h"127.0.0.1" -P"3306" ping] Result [0] []...
15110:20220919:154820.658 Sending back []
15110:20220919:154820.658 listener #2 [waiting for connection]
15110:20220919:154820.719 listener #2 [processing request]
15110:20220919:154820.719 Requested [system.cpu.util[,iowait]]
15110:20220919:154820.719 Sending back [0.071416]
15110:20220919:154820.719 listener #2 [waiting for connection]
15111:20220919:154821.077 listener #3 [processing request]
15111:20220919:154821.077 Requested [mysql.ping["127.0.0.1","3306"]]
15111:20220919:154821.077 In zbx_popen() command:' mysqladmin -h"127.0.0.1" -P"3306" ping'
15111:20220919:154821.078 End of zbx_popen():8
15143:20220919:154821.078 zbx_popen(): executing script
mysqladmin: connect to server at '127.0.0.1' failed
error: 'Access denied for user 'zabbix'@'localhost' (using password: NO)'
15111:20220919:154821.089 In zbx_waitpid()
15111:20220919:154821.089 zbx_waitpid() exited, status:0
15111:20220919:154821.089 End of zbx_waitpid():15143
15111:20220919:154821.089 Run remote command [ mysqladmin -h"127.0.0.1" -P"3306" ping] Result [0] []...
15111:20220919:154821.089 Sending back []
15111:20220919:154821.090 listener #3 [waiting for connection]
15112:20220919:154821.114 In send_buffer() host:'<ip>' port:10051 values:0/100
15112:20220919:154821.114 End of send_buffer():SUCCEED
15112:20220919:154821.114 active checks #1 [idle 1 sec]
15108:20220919:154821.116 collector [processing data]
15108:20220919:154821.116 In update_cpustats()
15108:20220919:154821.116 End of update_cpustats()
15108:20220919:154821.116 collector [idle 1 sec]
15109:20220919:154821.543 listener #1 [processing request]
But my .my.cnf
that is in /var/run/zabbix/
look like that:
[client]
user='zbx_monitor'
password='<password>'
The home directory of the zabbix
user is /var/run/zabbix/
so it should work.
I have done it on other servers and it worked fine. But on this one the .my.cnf
is not working and I can't find why.
The only things different between the server:
- Home directory
- Server date, so not the same linux version
Do you have any idea what could cause this problem ?
Edit:
namei -l /var/run/zabbix/.my.cnf
f: /var/run/zabbix/.my.cnf
drwxr-xr-x root root /
drwxr-xr-x root root var
lrwxrwxrwx root root run -> /run
drwxr-xr-x root root /
drwxr-xr-x root root run
drwxr-xr-x zabbix zabbix zabbix
-rw-r----- zabbix zabbix .my.cnf
If I try to run the command with the user zabbix
it works:
sudo -u zabbix mysqladmin -h"127.0.0.1" -P"3306" ping
mysqld is alive
So the error is happening only when it's the zabbix agent that run the command.
Here is the home directory of my zabbix user
getent passwd zabbix
zabbix:x:109:115::/var/run/zabbix/:/bin/false