2022 Zabbix中国峰会
2022 Zabbix中国峰会

1 触发器函数

1 Supported trigger functions

所有触发器表达式支持的函数都在下表中。 All functions supported in trigger expressions are listed here.

函数
FUNCTION
描述信息 **参 ** **备注*
Description Parameters Comments
abschange
后一个值与前一个值变动的绝对值。 支持的值类型: floa , nt, str, text, log

例如:
(前一个值;后一个值=绝对值)
1;5=4
3;1=2
0;-2.5=2.5

值类型为str型的返回值:
0 - 两个str相等
1 - 两个str不相等
例如:
(前一个值;后一个值=绝对值)
1;5=4
3;1=2
0;-2.5=2.5

值类型为str型的返回值:
0 - 两个str相等
1 - 两个str不相等
avg (sec|#num,<time_shift>)
指定评估期内的一个item的平均值。 sec or ** #num** - 评估期以多少秒或最新值个数(个数跟在#号后)表示  支持的值类型: float, int
time_shift (可选) - 评估时间点相对于当前时间的偏移量
<Examples:
=> avg(#5) → 最新5个值的平均值
=> avg(1h) → 最近一小时的平均值
=> avg(1h,1d) → 一天前的一小时内的平均值

从Zabbix 1.8.2开始支持time_shift参数。 主要用于将当前平均值与偏移若干秒后的平均值进行比较。
Examples:
=> avg(#5) → 最新5个值的平均值
=> avg(1h) → 最近一小时的平均值
=> avg(1h,1d) → 一天前的一小时内的平均值

从Zabbix 1.8.2开始支持time_shift参数。 主要用于将当前平均值与偏移若干秒后的平均值进行比较。
band (sec|#num,mask,<time_shift>)
将item值与mask进行按位与操作。 sec (可 略) or #num - 第N个最近的价值。  支持的值类型: int
mask (不可省略) - 64-bit无符号整数 (0 - 18446744073709551615) 
time_shift (可选) - 参见avg() 函数 请注意#|<um在这里的工作方式与其他函数不同(具体用法参见last()函数)。
\\尽管以二进制方式进行比较,但是所有的参数和返回值都是十进制。

示例:
=> band(,12)=8 or band(,12)=4 → 第三位和第四位被设置,但不是同时设置。
=> band(,20)=16 →第三位没有被设置但是第五位被设置了。

从Zabbix 2.2.0开始支持该函数。
time_shift (可选) - 参见avg() 函数 请注意#|um在这里的工作方式与其他函数不同(具体用法参见last()函数)。
\\尽管以二进制方式进行比较,但是所有的参数和返回值都是十进制。

示例:
=> band(,12)=8 or band(,12)=4 → 第三位和第四位被设置,但不是同时设置。
=> band(,20)=16 →第三位没有被设置但是第五位被设置了。

从Zabbix 2.2.0开始支持该函数。
change
最近获取值与之前获取值的差。 支持值类型: flo t, int, str, text, log

例如:
(前一个值;后一个值=差)
1;5=+4
3;1=-2
0;-2.5=-2.5

可与abschange函数对照。

值类型为str型的返回值:
0 - 两个str相等
1 - 两个str不相等
The amount of difference between last and previous values. Supported value types: float, int, str, text, log

For example:
(previous value;last value=change)
1;5=+4
3;1=-2
0;-2.5=-2.5

See also: abschange for comparison

For strings returns:
0 - values are equal
1 - values differ
count (sec|#num,<pattern>,<operator>,<time_shift>)

|<|指定评估期内值出现的次数。 sec or |#num - 评估期以多少秒或最新值个数(个数跟在#号后)表示。  支持值类型: float, integer, string, text,pattern (可选) - 指定模式  浮点类型的
operator (可选) 
支持的操作符: 
eq* - 等于 
ne
- 不等于 
gt - 大于  示ge - 大于等于  =&glt - 小于  =le - 小于等于  =&glike - 只要包含(区分大小写)就被匹配  => count(band - 按位与  =&regexp - 按pattern参数进行正则表达式匹配(大小写敏感)  => count(10m,12iregexp - 按pattern参数进行正则表达式匹配(不区分大小)  => count(10m,6/
注意: 
eq (默认), ne, gt, ge, lt, le, band, regexp, iregexp仅仅支持整型数据。  #num 参数从eq (默认), ne, gt, ge, lt, le, regexp, iregexp仅仅支持浮点型数据。  time_shift*like* (默认), *eq*, *ne*, *regexp*, *iregexp*支持string, text和log类型数据。\ *band*操作从
**time\_shift** (可选) - 参考avg()函数|log
据精度为0.000001。

and*作为第三个参数时, 第二个参数
pattern可以用'/'分隔的两个数字表示: **number\_to\_compare\_with/mask**。 count() 函数计算值和掩码的按位与,再和 number\_to\_compare\_with 参数进行比较,如果与*number\_to\_compare\_with*参数结果相等, 则该值被计数。
如果参数*number\_to\_compare\_with*和参数*mask*相等时, 只需要指定*mask*参数,不需要指定number\_to\_compare\_with参数以及使用'/'。
egexp*或*iregexp*作为第三个参数时,第二个参数
pattern可以是一个普通的或以 '@'开头的[全局](/manual/regular_expressions#global_regular_expressions)正则表达式。使用全局正则表达式时,是否大小写敏感取决于全局正则表达式的配置。为了进行正则表达式匹配,浮点值将始终用'.'后的4位数字表示。另请注意,对于十进制(存储在数据库中)和二进制(由Zabbix server使用)表示的数字差异,可能会对4位数字有影响。
:
; count(10m) → 过去10分钟值的个数。
gt; count(10m,"error",eq) → 过去十分钟值等于'error'的个数。
; count(10m,12) → 过去10分钟值等于12的个数。
0m,12,gt) → 过去10分钟值大于12的个数。
t; count(\#10,12,gt) → 最新10个值大于12的个数。
gt,1d) → 昨天这个时间点前十分钟值大于12的个数。
,band) → 过去10分钟值最低三个有效位是 '110' (二进制)的个数。
=> count(10m,,,1d) → 昨天这个时间点前十分钟值的个数。
abbix 1.6.1开始获得支持。
参数和字符类型操作从Zabbix 1.8.2开始获得支持。
abbix 2.2.0开始获得支持。
*regexp*, *iregexp*从Zabbix 3.2.0开始获得支持。| |-|----------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |<|<|
**operator** (可选)\ *
支持的操作符:\
*eq* - 等于\ **ne* - 不等于\
*gt* - 大于\ 示*ge* - 大于等于\ =&g*lt* - 小于\ =*le* - 小于等于\ =&g*like* - 只要包含(区分大小写)就被匹配\ => count(*band* - 按位与\ =&*regexp* - 按
pattern参数进行正则表达式匹配(大小写敏感)\ => count(10m,12*iregexp* - 按pattern参数进行正则表达式匹配(不区分大小)\ => count(10m,6/
注意:\
*eq* (默认), *ne*, *gt*, *ge*, *lt*, *le*, *band*, *regexp*, *iregexp*仅仅支持整型数据。\
#num参数从*eq* (默认), *ne*, *gt*, *ge*, *lt*, *le*, *regexp*, *iregexp*仅仅支持浮点型数据。\time_shiftlike (默认), eq, ne, regexp, iregexp支持string, text和log类型数据。  band操作从
time_shift (可选) - 参考avg()函数|
and作为第三个参数时, 第二个参数pattern可以用'/'分隔的两个数字表示: number_to_compare_with/mask。 count() 函数计算值和掩码的按位与,再和 number_to_compare_with 参数进行比较,如果与number_to_compare_with参数结果相等, 则该值被计数。
如果参数
number_to_compare_with和参数mask相等时, 只需要指定mask参数,不需要指定number_to_compare_with参数以及使用'/'。
egexp
iregexp作为第三个参数时,第二个参数pattern可以是一个普通的或以 '@'开头的全局正则表达式。使用全局正则表达式时,是否大小写敏感取决于全局正则表达式的配置。为了进行正则表达式匹配,浮点值将始终用'.'后的4位数字表示。另请注意,对于十进制(存储在数据库中)和二进制(由Zabbix server使用)表示的数字差异,可能会对4位数字有影响。
:
; count(10m) → 过去10分钟值的个数。
gt; count(10m,"error",eq) → 过去十分钟值等于'error'的个数。
; count(10m,12) → 过去10分钟值等于12的个数。
0m,12,gt) → 过去10分钟值大于12的个数。
t; count(#10,12,gt) → 最新10个值大于12的个数。
gt,1d) → 昨天这个时间点前十分钟值大于12的个数。
,band) → 过去10分钟值最低三个有效位是 '110' (二进制)的个数。
=> count(10m,,,1d) → 昨天这个时间点前十分钟值的个数。
abbix 1.6.1开始获得支持。
参数和字符类型操作从Zabbix 1.8.2开始获得支持。
abbix 2.2.0开始获得支持。
regexp, iregexp从Zabbix 3.2.0开始获得支持。|

date
当前时间,格式为:YYYYMMDD。 支持值类型: *a y*

例如返回值: 20150731
Current date in YYYYMMDD format. Supported value types: any

Example of returned value: 20150731
dayofmonth
当前是本月的第几天,取值范围从1到31。 支持值类型: any
<
从Zabbix 1.8.5开始支持该函数。
Day of month in range of 1 to 31. Supported value types: any

This function is supported since Zabbix 1.8.5.
dayofweek
当前是本周的第几天,取值范围从1到7 (周一 - 1, 周日 - 7). 支持值的类型: any
Day of week in range of 1 to 7 (Mon - 1, Sun - 7). Supported value types: any
delta (sec|#num,<time_shift>)
指定评估期内最大值和最小值的差('max()' 减去 'min()')。 sec or **#nu ** - 评估期以多少秒或最新值个数(个数跟在#号后)表示。  支持值类型: float, int
time_shift (可选) - 参考avg()函数
<从Zabbix 1.8.2开始支持time_shift参数。
Difference between the maximum and minimum values within the defined evaluation period ('max()' minus 'min()'). sec or #num - evaluation period in seconds or in latest collected values specified (preceded by a hash mark)
time_shift (optional) - see avg()
Supported value types: float, int

The time_shift parameter is supported since Zabbix 1.8.2.
diff
比较最近获取值与之前获取值是否相同。 支持值类型: float, nt str, text, log

返回值:
1 - 两值不等
0 - 两值相等
Checking if last and previous values differ. Supported value types: float, int, str, text, log

Returns:
1 - last and previous values differ
0 - otherwise
forecast (sec|#num,<time_shift>,time,<fit>,<mode>)
预测item未来的最大值,最小值,增量值或平均值。 sec or #num - 评估期以多少秒或最新值个数(个数跟在#号后)表示。  支持值类型: float, int
time_shift (可选) - 参考avg()函数 
time - 需要预测的时间点  如果返回值大于fit (可选) - 用于匹配历史数据的函数 

支持的匹配函数: 
linear - 线性函数  ExapolynomialN - N次多项式 (1 <= N <= 6)  =&gexponential - 指数函数  =&glogarithmic - 对数函数  =&gpower - 幂函数  =&
注意:  =linear函数为默认, polynomial1等同于linear 

mode (可选) - 按需输出  参数t
支持的
modes:
*value* - 值 (默认)
*max* - 最大值
*min* - 最小值
*delta* - *最大*-*最小*
*avg* - 平均值

注意:
*value* 预测item值在
now+time时间点
*max*, *min*, *delta* 和 *avg* 函数在
nownow+time时间段计算item值|<999999999999.9999 或者小于 -999999999999.9999, 返回值相应被设置为999999999999.9999 或 -999999999999.9999 。
只有在表达式被错误使用时才不可用(错误的项目类型,无效的参数),出现错误时返回-1。
ples:
; forecast(\#10,,1h) → 根据最新的十个值预测一小时后的值
; forecast(1h,,30m) → 根据过去一小时的值预测三十分钟后的值
; forecast(1h,1d,12h) → 根据昨天这个时间点前一个小时的值预测十二个小时后的值
t; forecast(1h,,10m,exponential) → 根据过去一小时的值并按照指数函数方式预测十分钟后的值
=> forecast(1h,,2h,polynomial3,max) → 根据过去一小时的值并按照三次多项式方式预测两小时后的最大值
gt; forecast(\#2,,-20m) → 根据最新的两个值预测二十分钟前的值 (比使用last()或prev()函数更加精确, 特别是item很少更新的时候, 比如说, 一小时一次)
从Zabbix 3.0.0开始支持该函数。
me
允许负值从Zabbix 3.0.6和3.2.2开始支持。
参考 触发器预测函数.
Future value, max, min, delta or avg of the item. sec or #num - evaluation period in seconds or in latest collected values specified (preceded by a hash mark)
time_shift (optional) - see avg()
time - forecasting horizon in seconds
fit (optional) - function used to fit historical data

Supported fits:
linear - linear function
polynomialN - polynomial of degree N (1 <= N <= 6)
exponential - exponential function
logarithmic - logarithmic function
power - power function

Note that:
linear is default, polynomial1 is equivalent to linear

mode (optional) - demanded output

Supported modes:
value - value (default)
max - maximum
min - minimum
delta - max-min
avg - average

Note that:
value estimates item value at the moment now + time
max, min, delta and avg investigate item value estimate on the interval between now and now + time
Supported value types: float, int

If value to return is larger than 999999999999.9999 or less than -999999999999.9999, return value is cropped to 999999999999.9999 or -999999999999.9999 correspondingly.

Becomes not supported only if misused in expression (wrong item type, invalid parameters), otherwise returns -1 in case of errors.

Examples:
=> forecast(#10,,1h) → forecast of item value after one hour based on last 10 values
=> forecast(1h,,30m) → forecast of item value after 30 minutes based on last hour data
=> forecast(1h,1d,12h) → forecast of item after 12 hours based on one hour one day ago
=> forecast(1h,,10m,exponential) → forecast of item value after 10 minutes based on last hour data and exponential function
=> forecast(1h,,2h,polynomial3,max) → forecast of maximum value item can reach in next two hours based on last hour data and cubic (third degree) polynomial
=> forecast(#2,,-20m) → estimate the value of an item which was 20 minutes ago based on last two values (this can be more precise than using last() or prev(), especially if item is updated rarely, say, once an hour)

This function is supported since Zabbix 3.0.0.
Negative time values are supported since Zabbix 3.0.6 and 3.2.2.
See also additional information on predictive trigger functions.
fuzzytime (sec)
检查item的时间戳和zabbix server时间之间相差多大。 sec - 秒数 支持值类型: float, int <
返回值:
0 - item时间戳和zabbix server时间戳之间相差超过指定的时间
1 - 其它。

常使用system.localtime来检查本地时间是否与zabbix server的时间相同。
也可以使用vfs.file.time[/path/file,modify]键值检测文件是否长时间未更新。

例如:
=> fuzzytime(60)=0 → 如果时间差超过60秒,就会检测到一个问题
Checking how much an item timestamp value differs from the Zabbix server time. sec - seconds Supported value types: float, int

Returns:
0 - if difference between item timestamp value and Zabbix server timestamp is over T seconds
1 - otherwise.

Usually used with system.localtime to check that local time is in sync with local time of Zabbix server.
Can be used also with vfs.file.time[/path/file,modify] key to check that file didn't get updates for long time.

Example:
=> fuzzytime(60)=0 → detect a problem if time difference is over 60 seconds
iregexp (pattern,<sec|#num>)
该函数和 regexp() 类似,只是不区分大小写。 参考regexp()函数 持值类型: str, log, te t
This function is a non case-sensitive analogue of regexp(). see regexp() Supported value types: str, log, text
last (sec|#num,<time_shift>)
最近的值。 **se ** (可省略) or #num - 最新的第N个值  支持值类型: float,time_shift (可选) - 参考avg()函数
int, str, text, log
注意此处的 #num 参数和在其它函数中的作用不一样。
例如:
last() 通常等同于 last(#1)
last(#3) - 第三个最新值 (不是三个最新值)

如果在history中同一秒有多个值存在,Zabbix不能保证值的精确顺序。

从Zabbix 1.6.2开始支持 #num 参数。
从Zabbix 1.8.2开始支持 time_shift 参数。
The most recent value. sec (ignored) or #num - the Nth most recent value
time_shift (optional) - see avg()
Supported value types: float, int, str, text, log

Take note that #num works differently here than with many other functions.
For example:
last() is always equal to last(#1)
last(#3) - third most recent value (not three latest values)

Zabbix does not guarantee exact order of values if more than two values exist within one second in history.

The #num parameter is supported since Zabbix 1.6.2.
The time_shift parameter is supported since Zabbix 1.8.2.
logeventid (pattern)
检查最近日志记录的EventID是否匹配正则表达式。 pattern - 正则表达 需要匹配的模式, 支持POSIX extended 类型。 支持值类型: log
<
返回值:
0 - 不匹配
1 - 匹配

从Zabbix 1.8.5开始支持该函数。
Checking if event ID of the last log entry matches a regular expression. pattern - regular expression describing the required pattern, Perl Compatible Regular Expression (PCRE) style. Supported value types: log

Returns:
0 - does not match
1 - matches

This function is supported since Zabbix 1.8.5.
logseverity
最近日志记录的日志等级。 支持值类型: l g
<
返回值:
0 - 默认等级
N - 对应的等级 (整数,常用的Windows日志等级: 1 - 信息, 2 - 警告, 4 - 错误, 7 - 审计失败, 8 - 审计成功, 9 - 严重错误, 10 - Verbose).
Zabbix从Windows日志事件中的 Information字段获取日志等级。
Log severity of the last log entry. Supported value types: log

Returns:
0 - default severity
N - severity (integer, useful for Windows event logs: 1 - Information, 2 - Warning, 4 - Error, 7 - Failure Audit, 8 - Success Audit, 9 - Critical, 10 - Verbose).
Zabbix takes log severity from Information field of Windows event log.
logsource (pattern)
检查最近的日志记录是否匹配参数指定的日志来源。 pattern - string类型 支持值类型: log
<
返回值:
0 - 不匹配
1 - 匹配
通常用于Windows日志事件。 例如, logsource("VMware Server").
Checking if log source of the last log entry matches parameter. pattern - required string Supported value types: log

Returns:
0 - does not match
1 - matches
Normally used for Windows event logs. For example, logsource("VMware Server").
max (sec|#num,<time_shift>)
指定评估期内一个item的最大值。 sec or * #num** - 评估期以多少秒或最新值个数(个数跟在#号后)表示  支持值类型: float, int
time_shift (可选) - 参考avg()函数
<从Zabbix 1.8.2开始支持 time_shift 参数。
Highest value of an item within the defined evaluation period. sec or #num - evaluation period in seconds or in latest collected values (preceded by a hash mark)
time_shift (optional) - see avg()
Supported value types: float, int

The time_shift parameter is supported since Zabbix 1.8.2.
min (sec|#num,<time_shift>)
指定评估期内一个item的最小值。 sec or * #num** - 评估期以多少秒或最新值个数(个数跟在#号后)表示  支持值类型: float, int
time_shift (可选) - 参考avg()函数
<从Zabbix 1.8.2开始支持 time_shift 参数。
Lowest value of an item within the defined evaluation period. sec or #num - evaluation period in seconds or in latest collected values (preceded by a hash mark)
time_shift (optional) - see avg()
Supported value types: float, int

The time_shift parameter is supported since Zabbix 1.8.2.
nodata (sec)
检查评估期内是否接收到数据。 sec - 评估期 单位为秒。  支持值类型: any
评估期不应该少于30秒,因为timer处理器每30秒调用一次该函数。 

nodata(0) 不被允许. 1 -
<返回值:
指定评估期没有接收到数据
0 - 其它

注意,如果在第一个参数指定的时间内出现以下问题,该函数会报错:
- Zabbix server被重启
- 刚出维护期
- item被添加或重新激活
- 错误显示在触发器配置界面Info 列。
Checking for no data received. sec - evaluation period in seconds.
The period should not be less than 30 seconds because the timer process calculates this function only every 30 seconds.

nodata(0) is disallowed.
Supported value types: any

Returns:
1 - if no data received during the defined period of time
0 - otherwise

Note that this function will display an error if, within the period of the 1st parameter:
- there's no data and Zabbix server was restarted
- there's no data and maintenance was completed
- there's no data and the item was added or re-enabled
Errors are displayed in the Info column in trigger configuration.
now
距离Epoch (00:00:00 UTC, January 1, 1970)的秒数。 支持 的类 : any
Number of seconds since the Epoch (00:00:00 UTC, January 1, 1970). Supported value types: any
percentile (sec|#num,<time_shift>,percentage)
P-th 一段时间的百分值, P (percentage) 做为第三个参数。 sec or **#n m** - 评估期以多少秒或最新值个数(个数跟在#号后)表示  支持值类型: float, int
time_shift (可选) - 参考avg()函数 
percentage - 0 到 100 (包括)之间的浮点数,小数点后最多保留四位 从Zabbix 3.0.0开始支持该函
<。
P-th percentile of a period, where P (percentage) is specified by the third parameter. sec or #num - evaluation period in seconds or in latest collected values (preceded by a hash mark)
time_shift (optional) - see avg()
percentage - a floating-point number between 0 and 100 (inclusive) with up to 4 digits after the decimal point
Supported value types: float, int

This function is supported since Zabbix 3.0.0.
prev
取前一个值。 支持 类型 float, int, str, text, log

返回值和 last(#2)相同。
Previous value. Supported value types: float, int, str, text, log

Returns the same as last(#2).
regexp (pattern,<sec|#num>)
检查最近的值是否匹配正则表达式。 pattern - 正 表达式, 支持POSIX extended 样式。  支持值类型: str, text, log
sec or #num (可选) - 评估期以多少秒或最新值个数(个数跟在#号后)表示。 这种情况下,可能有多个值被处理。
<返回值:
1 - 匹配
0 - 不匹配。如果有多个值被处理,其中有一个值匹配也会返回1。

该函数区分大小写。
Checking if the latest (most recent) value matches regular expression. pattern - regular expression, Perl Compatible Regular Expression (PCRE) style.
sec or #num (optional) - evaluation period in seconds or in latest collected values (preceded by a hash mark). In this case, more than one value may be processed.
Supported value types: str, text, log

Returns:
1 - found
0 - otherwise

If more than one value is processed, '1' is returned if there is at least one matching value.

This function is case-sensitive.
str (pattern,<sec|#num>)
从最新值中查找一个字符串。 pattern string型  支持值类型: str, tsec or #num (可选) - 评估期以多少秒或最新值个数(个数跟在#号后)表示。 这种情况下,可能有多个值被处理。
xt, log
返回值:
1 - 找到
0 - 没找到。如果有多个值被处理,其中有一个值找到也会返回1。

该函数区分大小写。
Finding a string in the latest (most recent) value. pattern - required string
sec or #num (optional) - evaluation period in seconds or in latest collected values (preceded by a hash mark). In this case, more than one value may be processed.
Supported value types: str, text, log

Returns:
1 - found
0 - otherwise

If more than one value is processed, '1' is returned if there is at least one matching value.

This function is case-sensitive.
strlen (sec|#num,<time_shift>)
最新值的字符长度(而不是字节数)。 sec (可省略) or #num - 最新的第N个值  支持值类型: str, text, log
time_shift (可选) - 参考avg()函数
<注意此处的 #num 参数和它在其它函数中的作用不一样。

示例:
=> strlen()(等同于 strlen(#1)) → 最新值的长度
=> strlen(#3) → 最新的第三个值的长度
=> strlen(,1d) → 一天前最新值的长度。

从Zabbix 1.8.4开始支持该函数。
Length of the latest (most recent) value in characters (not bytes). sec (ignored) or #num - the Nth most recent value
time_shift (optional) - see avg()
Supported value types: str, text, log

Take note that #num works differently here than with many other functions.

Examples:
=> strlen()(is equal to strlen(#1)) → length of the latest value
=> strlen(#3) → length of the third most recent value
=> strlen(,1d) → length of the most recent value one day ago.

This function is supported since Zabbix 1.8.4.
sum (sec|#num,<time_shift>)
指定评估期内item值的和。 sec o #num - 评估期以多少秒或最新值个数(个数跟在#号后)表示  支持值类型: float, int
time_shift (可选) - 参考avg()函数
<从Zabbix 1.8.2开始支持 time_shift 参数。
Sum of collected values within the defined evaluation period. sec or #num - evaluation period in seconds or in latest collected values (preceded by a hash mark)
time_shift (optional) - see avg()
Supported value types: float, int

The time_shift parameter is supported since Zabbix 1.8.2.
time
当前时间,以HHMMSS格式表示。 支持值类型: an *

返回值如: 123055
Current time in HHMMSS format. Supported value types: any

Example of returned value: 123055
timeleft (sec|#num,<time_shift>,threshold,<fit>)
item达到定义阀值需要多久时间,单位为秒。 sec or **#nu ** - 评估期以多少秒或最新值个数(个数跟在#号后)表示  支持值类型: float, int
time_shift (可选) - 参考 avg()函数 
threshold - 阀值  如fit (可选) - 参考forecast()函数
<返回值大于 999999999999.9999, 则被设置为999999999999.9999。
如果达不到阀值也将返回值设置为999999999999.9999。

只有在表达式错误时才不可用(错误的item类型,无效的参数),出现错误时返回-1。

示例:
=> timeleft(#10,,0) → 根据最新的十个值计算值达到0需要的时间
=> timeleft(1h,,100) → 根据过去一小时的值计算值达到100需要的时间
=> timeleft(1h,1d,0) → 根据昨天当前时间点前一个小时的值计算值达到0需要的时间
=> timeleft(1h,,200,polynomial2) → 根据过去一小时的值并按照二次多项式方式计算值达到200需要的时间

从Zabbix 3.0.0开始支持该函数。
从Zabbix 3.0.6 和 3.2.2开始支持Unit symbolsthreshold 参数。
通过 predictive trigger functions查看扩展信息。
Time in seconds needed for an item to reach a specified threshold. sec or #num - evaluation period in seconds or in latest collected values specified (preceded by a hash mark)
time_shift (optional) - see avg()
threshold - value to reach
fit (optional) - see forecast()
Supported value types: float, int

If value to return is larger than 999999999999.9999, return value is cropped to 999999999999.9999.

Returns 999999999999.9999 if threshold cannot be reached.

Becomes not supported only if misused in expression (wrong item type, invalid parameters), otherwise returns -1 in case of errors.

Examples:
=> timeleft(#10,,0) → time until item value reaches zero based on last 10 values
=> timeleft(1h,,100) → time until item value reaches 100 based on last hour data
=> timeleft(1h,1d,0) → time until item value reaches 0 based on one hour one day ago
=> timeleft(1h,,200,polynomial2) → time until item reaches 200 based on last hour data and assumption that item behaves like quadratic (second degree) polynomial

This function is supported since Zabbix 3.0.0.
Unit symbols in threshold parameter are supported since Zabbix 3.0.6 and 3.2.2.
See also additional information on predictive trigger functions.
  1. 所有函数返回值都为数值类型。例如,不可能返回字符型数据。
  2. 部分函数不能用于非数值类型数据。
  3. 字符型参数都应该使用双引号。否则,可能会被错误解析。
  4. 所有trigger函数中的sectime_shift参数都必须是数值类型。 时间单位后缀与item的数据类型完全无关。
  1. All functions return numeric values only. Comparison to strings is not supported, for example.
  2. Some of the functions cannot be used for non-numeric parameters!
  3. String arguments should be double quoted. Otherwise, they might get misinterpreted.
  4. For all trigger functions sec and time_shift must be an integer with an optional time unit suffix and has absolutely nothing to do with item's data type.

函数与unsupported item

Functions and unsupported items

从Zabbix 3.2开始, nodata(), date(), dayofmonth(), dayofweek(), now()time() 函数都支持用于unsupported item。 但其他函数都要求用于supported item。

Starting from Zabbix 3.2, nodata(), date(), dayofmonth(), dayofweek(), now() and time() functions are calculated for unsupported items, too. Other functions require that the referenced item is in a supported state.