Search code examples
postgresqlmonitoringzabbix

Why is the Zabbix Agent attempting to connect to PostgreSQL using the 'zabbix' user on certain 'zabbix' DB?


I'm monitoring my PostgreSQL cluster with Zabbix, and I have a specific username and password for this purpose, which is working perfectly. However, I'm encountering an issue where there is a connection attempt every minute from the Zabbix agent, trying to connect to the database using a 'zabbix' user in the 'zabbix' database. What could be causing this issue, and how can I resolve it?

Postgres 9.3 zabbix_agent 6

Message on Postgres log

user=zabbix,db=zabbix,app=[unknown],host=127.0.0.1 LOG: connection authorized: user=zabbix database=zabbix user=zabbix,db=zabbix,app=[unknown],host=127.0.0.1 FATAL: role "zabbix" does not exist


Solution

  • The issue is related to the use of 'pg_isready' by Zabbix-agent. Zabbix monitors PostgreSQL using a UserParameter configuration, and when using pg_isready with the Zabbix Linux user, it doesn't specify the user and database, so it defaults to the logged-in user and database names for the connection attempt. This is why you see the zabbix user and the zabbix database in the connection attempts in your PostgreSQL logs. To rectify this, you can modify the file /etc/zabbix/zabbix_agentd.d/template_db_postgresql.conf line as follows :

    UserParameter=pgsql.ping[*], pg_isready -h "$1" -p "$2" -U your_username -d your_database_name