I'm monitoring a few PostgreSQL servers user Agent2 plugin and Zabbix official template for it. This worked correctly in Zabbix 6.2.
Since I upgraded the agents to 6.4.3, the agent fails to authenticate to the PostgreSQL instance without any config changes both on the DB, Agent2 plugin config. The template was also upgraded to v6.4-0, but didn't have notable changes since previous version.
Steps to reproduce:
- Install zabbix-agent2 + zabbig-agent2-postgresql-plugin on host with PostgreSQL DB running
- Import official Zabbix PostgreSQL by agent2 template
- Configure host/template/agent as outlined in the template setup instructions (https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/db/postgresql_agent2/README.md)
Settings used in this example:
- $PG.URI: tcp://localhost:5432
- $PG.USER: zbx_monitor
- $PG.PASSWORD: zbx_monitor
-> Notice that you are not instructed to set a default database in the agent2 plugin config
Result:
Agent2 fails to connect to the local postgresql database with error on itemkeys:
- pgsql.oldest.xid["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"]
- pgsql.cache.hit["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"]
- pgsql.archive["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"]
- pgsql.bgwriter["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"]
- pgsql.connections["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"]
- pgsql.dbstat["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"]
- pgsql.dbstat.sum["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}"]
[PostgreSQL] Connection failed: failed to connect to `host=localhost user=zabbix database=user=zbx_monitor`: server error (FATAL: password authentication failed for user "zabbix" (SQLSTATE 28P01)).
Documentation states that except for the URI, all other parameters are optional, but leaving the database out as currently the case in the official template, and not providing a Default database in the agent2 plugin config seems to confuse Agent2 6.4.3.
In the error message, I see the parameter "user=" twice, once with "zabbix" as value. I have no idea where this comes from, as the PG.USER passed to the key is "zbx_monitor".
Also the "database=" parameter is set but empty.
Expected:
Successful connection to database postgres (as that is the default and inherited template macro value for $PG.DATABASE and there is no notice in the documentation that it is mandatory to be defined elsewhere) and have a correct item value returned by Agent2.
Workaround:
Set in Agent2 plugin config postgresql.conf:
Plugins.PostgreSQL.Default.Database=postgres
This "Default" config item is new in agent2 6.4 plugin.
or change the above mentioned item's into:
- pgsql.oldest.xid["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]
- pgsql.cache.hit["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]
- pgsql.archive["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]
- pgsql.bgwriter["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]
- pgsql.connections["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]
- pgsql.dbstat["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]
- pgsql.dbstat.sum["{$PG.URI}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]
as currently the database is not provided to the agent except for custom queries item and items created by database discovery LLD rule.
- duplicates
-
ZBX-22868 zabbix-agent2 upgrade breaks postgresql plugin monitoring
- Closed