[ZBX-11373] User macro not expanded as parameter for calculated item Created: 2016 Oct 19  Updated: 2017 May 30  Resolved: 2016 Oct 25

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Documentation (D)
Affects Version/s: 3.0.4
Fix Version/s: None

Type: Incident report Priority: Major
Reporter: Fabian Arrotin Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

I was initially searching for some way to aggregate/calculate the total bandwidth of a zabbix-agent, but there is no way to do that through LLD.
So, I wanted to use an intermediate calculated item at the host level (through template) but there is no wildcard support for there (so can't use {#IFNAME*} as a simple example

I tried to then define a user macro {$ETH_PUB_INT} and use that in the calculated item :

Type: Calculated
Item name : net.bw.out
Formula : last("net.if.out[{$ETH_PUB_INT}]")

But then at the zabbix server log, it says :

error reason for "host.domain.com:net.bw.out" changed: Cannot evaluate function "last()": item "host.domain.com:net.if.out[{$ETH_PUB_INT}]" does not exist.

So it seems that it's not expanding user macro to eth0 (as defined at the host level) and from doc (https://www.zabbix.com/documentation/3.0/manual/config/items/itemtypes/calculated) it seem that "User macros in the formula will be expanded if used to reference a parameter or a constant. User macros will NOT be expanded if used to reference a function, host name, item key or operator."

In my case, it's not an item key, but a paramater for an item key, so shouldn't it be expanded ??



 Comments   
Comment by Aleksandrs Saveljevs [ 2016 Oct 20 ]

As far as I understand, your scenario is approximately as follows. You have some items, say, net.if.out[eth0] and net.if.out[eth1], and you wish the calculated item to refer to net.if.out[eth0] by using a formula of last("net.if.out[{$ETH_PUB_INT}]") and defining {$ETH_PUB_INT} to be "eth0". If so, that is not going to work, because the first parameter to a function in calculated items should be the exact item key to refer to. In this particular case, it refers to net.if.out[{$ETH_PUB_INT}], which does not exist.

Therefore, closing as "Won't fix". For further support, please refer to https://www.zabbix.org/wiki/Getting_help .

Comment by richlv [ 2016 Oct 20 ]

it seems to me that this sentence in the documentation could be a bit misleading :
"User macros in the formula will be expanded if used to reference a parameter or a constant"

what parameter is meant here ?

Comment by Aleksandrs Saveljevs [ 2016 Oct 20 ]

Probably a function parameter is meant here. Reopening to clarify the docs...

Comment by Martins Valkovskis [ 2016 Oct 25 ]

Clarified in documentation for calculated items. Other documentation versions, too.

Generated at Sat Apr 20 13:16:30 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.