Closed MichaelDBA closed 2 years ago
This sounds like you have a general problem accessing the PostgreSQL server from the zabbix user account and not something with the scripts. Configuration parameters are set in the macro PG_CONNINFO
.
You can verify connection manually from the command line. Assuming that you installed as user zabbix
, you can try this, which should list all available databases:
sudo -u zabbix psql -h 127.0.0.1 -p 5432 -U postgres -d postgres -l
If this fails, then something is not in order with your PostgreSQL connection setup. Refer to PostgreSQL documentation on how to configure access to the database. Things to check is whether it connects using IP on localhost (your database is on the same server, right?) and permissions. Please also double-check that the server is actually up and running.
It should listen on localhost, otherwise you need to change either your connection mode or server configuration:
netstat -ln4 | grep 5432
Well that command works for me:
sudo -u zabbix psql -h 127.0.0.1 -p 5432 -U postgres -d postgres -l
Apparently the problem is related to what I am pulling in with this from zabbix_agentd.conf:
Include=/etc/zabbix/zabbix_agentd.d/*.conf
And this is what I have in /etc/zabbix/zabbix/zabbix_agentd.d:
template_db_postgresql.conf
userparameter_pgsql.conf
zabbix-extensions.conf
If I change the include to use only one of those files, it works:
Include=/etc/zabbix/zabbix_agentd.d/zabbix-extensions.conf
The PostgreSQL template I maintain brings the postgresql.conf
config with UserParameter scripts for the individual items. Your failing zabbix_get call hints toward a connection issue to your database server. The systemd error more towards an issue with the config.
Maybe check the config first. Did you have any additional errors logged? zabbix agent log or other entries in the journal? What are the other files in your zabbix_agent.d folder? Do some of them configure items with a conflicting name? Which file is from here? You have two which point towards Postgresql.
Sorry for not closing this earlier. I am using zabbix 5.4 now and I don't have this problem anymore.
I followed the instructions for adding Postgresql from the readme.md file here: https://github.com/lesovsky/zabbix-extensions/blob/master/files/postgresql/README.md
Then when i tried to restart the zabbix agent (I'm using zabbix 5.2 and PostgreSQL 13), I got this error:
I have trust turned on for everything in pg_hba.conf.
I tested using zabbix_get and here is the output: