zabbix-tools / libzbxpgsql

Monitor PostgreSQL with Zabbix
http://cavaliercoder.com/libzbxpgsql/
Other
158 stars 65 forks source link

pg.index.discovery and pg.table.discovery not working #70

Open nelpetro opened 7 years ago

nelpetro commented 7 years ago

Using libzbxpgsql-1.0.0-1.el6.x86_64.rpm on Zabbix 3.0

PostgreSQL Databases, PostgreSQL Settings and PostgreSQL Tablespaces Dicovery rules discover all 3 databases correctly, but PostgreSQL Tables and PostgreSQL Tablespaces discovery are not working.

[zabbix@auaps233 ~]$ ps -ef |grep zabbix zabbix 21621 1 0 Jan18 ? 00:00:00 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf zabbix 21623 21621 0 Jan18 ? 00:00:19 /usr/sbin/zabbix_agentd: collector [idle 1 sec] zabbix 21624 21621 0 Jan18 ? 00:00:25 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection] zabbix 21625 21621 0 Jan18 ? 00:00:26 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection] zabbix 21626 21621 0 Jan18 ? 00:00:26 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection] zabbix 21627 21621 0 Jan18 ? 00:04:40 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]

./pgpass settings for the zabbix user in /home/zabbix: [zabbix@auaps233 ~]$ ls -al | grep pgpass -rw------- 1 zabbix zabbix 113 Jan 18 12:57 .pgpass [zabbix@auaps233 ~]$

Error messages in zabbix_agentd.log:

21627:20170119:135629.290 active check "pg.table.discovery[host=auaps233 port=5432 user=zabbix connect_timeout=10,postgres]" is not supported: fe_sendauth: no password supplied

21627:20170119:140829.931 PostgreSQL: fe_sendauth: no password supplied

21627:20170119:140829.931 active check "pg.index.discovery[host=auaps233 port=5432 user=zabbix connect_timeout=10,postgres]" is not supported: fe_sendauth: no password supplied

21627:20170119:140829.940 PostgreSQL: fe_sendauth: no password supplied

What am I doing wrong?

cavaliercoder commented 7 years ago

When the module does 'wide' discovery of tables and indexes across multiple databases, it has to establish a new connection for each discovered database. This is a limitation of PostgreSQL.

Therefore, your .pgpass file must contain credentials for each database you wish to discover tables and indexes for. Please check this.

If you only want to discovery tables and indexes on the database you connect to (in your case postgres), you can set the third discovery parameter to shallow.

nelpetro commented 7 years ago

Thank you for your quick response. The .pgpass contains entries for all 3 databases. I will do some more troubleshooting on the .pgpass file

cavaliercoder commented 7 years ago

You might consider enabling debug logging in Zabbix to get a more detailed picture. It's incredibly verbose, but should contain the specifics you need.

nelpetro commented 7 years ago

I enabled debug and found that the agent was trying to connect to the 2 template databases as well, hence the fe_sendauth: no password supplied errors.

I added a {#DATABASE} filter on the discovery rules and am no longer getting that error.

However, table and index data are still not being collected. I have attached the zabbix agent log in debug mode. zabbix_agentd.debug.zip

Will appreciate if you could have a look and let me know if misconfigured something.

cavaliercoder commented 7 years ago

Thanks, I'll take a closer look. It is odd, as template dbs should be excluded for you already. What version of PostgreSQL are you running?

nelpetro commented 7 years ago

Running postgresql-9.4.6-1