[ZBXNEXT-9418] Use consistent macro names in ODBC and agent2 DB templates Created: 2024 Aug 15  Updated: 2024 Nov 19  Resolved: 2024 Sep 29

Status: Closed
Project: ZABBIX FEATURE REQUESTS
Component/s: Templates (T)
Affects Version/s: 7.0.2
Fix Version/s: 6.0.35rc1, 7.0.5rc1, 7.2.0alpha1

Type: Change Request Priority: Medium
Reporter: Edgars Melveris Assignee: Aleksejs Abrosimovs
Resolution: Fixed Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Causes
causes ZBX-25292 Ivalid CONNSTRING in template Postgre... Closed
causes ZBX-25255 Connection string macros skipped duri... Closed
Duplicate
Team: Team INT
Story Points: 1

 Description   

If both templates we use the same macro to define connection details:

{$PG.CONNSTRING}

But in each template we expect different contents for this macro.
It could help management of hosts in situations where both templates could be used for different hosts.

PostgreSQL by Zabbix agent 2

{$PG.CONNSTRING} = tcp://localhost:5432

PostgreSQL by ODBC:

{$PG.CONNSTRING} = Servername=localhost;Port=5432;Driver=/usr/lib64/psqlodbcw.so

For example, if we set macros like {$PG.ADDRESS}, {$PG.PORT} and {$PG.DRIVER}, they could be set universally for all hosts and then each template uses them differently.

Then in agent2 template the key would become:

pgsql.dbstat.sum["tcp://{$PG.ADDRESS}:{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}"]

But on ODBC template:

db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};Servername={$PG.ADDRESS};Port={$PG.PORT};Driver={$PG.DRIVER}"]


 Comments   
Comment by Aleksejs Abrosimovs [ 2024 Aug 21 ]

Although the idea of unifying {$PG.CONNSTRING} macros from different templates sounds appealing, it is impossible to implement it without neglecting the possibility of using secure connections to a database or other optional connection parameters.

The difference in possible content for both variants of {$PG.CONNSTRING} is too significant to unify them.
In case of Zabbix Agent 2 {$PG.CONNSTRING} even could have neither address nor port, but just a custom name for a session described in configuration file.
The example is described in "Note" part of the "Setup" section in README for PostgreSQL by Zabbix agent 2:
https://www.zabbix.com/integrations/postgresql#postgresql_agent2
In case of ODBC, {$PG.CONNSTRING} is a standard connection string passed to the ODBC driver. And that string could have a lot of optional parameters.
The example is described in "Note" part of the "Setup" section in README for PostgreSQL by Zabbix agent 2:
https://www.zabbix.com/integrations/postgresql#postgresql_odbc

As a possible solution for bulk host macro management and for distinguishing one host type macro from another, you can separate Agent 2 and ODBC macros. As an example: export these two templates, find all {$PG.CONNSTRING} and replace it to {$PG.CONNSTRING.ODBC} in ODBC template and {$PG.AGENT2.CONNSTRING} in Agent 2 template. And import them back.

 

Comment by Kim Anthonisen [ 2024 Aug 27 ]

The idea is not to unify them, but that the templates use different macro names, since the usage/content is different

Comment by Kim Anthonisen [ 2024 Aug 27 ]

The workaround is not usable, as it effectively prevents us from updating the templates with new releases from Zabbix

Comment by Aleksejs Abrosimovs [ 2024 Sep 12 ]

Available in:

Generated at Sat Apr 19 11:11:00 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.