ZABBIX BUGS AND ISSUES
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-11373

User macro not expanded as parameter for calculated item

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.0.4
    • Fix Version/s: None
    • Component/s: Documentation (D)
    • Labels:
      None

      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 ??

        Activity

        Hide
        Aleksandrs Saveljevs added a comment -

        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 .

        Show
        Aleksandrs Saveljevs added a comment - 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 .
        Hide
        richlv added a comment -

        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 ?

        Show
        richlv added a comment - 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 ?
        Hide
        Aleksandrs Saveljevs added a comment -

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

        Show
        Aleksandrs Saveljevs added a comment - Probably a function parameter is meant here. Reopening to clarify the docs...
        Hide
        Martins Valkovskis added a comment -

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

        Show
        Martins Valkovskis added a comment - Clarified in documentation for calculated items . Other documentation versions, too.

          People

          • Assignee:
            Unassigned
            Reporter:
            Fabian Arrotin
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: