[ZBX-2625] macros are not scoped Created: 2010 Jun 30  Updated: 2017 May 30  Resolved: 2012 Jun 17

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Frontend (F), Server (S)
Affects Version/s: 1.8.2
Fix Version/s: None

Type: Incident report Priority: Major
Reporter: Thomas Spengler Assignee: Unassigned
Resolution: Won't fix Votes: 1
Labels: macros, templates
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by ZBX-9386 Template macro precedence Closed

 Description   

when you have a macro used in
templateA with name CLUSTER and define a value also in this template like {$CLUSTER} => cA
templateB with name CLUSTER and define a value also in this template like {$CLUSTER} => cB

and use templateA and templateB in the same Host,
you have only the value from TemplateA

it means the the Macro's are global even they are defined only in templates



 Comments   
Comment by richlv [ 2010 Jun 30 ]

hmm. i don't understand the problem really.
if you define the same macro in two templates of the same level that are linked to same host, quite obviously the resolving of the macro is a bit undefined.

1. what do you mean by "the Macro's are global even they are defined only in templates" ?

2. how would you expect for this to behave ?

Comment by Thomas Spengler [ 2010 Jun 30 ]

I have

HOST
– Template A
---- Macro CLUSTER = cA
---- Value of CLUSTER inside the Template == cA
– Template B
---- Macro CLUSTER = cB
---- Value of CLUSTER inside the Template == cA

you see the problem

I would expect a nearest wins behaviour

e.g.

HOST
– Template A
---- Macro CLUSTER = cA
---- Value of CLUSTER inside the Template == cA
– Template B
---- Macro CLUSTER = cB
---- Value of CLUSTER inside the Template == cB

or

HOST
– Macro CLUSTER = cA
– Template A
---- Value of CLUSTER inside the Template == cA
– Template B
---- Macro CLUSTER = cB
---- Value of CLUSTER inside the Template == cB
– Template C
---- Value of CLUSTER inside the Template == cA

Comment by richlv [ 2010 Jun 30 ]

so you mean both templates are linked to the host directly ?
if so, there is no way to determine "nearest" one

Comment by Thomas Spengler [ 2010 Jun 30 ]

yes, both are linked to the same host,

but the items are in different templates

Comment by Thomas Spengler [ 2010 Jun 30 ]

my expected behavior is also

HOST
– Template A
---- Macro CLUSTER = cA
---- Value of CLUSTER inside the Template == cA
– Template B
---- Macro CLUSTER = cB
---- Value of CLUSTER inside the Template == cB
– Template C
---- NO MACRO defined
---- Value of CLUSTER inside the Template == {$CLUSTER}

Comment by richlv [ 2010 Jul 06 ]

i don't fully understand your schematics, but i'll try describing the problem as i might have understood it

if two templates that contain the same macro are linked to single host on the same level, you expect items from each template to use macro value from the same template.

is that correct ?

if so, what happens in nested configuration, where normally lower level template would override values coming from a higher level template ?

Comment by Thomas Spengler [ 2010 Jul 13 ]

That is my misunderstanding

I expect, that lower level template overwrites it's values, BUT only for them self and not for all others.

Comment by Alexander Vladishev [ 2015 Mar 10 ]

User macros resolving are described in our documentation. Feel free to reopen if macros are resolved in other way on your system.

Generated at Wed May 08 18:05:07 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.