[ZBX-21206] pgsql.custom.query cannot query different databases on same host Created: 2022 Jun 14 Updated: 2024 Apr 10 Resolved: 2022 Dec 12 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | Agent2 plugin (G) |
Affects Version/s: | 6.0.4, 6.0.5 |
Fix Version/s: | 6.0.13rc1, 6.2.7rc1, 6.4.0beta5, 6.4 (plan) |
Type: | Problem report | Priority: | Trivial |
Reporter: | Lukas Sabla | Assignee: | Eriks Sneiders |
Resolution: | Fixed | Votes: | 3 |
Labels: | postgresql, zabbix-agent2 | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified | ||
Environment: |
Ubuntu 20.04 |
Issue Links: |
|
||||||||||||
Team: | |||||||||||||
Sprint: | Sprint 90 (Jul 2022), Sprint 91 (Aug 2022), Sprint 92 (Sep 2022), Sprint 93 (Oct 2022), Sprint 94 (Nov 2022), Sprint 95 (Dec 2022) | ||||||||||||
Story Points: | 1 |
Description |
We operation multiple postgresql databases on single host, in which we used to monitor data with simple sql queries via zabbix-agent2 plugin item - pgsql.custom.query. We use zabbix-agent active type of items and single database user zbx_monitor. Steps to reproduce:
In postgres log it seems like zabbix-agent queries wrong database - mostly postgres as default and not the one sent via key parameter. Sometimes it runs query from one item against database from other item. We have tried to use item key with uri, user, password and database as well as key with named session, but with same result. As last working version for us was 6.0.3, we suspect commit 139fbddc248 to be a culprit of our troubles. |
Comments |
Comment by Luc Van der Veken [ 2022 Nov 24 ] |
I am having the same problem. I have one template using pgsql.custom.query (cloned and query filename added), querying a single database other than 'postgres' on those servers. It fails (much) more often than it works, it seems to be executing the query in the wrong database ("relation 'tablename' does not exist). Thinking the template may be using the database macro from the agent1 agent (PG.DB instead of PG.DATABASE), I added that to my own template too, still the same. I even tried replacing the macro's in the definition by fixed strings, no difference. |
Comment by Vladislavs Sokurenko [ 2022 Nov 24 ] |
Currently connections are made based on url without query, it should be fixed |
Comment by Luc Van der Veken [ 2022 Nov 24 ] |
There appears to have been a collision (real-life race condition?), sorry if it put you on the wrong leg. Looking at git, I see that I posted my comment above two days after it had been fixed. By looking at the changes in git, I discovered a workaround: redefined the uri with '127.0.0.1' instead of 'localhost' for the custom query to the other database, and it looks like it's working. Thanks for all your efforts. Zabbix is reasonably new to me, it looks like a magnificent product. |
Comment by Eriks Sneiders [ 2022 Dec 08 ] |
Fixed in Zabbix agent 2
Zabbix Plugin Support
Zabbix PostgreSQL plugin
|
Comment by Andreas Dijkman [ 2023 Feb 13 ] |
zabbix agent2 6.0.13 has been released but this still doesn't work. We updated to zabbix-agent2-6.0.13 and zabbix-agent2-plugin-postgresql-6.0.13 on RHEL9. @Erik Sneiders can you confirm the patch has been applied to to 6.0.13 release? |
Comment by Eriks Sneiders [ 2023 Feb 13 ] |
Hi andreas.dijkman! I can confirm that the fix/revert was merged for 6.0.13 release. If possible could you share the error you are receiving, and Zabbix agent 2 log with log level 5. Do note to remove any sensitive data Zabbix agent 2 log might contain. Do the steps to reproduce the issue match with the ones provided in the ticket? |
Comment by Andreas Dijkman [ 2023 Feb 13 ] |
Thanks for checking and pointing me in the right direction. The agent was hanging on stopping on debug level 5 (timeout during stop) and by forcefully killing it and restarting it (don't know why) the agent is working as expected. |