[ZBX-20304] Macro from host level doesn't work into action/script Created: 2021 Dec 01  Updated: 2021 Dec 14  Resolved: 2021 Dec 14

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Frontend (F)
Affects Version/s: 5.4.8
Fix Version/s: None

Type: Incident report Priority: Trivial
Reporter: Lukasz Ma Assignee: Francys Nivea (Inactive)
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File image-2021-12-01-20-34-05-726.png     PNG File image-2021-12-01-20-34-52-500.png     PNG File image-2021-12-01-20-35-26-753.png     PNG File image-2021-12-07-14-48-50-619.png     PNG File image-2021-12-07-14-49-07-258.png     PNG File image-2021-12-14-16-46-41-588.png     PNG File image-2021-12-14-16-49-55-590.png     PNG File image-2021-12-14-16-55-38-202.png     PNG File image-2021-12-14-16-57-06-975.png     PNG File image-2021-12-14-16-58-59-483.png     PNG File image-2021-12-14-17-17-37-461.png     PNG File image-2021-12-14-17-27-23-934.png     PNG File screenshot-1.png     JPEG File zabbix_action.jpg     PNG File zbx - action log.PNG     PNG File zbx - action.PNG     PNG File zbx - global macro.PNG     PNG File zbx - macro.PNG    

 Description   

Steps to reproduce:

  1. Please set the global macro as {$MACRO1} with value Global1
  2. Please set the local macro as {$MACRO1} with value Local1
  3. Please create the script and as a parameter please use this {$MACRO1} for example: notification.sh --info "{$MACRO1}"
  4. Please create the action for all problems from host where {$MACRO1} uses please execute the script notification.sh

Result:

Macro from global (Global1) will be used instead of Host (Local1)

Expected:
which is not in accordance with the guide:

Zabbix resolves macros according to the following precedence:

  1. host level macros (checked first)


  2. macros defined for first level templates of the host (i.e., templates linked directly to the host), sorted by template ID

  3. macros defined for second level templates of the host, sorted by template ID

  4. macros defined for third level templates of the host, sorted by template ID, etc.

  5. global macros (checked last)


 Comments   
Comment by Francys Nivea (Inactive) [ 2021 Dec 06 ]

Could not reproduce

Global macros

Local macros

Action configuration

Result - Action log

 

 

 

Comment by Lukasz Ma [ 2021 Dec 06 ]

Please create the new host and set macros than please execute the action (executed on zabbis server - not current host)

Comment by Lukasz Ma [ 2021 Dec 07 ]

Please execute the action on zabbix server instead of current host/host. It doesn't work when action executes on zabbix_server or agent on zabbix server. Then the global macro takes priority instead of local from the host.

Comment by Lukasz Ma [ 2021 Dec 07 ]

Please take a look into your screens:
Action should be executed on Zabbix server:

but it has been executed on local host (new server):

Comment by Francys Nivea (Inactive) [ 2021 Dec 07 ]

Same thing

Comment by Lukasz Ma [ 2021 Dec 07 ]

Did you make an upgrade from previous version or just install the new as 5.4.x ?
Problem has been reproduced on the server upgraded from 5.0.2 and 5.2.5

Comment by Francys Nivea (Inactive) [ 2021 Dec 07 ]

Using same version as informed, 5.4.8

Comment by Lukasz Ma [ 2021 Dec 07 ]

Ok, but as fresh installation or upgraded? Issue occurred on the version 5.4.8 upgraded from 5.2.5 and 5.0.2 

Comment by Lukasz Ma [ 2021 Dec 07 ]

I forgot that Macro should be set on the template lever and template attached on Host, so:
1. Please create the template with {$Macro1} and set the value as Local1
2. Please attach the template on host Debian Playground
3. Please create the global macro as {$Macro1} with value Global1
4. Please execute the action on Zabbix Server with parameter from Host from Template.

Comment by Lukasz Ma [ 2021 Dec 14 ]

Hello,

The issue occurs still when you will attach the template on host.

Br

Comment by Francys Nivea (Inactive) [ 2021 Dec 14 ]

Confirmed problem when "Template Level" macro is changed at host level:

I replicated the environment and new situations reported by you, and this was the result:

  1. I created a server that was upgraded from version 5.2.5 to 5.4.8
  2. I created a macro at the template level
  3.  Applied this template to my host and changed value of macro
  4.  Created action to be executed on host
  5. Forced alert and looked Action Log page
  6. Result

 

I don't understand when you say to create at the template level and then at the global level, as the result is to use the macro value at the template level. However, it follows the result when doing as described

Generated at Mon Jun 30 07:50:44 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.