This is a translation of the original English documentation page. Help us make it better.

1 Calcoli aggregati


In aggregate calculations information from several items may be collected by Zabbix server (by doing direct database queries) to calculate an aggregate, depending on the aggregate function used.

Aggregate calculations do not require any agent running on the host being monitored.

To define aggregate calculations, select the Calculated item type.


Aggregates can be retrieved by working with either:

  • history of items:
aggregate_function(foreach_function(/*/key?[group="host group"],timeperiod))


  • aggregate_function is one of the supported aggregate functions: avg, max, min, sum, etc.
  • foreach_function is one of the supported foreach functions: avg_foreach, count_foreach, etc.

Foreach functions use an item filter, to work with the history of multiple items, and return an array of values - one for each item.

If the aggregate results in a float value it will be trimmed to an integer if the aggregated item type of information is Numeric (unsigned).

An aggregate calculation may become unsupported if:

  • none of the referenced items is found (which may happen if the item key is incorrect, none of the items exists or all included groups are incorrect)
  • no data to calculate a function

Esempi di utilizzo

Esempi di chiavi per calcoli aggregati.

Esempio 1

Totale spazio su disco del gruppo host "MySQL Servers".

sum(last_foreach(/*/vfs.fs.size[/,total]?[group="MySQL Servers"]))
Esempio 2

Somma dei valori più recenti di tutti gli elementi corrispondenti a[*] sull'host.

Esempio 3

Carico medio del processore del gruppo host "MySQL Servers".

avg(last_foreach(/*/system.cpu.load[,avg1]?[group="MySQL Servers"]))
Esempio 4

Media di 5 minuti del numero di query al secondo per il gruppo host "Server MySQL".

avg(avg_foreach(/*/mysql.qps?[group="MySQL Servers"],5m))
Esempio 5

Carico medio della CPU su tutti gli host in più gruppi host che dispongono di tag specifici.

avg(last_foreach(/*/system.cpu.load?[(gruppo="Server A" o gruppo="Server B" o gruppo="Server C") e (tag="Servizio:" o tag="Importanza: Alto")]))
Esempio 6

Calcolo utilizzato sulle somme dei valori degli articoli più recenti di un intero gruppo host.

sum(last_foreach(/*/net.if.out[eth0,bytes]?[group="video"])) / sum(last_foreach(/*/[active]?[group="video"]) )
Esempio 7

Il numero totale di elementi non supportati nel gruppo host "server Zabbix".

sum(last_foreach(/*/zabbix[host,,items_unsupported]?[group="Zabbix server"]))
Examples of correct/incorrect syntax

Expressions (including function calls) cannot be used as history, trend, or foreach function parameters. However, those functions themselves can be used in other (non-historical) function parameters.

Expression Example
Valid avg(last(/host/key1),last(/host/key2)*10,last(/host/key1)*100)
max(avg(avg_foreach(/*/system.cpu.load?[group="Servers A"],5m)),avg(avg_foreach(/*/system.cpu.load?[group="Servers B"],5m)),avg(avg_foreach(/*/system.cpu.load?[group="Servers C"],5m)))
Invalid sum(/host/key,10+2)
sum(/host/key, avg(10,2))

Note that in an expression like:


it cannot be guaranteed that both parts of the equation will always have the same set of values. While one part of the expression is evaluated, a new value for the requested period may arrive and then the other part of the expression will have a different set of values.