监控项对象
以下对象直接与item API 相关。
监控项
无法通过 Zabbix API 直接创建、更新或删除 Web 监控项。
监控项对象具有以下属性。
| Property | Type | Description |
|---|---|---|
| itemid | ID | 监控项的 ID。 Property behavior: - 只读 - 更新操作时必需 |
| delay | string | 监控项的更新间隔。 接受秒数或带后缀的时间单位(例如 30s、1m、2h、1d),并且可选地接受一个或多个 自定义间隔,所有项以分号分隔。自定义间隔可以混合使用灵活间隔和计划间隔。 接受用户宏。如果使用,值必须是单个宏。不支持多个宏或宏与文本混用。灵活间隔可以写成两个以斜杠分隔的宏(例如 {$FLEX_INTERVAL}/{$FLEX_PERIOD})。示例: 1h;wd1-5h9-18;{$Macro1}/1-7,00:00-24:00;0/6-7,12:00-24:00;{$Macro2}/{$Macro3}Property behavior: - 如果 type 设置为 "Zabbix agent" (0)、"Simple check" (3)、"Zabbix internal" (5)、"External check" (10)、"Database monitor" (11)、"IPMI agent" (12)、"SSH agent" (13)、"TELNET agent" (14)、"Calculated" (15)、"JMX agent" (16)、"HTTP agent" (19)、"SNMP agent" (20)、"Script" (21)、"Browser" (22),或者 type 设置为 "Zabbix agent (active)" (7) 且 key_ 不包含 "mqtt.get",则必需 |
| hostid | ID | 监控项所属主机或模板的 ID。 Property behavior: - 常量 - 创建操作时必需 |
| interfaceid | ID | 监控项主机接口的 ID。 Property behavior: - 如果监控项属于主机且 type 设置为 "Zabbix agent"、"IPMI agent"、"JMX agent"、"SNMP trap" 或 "SNMP agent",则必需- 如果监控项属于主机且 type 设置为 "Simple check"、"External check"、"SSH agent"、"TELNET agent" 或 "HTTP agent",则支持- 对于发现的对象为只读 |
| key_ | string | 监控项键值。 Property behavior: - 创建操作时必需 - 对于继承对象或发现的对象为只读 |
| name | string | 监控项名称。 支持用户宏。 Property behavior: - 创建操作时必需 - 对于继承对象或发现的对象为只读 |
| name_resolved | string | 已解析用户宏后的监控项名称。 Property behavior: - 只读 |
| type | integer | 监控项类型。 可能的值: 0 - Zabbix agent; 2 - Zabbix trapper; 3 - Simple check; 5 - Zabbix internal; 7 - Zabbix agent (active); 9 - Web item; 10 - External check; 11 - Database monitor; 12 - IPMI agent; 13 - SSH agent; 14 - TELNET agent; 15 - Calculated; 16 - JMX agent; 17 - SNMP trap; 18 - Dependent item; 19 - HTTP agent; 20 - SNMP agent; 21 - Script; 22 - Browser。 Property behavior: - 创建操作时必需 - 对于继承对象或发现的对象为只读 |
| url | string | URL 字符串。 支持用户宏、{HOST.IP}、{HOST.CONN}、{HOST.DNS}、{HOST.HOST}、{HOST.NAME}、{HOST.PORT}、{ITEM.ID}、{ITEM.KEY}。 Property behavior: - 如果 type 设置为 "HTTP agent",则必需- 对于继承对象或发现的对象为只读 |
| value_type | integer | 监控项的信息类型。 可能的值: 0 - numeric float; 1 - character; 2 - log; 3 - numeric unsigned; 4 - text; 5 - binary。 Property behavior: - 创建操作时必需 - 对于继承对象或发现的对象为只读 |
| allow_traps | integer | 允许像 trapper 监控项一样填充值。 0 - (默认) 不允许接收传入数据; 1 - 允许接收传入数据。 Property behavior: - 如果 type 设置为 "HTTP agent",则支持- 对于发现的对象为只读 |
| authtype | integer | 认证方式。 如果 type 设置为 "SSH agent",可能的值:0 - (默认) password; 1 - public key。 如果 type 设置为 "HTTP agent",可能的值:0 - (默认) none; 1 - basic; 2 - NTLM; 3 - Kerberos; 4 - Digest。 Property behavior: - 如果 type 设置为 "SSH agent" 或 "HTTP agent",则支持- 对于继承对象(如果 type 设置为 "HTTP agent")或发现的对象为只读 |
| description | string | 监控项描述。 Property behavior: - 对于发现的对象为只读 |
| error | string | 如果更新监控项值时出现问题,则显示错误文本。 Property behavior: - 只读 |
| flags | integer | 监控项的 来源。 可能的值: 0 - 普通监控项; 4 - 由原型转换而来的监控项。 Property behavior: - 只读 |
| follow_redirects | integer | 轮询数据时是否跟随响应重定向。 可能的值: 0 - 不跟随重定向; 1 - (默认) 跟随重定向。 Property behavior: - 如果 type 设置为 "HTTP agent",则支持- 对于继承对象或发现的对象为只读 |
| headers | array | 执行 HTTP 请求时发送的 headers 数组。 Property behavior: - 如果 type 设置为 "HTTP agent",则支持- 对于继承对象或发现的对象为只读 |
| history | string | 历史数据的保存时长。 也接受用户宏。 默认:31d。 Property behavior: - 对于发现的对象为只读 |
| http_proxy | string | HTTP(S) proxy 连接字符串。 Property behavior: - 如果 type 设置为 "HTTP agent",则支持- 对于继承对象或发现的对象为只读 |
| inventory_link | integer | 由监控项填充的主机库存字段 ID。 有关支持的主机库存字段及其 ID 列表,请参阅 主机库存页面。 默认:0。 Property behavior: - 如果 value_type 设置为 "numeric float"、"character"、"numeric unsigned" 或 "text",则支持- 对于发现的对象为只读 |
| ipmi_sensor | string | IPMI 传感器。 Property behavior: - 如果 type 设置为 "IPMI agent" 且 key_ 未设置为 "ipmi.get",则必需- 如果 type 设置为 "IPMI agent",则支持- 对于继承对象或发现的对象为只读 |
| jmx_endpoint | string | JMX agent 自定义连接字符串。 默认值:service:jmx:rmi:///jndi/rmi://{HOST.CONN}:{HOST.PORT}/jmxrmi Property behavior: - 如果 type 设置为 "JMX agent",则支持- 对于发现的对象为只读 |
| lastclock | timestamp | 监控项值最后更新时间。 默认情况下,仅显示最近 24 小时内的值。您可以通过在 Administration > General 菜单部分更改 Max history display period 参数的值来延长此时间范围。 Property behavior: - 只读 |
| lastns | integer | 监控项值最后更新时间的纳秒部分。 默认情况下,仅显示最近 24 小时内的值。您可以通过在 Administration > General 菜单部分更改 Max history display period 参数的值来延长此时间范围。 Property behavior: - 只读 |
| lastvalue | string | 监控项的最新值。 默认情况下,仅显示最近 24 小时内的值。您可以通过在 Administration > General 菜单部分更改 Max history display period 参数的值来延长此时间范围。 Property behavior: - 只读 |
| logtimefmt | string | 日志条目中的时间格式。 Property behavior: - 如果 value_type 设置为 "log",则支持- 对于继承对象或发现的对象为只读 |
| master_itemid | ID | 主监控项的 ID。 Property behavior: - 如果 type 设置为 "Dependent item",则必需- 对于继承对象或发现的对象为只读 |
| output_format | integer | 是否将响应转换为 JSON。 0 - (默认) 原样存储; 1 - 转换为 JSON。 Property behavior: - 如果 type 设置为 "HTTP agent",则支持- 对于继承对象或发现的对象为只读 |
| params | string | 根据监控项类型而定的附加参数: - SSH agent 和 TELNET agent 监控项的执行脚本; - database monitor 监控项的 SQL 查询; - calculated 监控项的公式; - script 和 browser 监控项的脚本。 Property behavior: - 如果 type 设置为 "Database monitor"、"SSH agent"、"TELNET agent"、"Calculated"、"Script" 或 "Browser",则必需- 对于继承对象(如果 type 设置为 "Script" 或 "Browser")或发现的对象为只读 |
| parameters | object/array | 如果 type 设置为 "Script" 或 "Browser",则为附加参数。由具有 name 和 value 属性的对象数组组成,其中 name 必须唯一。Property behavior: - 如果 type 设置为 "Script" 或 "Browser",则支持- 对于继承对象或发现的对象为只读 |
| password | string | 认证密码。 Property behavior: - 如果 type 设置为 "JMX agent" 且已设置 username,则必需- 如果 type 设置为 "Simple check"、"SSH agent"、"TELNET agent"、"Database monitor" 或 "HTTP agent",则支持- 对于继承对象(如果 type 设置为 "HTTP agent")或发现的对象为只读 |
| post_type | integer | 存储在 posts 属性中的 POST 数据体类型。可能的值: 0 - (默认) 原始数据; 2 - JSON 数据; 3 - XML 数据。 Property behavior: - 如果 type 设置为 "HTTP agent",则支持- 对于继承对象或发现的对象为只读 |
| posts | string | HTTP(S) 请求体数据。 Property behavior: - 如果 type 设置为 "HTTP agent" 且 post_type 设置为 "JSON data" 或 "XML data",则必需- 如果 type 设置为 "HTTP agent" 且 post_type 设置为 "Raw data",则支持- 对于继承对象或发现的对象为只读 |
| prevvalue | string | 监控项的上一个值。 默认情况下,仅显示最近 24 小时内的值。您可以通过在 Administration > General 菜单部分更改 Max history display period 参数的值来延长此时间范围。 Property behavior: - 只读 |
| privatekey | string | 私钥文件名。 Property behavior: - 如果 type 设置为 "SSH agent" 且 authtype 设置为 "public key",则必需- 对于发现的对象为只读 |
| publickey | string | 公钥文件名。 Property behavior: - 如果 type 设置为 "SSH agent" 且 authtype 设置为 "public key",则必需- 对于发现的对象为只读 |
| query_fields | array | 执行 HTTP 请求时发送的 query fields 数组。 Property behavior: - 如果 type 设置为 "HTTP agent",则支持- 对于继承对象或发现的对象为只读 |
| request_method | integer | 请求方法类型。 可能的值: 0 - (默认) GET; 1 - POST; 2 - PUT; 3 - HEAD。 Property behavior: - 如果 type 设置为 "HTTP agent",则支持- 对于继承对象或发现的对象为只读 |
| retrieve_mode | integer | 应存储响应的哪一部分。 如果 request_method 设置为 "GET"、"POST" 或 "PUT",可能的值:0 - (默认) 正文; 1 - 标头; 2 - 同时存储正文和标头。 如果 request_method 设置为 "HEAD",可能的值:1 - 标头。 Property behavior: - 如果 type 设置为 "HTTP agent",则支持- 对于继承对象或发现的对象为只读 |
| snmp_oid | string | SNMP OID。 Property behavior: - 如果 type 设置为 "SNMP agent",则必需- 对于继承对象或发现的对象为只读 |
| ssl_cert_file | string | 公用 SSL 密钥文件路径。 Property behavior: - 如果 type 设置为 "HTTP agent",则支持- 对于继承对象或发现的对象为只读 |
| ssl_key_file | string | 私有 SSL 密钥文件路径。 Property behavior: - 如果 type 设置为 "HTTP agent",则支持- 对于继承对象或发现的对象为只读 |
| ssl_key_password | string | SSL 密钥文件密码。 Property behavior: - 如果 type 设置为 "HTTP agent",则支持- 对于继承对象或发现的对象为只读 |
| state | integer | 监控项状态。 可能的值: 0 - (默认) 正常; 1 - 不受支持。 Property behavior: - 只读 |
| status | integer | 监控项状态。 可能的值: 0 - (默认) 已启用监控项; 1 - 已禁用监控项。 |
| status_codes | string | 所需 HTTP 状态码范围,以逗号分隔。 也支持将用户宏作为逗号分隔列表的一部分。 示例:200,200-{$M},{$M},200-400 Property behavior: - 如果 type 设置为 "HTTP agent",则支持- 对于继承对象或发现的对象为只读 |
| templateid | ID | 父模板监控项的 ID。 提示:使用 hostid 属性指定该监控项所属的模板。Property behavior: - 只读 |
| timeout | string | 监控项数据轮询请求超时时间。 接受秒数或带后缀的时间单位(例如 30s、1m)。也接受用户宏。 可能的取值范围:1-600s。 默认:"" - 使用 proxy/全局设置。 Property behavior: - 如果 type 设置为 "Zabbix agent" (0)、"Simple check" (3) 且 key_ 不以 "vmware." 和 "icmpping" 开头、"Zabbix agent (active)" (7)、"External check" (10)、"Database monitor" (11)、"SSH agent" (13)、"TELNET agent" (14)、"HTTP agent" (19)、"SNMP agent" (20) 且 snmp_oid 以 "walk[" 或 "get[" 开头、"Script" (21)、"Browser" (22),则支持- 对于继承和发现的对象为只读 |
| trapper_hosts | string | 允许的主机。 Property behavior: - 对于发现的对象为只读 - 如果 type 设置为 "Zabbix trapper",或者 type 设置为 "HTTP agent" 且 allow_traps 设置为 "Allow to accept incoming data",则支持 |
| trends | string | 趋势数据的保存时长。 也接受用户宏。 默认:365d。 Property behavior: - 如果 value_type 设置为 "numeric float" 或 "numeric unsigned",则支持- 对于发现的对象为只读 |
| units | string | 值单位。 Property behavior: - 如果 value_type 设置为 "numeric float" 或 "numeric unsigned",则支持- 对于继承对象或发现的对象为只读 |
| username | string | 认证用户名。 Property behavior: - 如果 type 设置为 "SSH agent"、"TELNET agent",或者 type 设置为 "JMX agent" 且已设置 password,则必需- 如果 type 设置为 "Simple check"、"Database monitor" 或 "HTTP agent",则支持- 对于继承对象(如果 type 设置为 "HTTP agent")或发现的对象为只读 |
| uuid | string | 通用唯一标识符,用于将导入的监控项与已存在的监控项关联。如果未提供,则自动生成。 Property behavior: - 如果监控项属于模板,则支持 |
| valuemapid | ID | 关联值映射的 ID。 Property behavior: - 如果 value_type 设置为 "numeric float"、"character" 或 "numeric unsigned",则支持- 对于继承对象或发现的对象为只读 |
| verify_host | integer | 是否验证连接的主机名与主机证书中的名称一致。 可能的值: 0 - (默认) 不验证; 1 - 验证。 Property behavior: - 如果 type 设置为 "HTTP agent",则支持- 对于继承对象或发现的对象为只读 |
| verify_peer | integer | 是否验证主机证书是否可信。 可能的值: 0 - (默认) 不验证; 1 - 验证。 Property behavior: - 如果 type 设置为 "HTTP agent",则支持- 对于继承对象或发现的对象为只读 |
HTTP 标头
标头对象具有以下属性:
HTTP 查询字段
查询字段对象定义了用于指定 URL 参数的名称和值。 它具有以下属性:
监控项标签
监控项标签对象具有以下属性。
监控项预处理
监控项预处理对象具有以下属性。
| Property | Type | Description |
|---|---|---|
| type | integer | 预处理选项类型。 可能的值: 1 - 自定义倍数; 2 - 右侧裁剪; 3 - 左侧裁剪; 4 - 裁剪; 5 - 正则表达式; 6 - 布尔值转十进制; 7 - 八进制转十进制; 8 - 十六进制转十进制; 9 - 简单变更; 10 - 每秒变更; 11 - XML XPath; 12 - JSONPath; 13 - 范围内; 14 - 匹配正则表达式; 15 - 不匹配正则表达式; 16 - 检查 JSON 中的错误; 17 - 检查 XML 中的错误; 18 - 使用正则表达式检查错误; 19 - 丢弃未变化值; 20 - 带心跳的丢弃未变化值; 21 - JavaScript; 22 - Prometheus 模式; 23 - Prometheus 转 JSON; 24 - CSV 转 JSON; 25 - 替换; 26 - 检查不受支持; 27 - XML 转 JSON; 28 - SNMP walk 值; 29 - SNMP walk 转 JSON; 30 - SNMP 获取值。 Property behavior: - required |
| params | string | 预处理选项使用的附加参数。 多个参数之间使用换行符 (\n) 分隔。 如果 type 设置为 "Check unsupported",参数采用 <scope>[\n<pattern>] 语法,其中 pattern 是正则表达式,scope 为以下之一:-1 - 匹配任意错误; \ 0 - 检查错误消息是否匹配 pattern; \ 1 - 检查错误消息是否不匹配 pattern。 Property behavior: - 当 type 设置为 "Custom multiplier" (1), "Right trim" (2), "Left trim" (3), "Trim" (4), "Regular expression" (5), "XML XPath" (11), "JSONPath" (12), "In range" (13), "Matches regular expression" (14), "Does not match regular expression" (15), "Check for error in JSON" (16), "Check for error in XML" (17), "Check for error using regular expression" (18), "Discard unchanged with heartbeat" (20), "JavaScript" (21), "Prometheus pattern" (22), "Prometheus to JSON" (23), "CSV to JSON" (24), "Replace" (25), Check unsupported (26), "SNMP walk value" (28), "SNMP walk to JSON" (29), 或 "SNMP get value" (30) 时为 required |
| error_handler | integer | 预处理步骤失败时使用的操作类型。 可能的值: 0 - 错误消息由 Zabbix 服务器设置; 1 - 丢弃值; 2 - 设置自定义值; 3 - 设置自定义错误消息。 如果 type 设置为 "Check unsupported",可能的值为:1 - 丢弃值; 2 - 设置自定义值; 3 - 设置自定义错误消息。 Property behavior: - 当 type 设置为 "Custom multiplier" (1), "Regular expression" (5), "Boolean to decimal" (6), "Octal to decimal" (7), "Hexadecimal to decimal" (8), "Simple change" (9), "Change per second" (10), "XML XPath" (11), "JSONPath" (12), "In range" (13), "Matches regular expression" (14), "Does not match regular expression" (15), "Check for error in JSON" (16), "Check for error in XML" (17), "Check for error using regular expression" (18), "Prometheus pattern" (22), "Prometheus to JSON" (23), "CSV to JSON" (24), "Check unsupported" (26), "XML to JSON" (27), "SNMP walk value" (28), "SNMP walk to JSON" (29), 或 "SNMP get value" (30) 时为 required |
| error_handler_params | string | 错误处理器参数。 Property behavior: - 当 error_handler 设置为 "Set custom value" 或 "Set custom error message" 时为 required |
以下参数和错误处理器受每种预处理类型支持。
| Preprocessing type | Name | Parameter 1 | Parameter 2 | Parameter 3 | Supported error handlers |
|---|---|---|---|---|---|
| 1 | Custom multiplier | number1, 6 | 0, 1, 2, 3 | ||
| 2 | Right trim | list of characters2 | |||
| 3 | Left trim | list of characters2 | |||
| 4 | Trim | list of characters2 | |||
| 5 | Regular expression | pattern3 | output2 | 0, 1, 2, 3 | |
| 6 | Boolean to decimal | 0, 1, 2, 3 | |||
| 7 | Octal to decimal | 0, 1, 2, 3 | |||
| 8 | Hexadecimal to decimal | 0, 1, 2, 3 | |||
| 9 | Simple change | 0, 1, 2, 3 | |||
| 10 | Change per second | 0, 1, 2, 3 | |||
| 11 | XML XPath | path4 | 0, 1, 2, 3 | ||
| 12 | JSONPath | path4 | 0, 1, 2, 3 | ||
| 13 | In range | min1, 6 | max1, 6 | 0, 1, 2, 3 | |
| 14 | Matches regular expression | pattern3 | 0, 1, 2, 3 | ||
| 15 | Does not match regular expression | pattern3 | 0, 1, 2, 3 | ||
| 16 | Check for error in JSON | path4 | 0, 1, 2, 3 | ||
| 17 | Check for error in XML | path4 | 0, 1, 2, 3 | ||
| 18 | Check for error using regular expression | pattern3 | output2 | 0, 1, 2, 3 | |
| 19 | Discard unchanged | ||||
| 20 | Discard unchanged with heartbeat | seconds5, 6 | |||
| 21 | JavaScript | script2 | |||
| 22 | Prometheus pattern | pattern6, 7 | value, label, function |
output8, 9 | 0, 1, 2, 3 |
| 23 | Prometheus to JSON | pattern6, 7 | 0, 1, 2, 3 | ||
| 24 | CSV to JSON | character2 | character2 | 0,1 | 0, 1, 2, 3 |
| 25 | Replace | search string2 | replacement2 | ||
| 26 | Check unsupported | scope1 | pattern3, 6 | 1, 2, 3 | |
| 27 | XML to JSON | 0, 1, 2, 3 | |||
| 28 | SNMP walk value | OID2 | Format: 0 - Unchanged 1 - UTF-8 from Hex-STRING 2 - MAC from Hex-STRING 3 - Integer from BITS |
0, 1, 2, 3 | |
| 29 | SNMP walk to JSON10 | Field name2 | OID prefix2 | Format: 0 - Unchanged 1 - UTF-8 from Hex-STRING 2 - MAC from Hex-STRING 3 - Integer from BITS |
0, 1, 2, 3 |
| 30 | SNMP get value | Format: 1 - UTF-8 from Hex-STRING 2 - MAC from Hex-STRING 3 - Integer from BITS |
0, 1, 2, 3 | ||
1 浮点数(整数会隐式转换为浮点值)
2 字符串
3 正则表达式
4 JSONPath 或 XML XPath
5 正整数(支持时间后缀,例如 30s、1m、2h、1d)
6 用户宏
7 采用以下语法的 Prometheus 模式:<metric name>{<label name>="<label value>", ...} == <value>。Prometheus 模式的每个组成部分(指标、标签名、标签值和指标值)都可以是用户宏。
8 采用以下语法的 Prometheus 输出:<label name>(如果第二个参数选择了 label,则可以是用户宏)。
9 以下聚合函数之一:sum、min、max、avg、count,如果第二个参数选择了 function。
10 支持多个以换行符分隔的 "Field name,OID prefix,Format records" 记录。