Ad Widget

Collapse

Using macro in calculated item's formula

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Alex Konokhov
    Junior Member
    • Oct 2014
    • 1

    #1

    Using macro in calculated item's formula

    Hi,

    Need some help with understanding work of calculated item's formulas and user macros.
    I want to calculate daily amount of network traffic (IN and OUT) that goes through network interfaces on host 'test'.
    I used autodiscovery mechanism and there is an item "IN load on $1" with key "net.if.in[{#IFNAME},bytes]". The value of this item is stored as "Delta (simple change)".
    To calculate amount of traffic I need to sum values of this item from the start of the day (00:00).
    To know how many seconds passed from 00:00, I created UserParameter on host "Zabbix server" - "seconds.begin".
    Finally, I created calculated item "IN traffic on $1" with formula:
    Code:
    sum("net.if.in[{#IFNAME},bytes]",{Zabbix server:seconds.begin})
    First two items - "IN load on $1" and "seconds.begin" work well, but calculated item gives an error:
    Cannot evaluate function "sum({Zabbix server:magic.seconds.begin})"
    It looks like the macro {Zabbix server:magic.seconds.begin} is not expanded in the formula.

    The documentation tells, that:
    "User macros in the formula will be expanded if used to reference a parameter or a constant. "
    So, as I understood, there is a possibility to use macro which returns amount of seconds in function "sum". But my function doesn't work.

    I'll be grateful for any help.


    P.S.: done the same thing using simple bash script as UserParameter on host "test", but it would be more interesting to calculate it using only Zabbix functionality.
Working...