当必须使用一些大数字,例如“86400”来表示一天中的秒数,既困难又容易出错。这就需要使用一些单位符号来简化 Zabbix 触发器表达式和监控项键。
可以简单地输入“1d”,而不是“86400”秒。后缀起到乘数的作用。
对于时间可以使用:
时间单位仅支持整数(因此支持“1h”,不支持“1,5h”或“1.5h”;请改用“90m”)。
时间单位支持:
ha_set_failover_delay=delay
运行时控制 选项内存大小单位支持:
对于内存大小可以使用:
单位符号也用于前端数据可读的表示法。
Zabbix server 和前端都支持这些符号:
当监控项值在前端显示为B、Bps时, 是基于二进制的(1K = 1024)。其他情况基于十进制(1K = 1000)。
此外,前端还支持显示:
通过使用一些适当的单位,可以编写更易于理解和维护的触发器表达式,例如这些表达式:
last(/host/system.uptime[])<86400s
avg(/host/system.cpu.load,600s)<10
last(/host/vm.memory.size[available])<20971520
可以改为:
last(/host/system.uptime[])<1d
avg(/host/system.cpu.load,10m)<10
last(/host/vm.memory.size[available])<20M
By default, specifying a unit for an item results in a multiplier prefix being added - for example, an incoming value '2048' with unit 'B' would be displayed as '2KB' by the frontend (for more details, see Units in item configuration).
To prevent a unit from conversion, use the !
prefix, for example, !B
. To better understand how the conversion works with and without the exclamation mark, see the following examples of values and units:
1024 !B → 1024 B
1024 B → 1 KB
61 !s → 61 s
61 s → 1m 1s
0 !uptime → 0 uptime
0 uptime → 00:00:00
0 !! → 0 !
0 ! → 0
Before Zabbix 4.0, there was a hardcoded unit stoplist consisting of ms
, rpm
, RPM
, %
. This stoplist has been deprecated, thus the correct way to prevent converting such units is !ms
, !rpm
, !RPM
, !%
.