此处列出的所有函数均支持以下场景:
关于函数参数的通用说明:
<
>
标识函数 | ||
---|---|---|
Description | 函数特定参数 | 说明 |
ascii (value) | ||
The ASCII code of the leftmost character of the value. | value - 待检查值 | 支持值类型:string、文本、日志 例如:'Abc'将返回'65'('A'的ASCII码) 示例: => ascii(last(/主机/key)) |
bitlength (value) | ||
The length of value in bits. | value - 待检查值 | 支持值类型:string、文本、日志、integer 示例: => bitlength(last(/主机/key)) |
bytelength (value) | ||
The length of value in bytes. | value - 待检查值 | 支持值类型:string、文本、日志、integer 示例: => bytelength(last(/主机/key)) |
char (value) | ||
Return the character by interpreting the value as ASCII code. | value - 待检查值 | 支持值类型:integer 值必须在0-255范围内。例如:'65'(作为ASCII码解析)将返回'A' 示例: => char(last(/主机/key)) |
concat (<value1>,<value2>,...) | ||
The string resulting from concatenating referenced item values or constant values. | value - 历史函数返回值或常量值(string、integer或float数字) | 支持值类型:string、文本、日志、float、integer 例如:将'Zab'与常量string'bix'连接将返回'Zabbix' 必须包含至少两个参数 示例: => concat(last(/主机/key),"bix") => concat("1 min: ",last(/主机/system.cpu.load[all,avg1]),", 15 min: ",last(/主机/system.cpu.load[all,avg15])) |
insert (value,start,length,replacement) | ||
Insert specified characters or spaces into the character string beginning at the specified position in the string. | value - 待检查值 start - 起始位置 length - 替换长度 replacement - 替换string |
支持值类型:string、文本、日志 例如:'Zabbbix'在起始位置3、替换长度2时将'bb'替换为'b'得到'Zabbix' 示例: => insert(last(/主机/key),3,2,"b") |
left (value,count) | ||
The leftmost characters of the value. | value - 待检查值 count - 返回字符数 |
支持值类型:string、文本、日志 例如:指定3个最左字符可从'Zabbix'返回'Zab' 示例: => left(last(/主机/key),3) - 返回最左三个字符 另见right() |
length (value) | ||
The length of value in characters. | value - 待检查值 | 支持值类型:字符串、文本、日志 示例: => length(last(/主机/key)) → 最新值长度 => length(last(/主机/key,#3)) → 倒数第三个值长度 => length(last(/主机/key,#1:now-1d)) → 一天前最新值长度 |
ltrim (value,<chars>) | ||
Remove specified characters from the beginning of string. | value - 待检查值 chars - (可选)指定移除字符 默认移除左侧空白(未指定可选字符时) |
支持值类型:string、文本、日志 示例: => ltrim(last(/主机/key)) - 移除string开头空白 => ltrim(last(/主机/key),"Z") - 移除开头所有'Z' => ltrim(last(/主机/key)," Z") - 移除开头所有空格和'Z' 另见:rtrim()、trim() |
mid (value,start,length) | ||
Return a substring of N characters beginning at the character position specified by 'start'. | value - 待检查值 start - 子串起始位置 length - 子串返回长度 |
支持值类型:string、文本、日志 例如:从'Zabbix'中起始位置2、返回长度4可得到'abbi' 示例: => mid(last(/主机/key),2,4)="abbi" |
repeat (value,count) | ||
Repeat a string. | value - 待检查值 count - 重复次数 |
支持值类型:string、文本、日志 示例: => repeat(last(/主机/key),2) - 重复值两次 |
replace (value,pattern,replacement) | ||
Find pattern in the value and replace with replacement. All occurrences of the pattern will be replaced. | value - 待检查值 pattern - 查找模式 replacement - 替换string |
支持值类型:string、文本、日志 示例: => replace(last(/主机/key),"ibb","abb") - 将所有'ibb'替换为'abb' |
right (value,count) | ||
The rightmost characters of the value. | value - 待检查值 count - 返回字符数 |
支持值类型:string、文本、日志 例如:指定3个最右字符可从'Zabbix'返回'bix' 示例: => right(last(/主机/key),3) - 返回最右三个字符 另见left() |
rtrim (value,<chars>) | ||
Remove specified characters from the end of string. | value - 待检查值 chars - (可选)指定移除字符 默认移除右侧空白(未指定可选字符时) |
支持值类型:string、文本、日志 示例: => rtrim(last(/主机/key)) - 移除string末尾空白 => rtrim(last(/主机/key),"x") - 移除末尾所有'x' => rtrim(last(/主机/key),"x ") - 移除末尾所有'x'或空格 另见:ltrim()、trim() |
trim (value,<chars>) | ||
Remove specified characters from the beginning and end of string. | value - 待检查值 chars - (可选)指定移除字符 默认移除两侧空白(未指定可选字符时) |
支持值类型:string、文本、日志 示例: => trim(last(/主机/key)) - 移除string首尾空白 => trim(last(/主机/key),"_") - 移除首尾所有'_' 另见:ltrim()、rtrim() |