1 Server-proxy 数据交换协议

概述

Server - proxy 数据交换基于 JSON 格式。

请求和响应消息必须以header头部与数据长度开头。

被动代理

配置请求

服务器将第一时间发送一个空的 proxy config 请求。此请求每隔 ProxyConfigFrequency (服务器配置参数) 秒发送一次。

Proxy 以当前 Proxy 版本、会话令牌和配置修改进行响应。服务器以需要更新的配置数据进行响应。

名称值类型描述
server→proxy:
requeststring‘proxy config’
proxy→server:
versionstringProxy 版本 (<major>.<minor>.<build>).
sessionstringProxy 配置会话令牌.
config_revisionnumberProxy 配置修订.
server→proxy:
full_syncnumber1 - 如果发送完整配置数据; 空 - 其他情况 (可选).
dataarray表数据对象.如果配置未更改则为空(可选).
<table>object一个或多个 <table> 对象数据 (可选, 取决于变化).
fieldsarray字段名称数组.
-string字段名称.
dataarray行数组.
-array列数组.
-string,number列值的类型取决于数据库中的列类型.
macro.secretsobjectSecret宏信息,如果vault宏未发生更改,则为空(可选).
config_revisionnumber配置缓存修订 - 与配置数据一起发送 (可选).
del_hostidsarray已删除的hostid数组 (可选).
-number主机标识符.
del_macro_hostidsarray删除的所有宏的hostid数组 (可选).
-number主机标识符.
proxy→server:
responsestring请求成功信息 (‘success’ or ‘failed’).
versionstringProxy版本 (<major>.<minor>.<build>).

例子:

server→proxy:

server→proxy:

  1. {
  2. "request":"proxy config"
  3. }

proxy→server:

  1. {
  2. "version": "7.0.0",
  3. "session": "0033124949800811e5686dbfd9bcea98",
  4. "config_revision": 0
  5. }

server→proxy:

  1. {
  2. "full_sync": 1,
  3. "data": {
  4. "hosts": {
  5. "fields": ["hostid", "host", "status", "ipmi_authtype", "ipmi_privilege", "ipmi_username", "ipmi_password", "name", "tls_connect", "tls_accept", "tls_issuer", "tls_subject", "tls_psk_identity", "tls_psk"],
  6. "data": [
  7. [10084, "Zabbix server", 0, -1, 2, "", "", "Zabbix server", 1, 1, "", "", "", ""]
  8. ]
  9. },
  10. "interface": {
  11. "fields": ["interfaceid", "hostid", "main", "type", "useip", "ip", "dns", "port", "available"],
  12. "data": [
  13. [1, 10084, 1, 1, 1, "127.0.0.1", "", "10053", 1]
  14. ]
  15. },
  16. "interface_snmp": {
  17. "fields": ["interfaceid", "version", "bulk", "community", "securityname", "securitylevel", "authpassphrase", "privpassphrase", "authprotocol", "privprotocol", "contextname"],
  18. "data": []
  19. },
  20. "host_inventory": {
  21. "fields": ["hostid", "type", "type_full", "name", "alias", "os", "os_full", "os_short", "serialno_a", "serialno_b", "tag", "asset_tag", "macaddress_a", "macaddress_b", "hardware", "hardware_full", "software", "software_full", "software_app_a", "software_app_b", "software_app_c", "software_app_d", "software_app_e", "contact", "location", "location_lat", "location_lon", "notes", "chassis", "model", "hw_arch", "vendor", "contract_number", "installer_name", "deployment_status", "url_a", "url_b", "url_c", "host_networks", "host_netmask", "host_router", "oob_ip", "oob_netmask", "oob_router", "date_hw_purchase", "date_hw_install", "date_hw_expiry", "date_hw_decomm", "site_address_a", "site_address_b", "site_address_c", "site_city", "site_state", "site_country", "site_zip", "site_rack", "site_notes", "poc_1_name", "poc_1_email", "poc_1_phone_a", "poc_1_phone_b", "poc_1_cell", "poc_1_screen", "poc_1_notes", "poc_2_name", "poc_2_email", "poc_2_phone_a", "poc_2_phone_b", "poc_2_cell", "poc_2_screen", "poc_2_notes"],
  22. "data": [
  23. [10084, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "56.95387", "24.22067", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]
  24. ]
  25. },
  26. "items": {
  27. "fields": ["itemid", "type", "snmp_oid", "hostid", "key_", "delay", "history", "status", "value_type", "trapper_hosts", "logtimefmt", "params", "ipmi_sensor", "authtype", "username", "password", "publickey", "privatekey", "flags", "interfaceid", "inventory_link", "jmx_endpoint", "master_itemid", "timeout", "url", "query_fields", "posts", "status_codes", "follow_redirects", "post_type", "http_proxy", "headers", "retrieve_mode", "request_method", "output_format", "ssl_cert_file", "ssl_key_file", "ssl_key_password", "verify_peer", "verify_host", "allow_traps"],
  28. "data": [
  29. [44161, 7, "", 10084, "agent.hostmetadata", "10s", "90d", 0, 1, "", "", "", "", 0, "", "", "", "", 0, null, 0, "", null, "3s", "", "", "", "200", 1, 0, "", "", 0, 0, 0, "", "", "", 0, 0, 0],
  30. [44162, 0, "", 10084, "agent.ping", "10s", "90d", 0, 3, "", "", "", "", 0, "", "", "", "", 0, 1, 0, "", null, "3s", "", "", "", "200", 1, 0, "", "", 0, 0, 0, "", "", "", 0, 0, 0]
  31. ]
  32. },
  33. "item_rtdata": {
  34. "fields": ["itemid", "lastlogsize", "mtime"],
  35. "data": [
  36. [44161, 0, 0],
  37. [44162, 0, 0]
  38. ]
  39. },
  40. "item_preproc": {
  41. "fields": ["item_preprocid", "itemid", "step", "type", "params", "error_handler", "error_handler_params"],
  42. "data": []
  43. },
  44. "item_parameter": {
  45. "fields": ["item_parameterid", "itemid", "name", "value"],
  46. "data": []
  47. },
  48. "globalmacro": {
  49. "fields": ["globalmacroid", "macro", "value", "type"],
  50. "data": [
  51. [2, "{$SNMP_COMMUNITY}", "public", 0]
  52. ]
  53. },
  54. "hosts_templates": {
  55. "fields": ["hosttemplateid", "hostid", "templateid", "link_type"],
  56. "data": []
  57. },
  58. "hostmacro": {
  59. "fields": ["hostmacroid", "hostid", "macro", "value", "type", "automatic"],
  60. "data": [
  61. [5676, 10084, "{$M}", "AppID=zabbix_server&Query=Safe=passwordSafe;Object=zabbix:Content", 2, 0]
  62. ]
  63. },
  64. "drules": {
  65. "fields": ["druleid", "name", "iprange", "delay"],
  66. "data": [
  67. [2, "Local network", "127.0.0.1", "10s"]
  68. ]
  69. },
  70. "dchecks": {
  71. "fields": ["dcheckid", "druleid", "type", "key_", "snmp_community", "ports", "snmpv3_securityname", "snmpv3_securitylevel", "snmpv3_authpassphrase", "snmpv3_privpassphrase", "uniq", "snmpv3_authprotocol", "snmpv3_privprotocol", "snmpv3_contextname", "host_source", "name_source"],
  72. "data": [
  73. [2, 2, 9, "system.uname", "", "10052", "", 0, "", "", 0, 0, 0, "", 1, 0]
  74. ]
  75. },
  76. "regexps": {
  77. "fields": ["regexpid", "name"],
  78. "data": [
  79. [1, "File systems for discovery"],
  80. [2, "Network interfaces for discovery"],
  81. [3, "Storage devices for SNMP discovery"],
  82. [4, "Windows service names for discovery"],
  83. [5, "Windows service startup states for discovery"]
  84. ]
  85. },
  86. "expressions": {
  87. "fields": ["expressionid", "regexpid", "expression", "expression_type", "exp_delimiter", "case_sensitive"],
  88. "data": [
  89. [1, 1, "^(btrfs|ext2|ext3|ext4|reiser|xfs|ffs|ufs|jfs|jfs2|vxfs|hfs|apfs|refs|ntfs|fat32|zfs)$", 3, ",", 0],
  90. [3, 3, "^(Physical memory|Virtual memory|Memory buffers|Cached memory|Swap space)$", 4, ",", 1],
  91. [5, 4, "^(MMCSS|gupdate|SysmonLog|clr_optimization_v2.0.50727_32|clr_optimization_v4.0.30319_32)$", 4, ",", 1],
  92. [6, 5, "^(automatic|automatic delayed)$", 3, ",", 1],
  93. [7, 2, "^Software Loopback Interface", 4, ",", 1],
  94. [8, 2, "^(In)?[Ll]oop[Bb]ack[0-9._]*$", 4, ",", 1],
  95. [9, 2, "^NULL[0-9.]*$", 4, ",", 1],
  96. [10, 2, "^[Ll]o[0-9.]*$", 4, ",", 1],
  97. [11, 2, "^[Ss]ystem$", 4, ",", 1],
  98. [12, 2, "^Nu[0-9.]*$", 4, ",", 1]
  99. ]
  100. },
  101. "config": {
  102. "fields": ["configid", "snmptrap_logging", "hk_history_global", "hk_history", "autoreg_tls_accept"],
  103. "data": [
  104. [1, 1, 0, "90d", 1]
  105. ]
  106. },
  107. "httptest": {
  108. "fields": ["httptestid", "name", "delay", "agent", "authentication", "http_user", "http_password", "hostid", "http_proxy", "retries", "ssl_cert_file", "ssl_key_file", "ssl_key_password", "verify_peer", "verify_host"],
  109. "data": []
  110. },
  111. "httptestitem": {
  112. "fields": ["httptestitemid", "httptestid", "itemid", "type"],
  113. "data": []
  114. },
  115. "httptest_field": {
  116. "fields": ["httptest_fieldid", "httptestid", "type", "name", "value"],
  117. "data": []
  118. },
  119. "httpstep": {
  120. "fields": ["httpstepid", "httptestid", "name", "no", "url", "timeout", "posts", "required", "status_codes", "follow_redirects", "retrieve_mode", "post_type"],
  121. "data": []
  122. },
  123. "httpstepitem": {
  124. "fields": ["httpstepitemid", "httpstepid", "itemid", "type"],
  125. "data": []
  126. },
  127. "httpstep_field": {
  128. "fields": ["httpstep_fieldid", "httpstepid", "type", "name", "value"],
  129. "data": []
  130. },
  131. "config_autoreg_tls": {
  132. "fields": ["autoreg_tlsid", "tls_psk_identity", "tls_psk"],
  133. "data": [
  134. [1, "", ""]
  135. ]
  136. }
  137. },
  138. "macro.secrets": {
  139. "AppID=zabbix_server&Query=Safe=passwordSafe;Object=zabbix": {
  140. "Content": "738"
  141. }
  142. },
  143. "config_revision": 2
  144. }

proxy→server:

  1. {
  2. "response": "success",
  3. "version": "7.0.0"
  4. }
数据请求

proxy data 请求用于从代理获取主机接口可用性、历史、发现和自动注册的数据。此请求每隔 ProxyDataFrequency (服务器配置参数)秒发送一次。

名称值类型描述
server→proxy:
requeststring‘proxy data’
proxy→server:
sessionstring数据会话令牌.
interface availabilityarray(可选) 接口可用性数据对象数组.
interfaceidnumber接口标识符.
availablenumber接口可用性:

0, INTERFACEAVAILABLE_UNKNOWN - 未知
1, INTERFACE_AVAILABLE_TRUE - 可用
2, INTERFACE_AVAILABLE_FALSE - 不可用
errorstring接口错误消息或空字符串.
history dataarray(可选) 历史数据对象数组.
itemidnumber监控项标识符.
clocknumber监控项值时间戳 (秒).
nsnumber监控项值时间戳 (纳秒).
valuestring(可选) 监控项值.
idnumber值标识符 (自增id, 在一个数据会话中是唯一的).
timestampnumber(可选) 日志类型监控项的时间戳.
sourcestring(可选) 事件日志监控项源值.
severitynumber(可选) 事件日志监控项严重性值.
eventidnumber(可选) 事件日志监控项事件id值.
statestring(可选) 监控项状态:
0, ITEM_STATE_NORMAL
1, ITEM_STATE_NOTSUPPORTED
lastlogsizenumber(可选) 日志类型监控项最近的日志大小.
mtimenumber(可选) 日志类型监控项的修改时间.
discovery dataarray(可选) 自动发现数据对象数组.
clocknumber自动发现数据时间戳.
druleidnumber自动发现规则id.
dcheckidnumber自动发现检查标识符或自动发现规则数据为空.
typenumber自动发现检查类型:

-1 discovery rule data
0, SVC_SSH - SSH service check
1, SVC_LDAP - LDAP service check
2, SVC_SMTP - SMTP service check
3, SVC_FTP - FTP service check
4, SVC_HTTP - HTTP service check
5, SVC_POP - POP service check
6, SVC_NNTP - NNTP service check
7, SVC_IMAP - IMAP service check
8, SVC_TCP - TCP port availability check
9, SVC_AGENT - Zabbix agent
10, SVC_SNMPv1 - SNMPv1 agent
11, SVC_SNMPv2 - SNMPv2 agent
12, SVC_ICMPPING - ICMP ping
13, SVC_SNMPv3 - SNMPv3 agent
14, SVC_HTTPS - HTTPS service check
15, SVC_TELNET - Telnet availability check
ipstring主机IP地址.
dnsstring主机DNS名称.
portnumber(可选) 服务端口号.
keystring(可选) 用于自动发现检查的监控项键 9 SVC_AGENT
valuestring(可选) 从服务接收的值, 对于大多数服务可以为空.
statusnumber(可选) 服务状态:

0, DOBJECT_STATUS_UP - Service UP
1, DOBJECT_STATUS_DOWN - Service DOWN
auto registrationarray(可选) 自动注册数据对象数组.
clocknumber自动注册数据时间戳.
hoststring主机名.
ipstring(可选) 主机IP地址.
dnsstring(可选) DNS.
portstring(可选) 主机端口.
host_metadatastring(可选) agent发送的主机元数据 (基于HostMetadata或HostMetadataItem agent配置参数).
tasksarray(可选) 任务数组.
typenumber任务类型:

0, ZBX_TM_TASK_PROCESS_REMOTE_COMMAND_RESULT - 远程命令结果
statusnumber远程命令执行状态:

0, ZBX_TM_REMOTE_COMMAND_COMPLETED - 远程命令执行成功
1, ZBX_TM_REMOTE_COMMAND_FAILED - 远程命令失败
errorstring(可选) 错误信息.
parent_taskidnumber父任务ID.
morenumber(可选) 1 - 还有更多历史数据要发送.
clocknumber(可选) 数据传输时间戳 (秒).
nsnumber(可选) 数据传输时间戳 (纳秒).
versionstringProxy 版本 (<major>.<minor>.<build>).
server→proxy:
responsestring请求成功信息 (‘success’ or ‘failed’).
tasksarray(可选) 任务数组.
typenumber任务类型:

1, ZBX_TM_TASK_PROCESS_REMOTE_COMMAND - 远程命令
clocknumber任务创建时间.
ttlnumber任务过期时间(以秒为单位).
commandtypenumber远程命令类型:

0, ZBX_SCRIPT_TYPE_CUSTOM_SCRIPT - 使用自定义脚本
1, ZBX_SCRIPT_TYPE_IPMI - 使用IPMI
2, ZBX_SCRIPT_TYPE_SSH - 使用SSH
3, ZBX_SCRIPT_TYPE_TELNET - 使用Telnet
4, ZBX_SCRIPT_TYPE_GLOBAL_SCRIPT - 使用全局脚本 (目前功能相当于自定义脚本)
commandstring要执行的远程命令.
execute_onnumber自定义脚本的执行目标:

0, ZBX_SCRIPT_EXECUTE_ON_AGENT - 在agent上执行脚本
1, ZBX_SCRIPT_EXECUTE_ON_SERVER - 在server上执行脚本
2, ZBX_SCRIPT_EXECUTE_ON_PROXY - 在proxy上执行脚本
portnumber(可选) Telnet和SSH命令端口.
authtypenumber(可选) SSH命令的身份认证方式.
usernamestring(可选) Telnet和SSH命令的用户名.
passwordstring(可选) Telnet和SSH命令的密码.
publickeystring(可选) SSH命令的公钥.
privatekeystring(可选) SSH命令的私钥.
parent_taskidnumber父任务ID.
hostidnumber目标hostid.

例子:

server→proxy:

  1. {
  2. "request": "proxy data"
  3. }

proxy→server:

  1. {
  2. "session": "12345678901234567890123456789012"
  3. "interface availability": [
  4. {
  5. "interfaceid": 1,
  6. "available": 1,
  7. "error": ""
  8. },
  9. {
  10. "interfaceid": 2,
  11. "available": 2,
  12. "error": "Get value from agent failed: cannot connect to [[127.0.0.1]:10049]: [111] Connection refused"
  13. },
  14. {
  15. "interfaceid": 3,
  16. "available": 1,
  17. "error": ""
  18. },
  19. {
  20. "interfaceid": 4,
  21. "available": 1,
  22. "error": ""
  23. }
  24. ],
  25. "history data":[
  26. {
  27. "itemid":"12345",
  28. "clock":1478609647,
  29. "ns":332510044,
  30. "value":"52956612",
  31. "id": 1
  32. },
  33. {
  34. "itemid":"12346",
  35. "clock":1478609647,
  36. "ns":330690279,
  37. "state":1,
  38. "value":"Cannot find information for this network interface in /proc/net/dev.",
  39. "id": 2
  40. }
  41. ],
  42. "discovery data":[
  43. {
  44. "clock":1478608764,
  45. "drule":2,
  46. "dcheck":3,
  47. "type":12,
  48. "ip":"10.3.0.10",
  49. "dns":"vdebian",
  50. "status":1
  51. },
  52. {
  53. "clock":1478608764,
  54. "drule":2,
  55. "dcheck":null,
  56. "type":-1,
  57. "ip":"10.3.0.10",
  58. "dns":"vdebian",
  59. "status":1
  60. }
  61. ],
  62. "auto registration":[
  63. {
  64. "clock":1478608371,
  65. "host":"Logger1",
  66. "ip":"10.3.0.1",
  67. "dns":"localhost",
  68. "port":"10050"
  69. },
  70. {
  71. "clock":1478608381,
  72. "host":"Logger2",
  73. "ip":"10.3.0.2",
  74. "dns":"localhost",
  75. "port":"10050"
  76. }
  77. ],
  78. "tasks":[
  79. {
  80. "type": 0,
  81. "status": 0,
  82. "parent_taskid": 10
  83. },
  84. {
  85. "type": 0,
  86. "status": 1,
  87. "error": "No permissions to execute task.",
  88. "parent_taskid": 20
  89. }
  90. ],
  91. "version":"7.0.0"
  92. }

server→proxy:

  1. {
  2. "response": "success",
  3. "tasks":[
  4. {
  5. "type": 1,
  6. "clock": 1478608371,
  7. "ttl": 600,
  8. "commandtype": 2,
  9. "command": "restart_service1.sh",
  10. "execute_on": 2,
  11. "port": 80,
  12. "authtype": 0,
  13. "username": "userA",
  14. "password": "password1",
  15. "publickey": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe",
  16. "privatekey": "lsuusFncCzWBQ7RKNUSesmQRMSGkVb1/3j+skZ6UtW+5u09lHNsj6tQ5QCqGKukO1De7zhd",
  17. "parent_taskid": 10,
  18. "hostid": 10070
  19. },
  20. {
  21. "type": 1,
  22. "clock": 1478608381,
  23. "ttl": 600,
  24. "commandtype": 1,
  25. "command": "restart_service2.sh",
  26. "execute_on": 0,
  27. "authtype": 0,
  28. "username": "",
  29. "password": "",
  30. "publickey": "",
  31. "privatekey": "",
  32. "parent_taskid": 20,
  33. "hostid": 10084
  34. }
  35. ]
  36. }

主动代理

配置请求

主动 proxy 发送 proxy config 请求获取proxy配置数据。此请求每隔 ProxyConfigFrequency (proxy配置参数) 秒发送一次.

名称值类型描述
proxy→server:
requeststring‘proxy config’
hoststring
Proxy名称.
versionstringProxy版本 (<major>.<minor>.<build>).
sessionstringProxy配置会话令牌.
config_revisionnumberProxy配置修订.
server→proxy:
fullsyncnumber1 - 如果发送完整的配置数据, 否则为空 (可选).
dataarray表数据对象. 如果配置数据未发生变化则为空 (可选).
<table>object一个或多个 <table> 数据对象 (可选, 取决于变化).
fieldsarray字段名称数组.
-string字段名称.
dataarray行数组.
-array列数组.
-string,number列值的类型取决于数据库模式中的列类型.
macro.secretsobjectSecret宏信息, 如果在vault宏中未发生变化则为空 (可选).
config_revisionnumber配置缓存修订 - 与配置数据一起发送 (可选).
del_hostidsarray已删除的hostid数组 (可选).
-number主机标识符.
del_macro_hostidsarray删除所有宏的主机id数组 (可选).
-number主机标识符.

例子:

proxy→server:

  1. {
  2. "request": "proxy config",
  3. "host": "Zabbix proxy",
  4. "version":"7.0.0",
  5. "session": "fd59a09ff4e9d1fb447de1f04599bcf6",
  6. "config_revision": 0
  7. }

server→proxy:

  1. {
  2. "full_sync": 1,
  3. "data": {
  4. "hosts": {
  5. "fields": ["hostid", "host", "status", "ipmi_authtype", "ipmi_privilege", "ipmi_username", "ipmi_password", "name", "tls_connect", "tls_accept", "tls_issuer", "tls_subject", "tls_psk_identity", "tls_psk"],
  6. "data": [
  7. [10084, "Zabbix server", 0, -1, 2, "", "", "Zabbix server", 1, 1, "", "", "", ""]
  8. ]
  9. },
  10. "interface": {
  11. "fields": ["interfaceid", "hostid", "main", "type", "useip", "ip", "dns", "port", "available"],
  12. "data": [
  13. [1, 10084, 1, 1, 1, "127.0.0.1", "", "10053", 1]
  14. ]
  15. },
  16. "interface_snmp": {
  17. "fields": ["interfaceid", "version", "bulk", "community", "securityname", "securitylevel", "authpassphrase", "privpassphrase", "authprotocol", "privprotocol", "contextname"],
  18. "data": []
  19. },
  20. "host_inventory": {
  21. "fields": ["hostid", "type", "type_full", "name", "alias", "os", "os_full", "os_short", "serialno_a", "serialno_b", "tag", "asset_tag", "macaddress_a", "macaddress_b", "hardware", "hardware_full", "software", "software_full", "software_app_a", "software_app_b", "software_app_c", "software_app_d", "software_app_e", "contact", "location", "location_lat", "location_lon", "notes", "chassis", "model", "hw_arch", "vendor", "contract_number", "installer_name", "deployment_status", "url_a", "url_b", "url_c", "host_networks", "host_netmask", "host_router", "oob_ip", "oob_netmask", "oob_router", "date_hw_purchase", "date_hw_install", "date_hw_expiry", "date_hw_decomm", "site_address_a", "site_address_b", "site_address_c", "site_city", "site_state", "site_country", "site_zip", "site_rack", "site_notes", "poc_1_name", "poc_1_email", "poc_1_phone_a", "poc_1_phone_b", "poc_1_cell", "poc_1_screen", "poc_1_notes", "poc_2_name", "poc_2_email", "poc_2_phone_a", "poc_2_phone_b", "poc_2_cell", "poc_2_screen", "poc_2_notes"],
  22. "data": [
  23. [10084, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "56.95387", "24.22067", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]
  24. ]
  25. },
  26. "items": {
  27. "fields": ["itemid", "type", "snmp_oid", "hostid", "key_", "delay", "history", "status", "value_type", "trapper_hosts", "logtimefmt", "params", "ipmi_sensor", "authtype", "username", "password", "publickey", "privatekey", "flags", "interfaceid", "inventory_link", "jmx_endpoint", "master_itemid", "timeout", "url", "query_fields", "posts", "status_codes", "follow_redirects", "post_type", "http_proxy", "headers", "retrieve_mode", "request_method", "output_format", "ssl_cert_file", "ssl_key_file", "ssl_key_password", "verify_peer", "verify_host", "allow_traps"],
  28. "data": [
  29. [44161, 7, "", 10084, "agent.hostmetadata", "10s", "90d", 0, 1, "", "", "", "", 0, "", "", "", "", 0, null, 0, "", null, "3s", "", "", "", "200", 1, 0, "", "", 0, 0, 0, "", "", "", 0, 0, 0],
  30. [44162, 0, "", 10084, "agent.ping", "10s", "90d", 0, 3, "", "", "", "", 0, "", "", "", "", 0, 1, 0, "", null, "3s", "", "", "", "200", 1, 0, "", "", 0, 0, 0, "", "", "", 0, 0, 0]
  31. ]
  32. },
  33. "item_rtdata": {
  34. "fields": ["itemid", "lastlogsize", "mtime"],
  35. "data": [
  36. [44161, 0, 0],
  37. [44162, 0, 0]
  38. ]
  39. },
  40. "item_preproc": {
  41. "fields": ["item_preprocid", "itemid", "step", "type", "params", "error_handler", "error_handler_params"],
  42. "data": []
  43. },
  44. "item_parameter": {
  45. "fields": ["item_parameterid", "itemid", "name", "value"],
  46. "data": []
  47. },
  48. "globalmacro": {
  49. "fields": ["globalmacroid", "macro", "value", "type"],
  50. "data": [
  51. [2, "{$SNMP_COMMUNITY}", "public", 0]
  52. ]
  53. },
  54. "hosts_templates": {
  55. "fields": ["hosttemplateid", "hostid", "templateid", "link_type"],
  56. "data": []
  57. },
  58. "hostmacro": {
  59. "fields": ["hostmacroid", "hostid", "macro", "value", "type", "automatic"],
  60. "data": [
  61. [5676, 10084, "{$M}", "AppID=zabbix_server&Query=Safe=passwordSafe;Object=zabbix:Content", 2, 0]
  62. ]
  63. },
  64. "drules": {
  65. "fields": ["druleid", "name", "iprange", "delay"],
  66. "data": [
  67. [2, "Local network", "127.0.0.1", "10s"]
  68. ]
  69. },
  70. "dchecks": {
  71. "fields": ["dcheckid", "druleid", "type", "key_", "snmp_community", "ports", "snmpv3_securityname", "snmpv3_securitylevel", "snmpv3_authpassphrase", "snmpv3_privpassphrase", "uniq", "snmpv3_authprotocol", "snmpv3_privprotocol", "snmpv3_contextname", "host_source", "name_source"],
  72. "data": [
  73. [2, 2, 9, "system.uname", "", "10052", "", 0, "", "", 0, 0, 0, "", 1, 0]
  74. ]
  75. },
  76. "regexps": {
  77. "fields": ["regexpid", "name"],
  78. "data": [
  79. [1, "File systems for discovery"],
  80. [2, "Network interfaces for discovery"],
  81. [3, "Storage devices for SNMP discovery"],
  82. [4, "Windows service names for discovery"],
  83. [5, "Windows service startup states for discovery"]
  84. ]
  85. },
  86. "expressions": {
  87. "fields": ["expressionid", "regexpid", "expression", "expression_type", "exp_delimiter", "case_sensitive"],
  88. "data": [
  89. [1, 1, "^(btrfs|ext2|ext3|ext4|reiser|xfs|ffs|ufs|jfs|jfs2|vxfs|hfs|apfs|refs|ntfs|fat32|zfs)$", 3, ",", 0],
  90. [3, 3, "^(Physical memory|Virtual memory|Memory buffers|Cached memory|Swap space)$", 4, ",", 1],
  91. [5, 4, "^(MMCSS|gupdate|SysmonLog|clr_optimization_v2.0.50727_32|clr_optimization_v4.0.30319_32)$", 4, ",", 1],
  92. [6, 5, "^(automatic|automatic delayed)$", 3, ",", 1],
  93. [7, 2, "^Software Loopback Interface", 4, ",", 1],
  94. [8, 2, "^(In)?[Ll]oop[Bb]ack[0-9._]*$", 4, ",", 1],
  95. [9, 2, "^NULL[0-9.]*$", 4, ",", 1],
  96. [10, 2, "^[Ll]o[0-9.]*$", 4, ",", 1],
  97. [11, 2, "^[Ss]ystem$", 4, ",", 1],
  98. [12, 2, "^Nu[0-9.]*$", 4, ",", 1]
  99. ]
  100. },
  101. "config": {
  102. "fields": ["configid", "snmptrap_logging", "hk_history_global", "hk_history", "autoreg_tls_accept"],
  103. "data": [
  104. [1, 1, 0, "90d", 1]
  105. ]
  106. },
  107. "httptest": {
  108. "fields": ["httptestid", "name", "delay", "agent", "authentication", "http_user", "http_password", "hostid", "http_proxy", "retries", "ssl_cert_file", "ssl_key_file", "ssl_key_password", "verify_peer", "verify_host"],
  109. "data": []
  110. },
  111. "httptestitem": {
  112. "fields": ["httptestitemid", "httptestid", "itemid", "type"],
  113. "data": []
  114. },
  115. "httptest_field": {
  116. "fields": ["httptest_fieldid", "httptestid", "type", "name", "value"],
  117. "data": []
  118. },
  119. "httpstep": {
  120. "fields": ["httpstepid", "httptestid", "name", "no", "url", "timeout", "posts", "required", "status_codes", "follow_redirects", "retrieve_mode", "post_type"],
  121. "data": []
  122. },
  123. "httpstepitem": {
  124. "fields": ["httpstepitemid", "httpstepid", "itemid", "type"],
  125. "data": []
  126. },
  127. "httpstep_field": {
  128. "fields": ["httpstep_fieldid", "httpstepid", "type", "name", "value"],
  129. "data": []
  130. },
  131. "config_autoreg_tls": {
  132. "fields": ["autoreg_tlsid", "tls_psk_identity", "tls_psk"],
  133. "data": [
  134. [1, "", ""]
  135. ]
  136. }
  137. },
  138. "macro.secrets": {
  139. "AppID=zabbix_server&Query=Safe=passwordSafe;Object=zabbix": {
  140. "Content": "738"
  141. }
  142. },
  143. "config_revision": 2
  144. }
数据请求

proxy data 请求由 proxy 发送,以提供主机接口可用性、历史、发现和自动注册的数据. 此请求每隔 DataSenderFrequency ( proxy 配置参数) 秒发送一次. 注意主动 proxy 仍会每秒轮询 Zabbix server 以获取远程命令任务 (使用空的proxy data 请求).

名称值类型描述
proxy→server:
requeststring‘proxy data’
hoststringProxy名称.
sessionstring数据会话令牌.
interface availabilityarray(可选) 接口可用性数据对象数组.
interfaceidnumber接口标识符.
availablenumber接口可用性:

0, INTERFACEAVAILABLE_UNKNOWN - 未知
1, INTERFACE_AVAILABLE_TRUE - 可用
2, INTERFACE_AVAILABLE_FALSE - 不可用
errorstring接口错误消息或空字符串.
history dataarray(可选) 历史数据对象数组.
itemidnumber监控项标识符.
clocknumber监控项值时间戳 (秒).
nsnumber监控项值时间戳 (纳秒).
valuestring(可选) 监控项值.
idnumber值标识符 (自增id, 在一个数据会话中是唯一的).
timestampnumber(可选) 日志类型监控项的时间戳.
sourcestring(可选) 事件日志监控项源值.
severitynumber(可选) 事件日志监控项严重性值.
eventidnumber(可选) 事件日志监控项事件id值.
statestring(可选) 监控项状态:
0, ITEM_STATE_NORMAL
1, ITEM_STATE_NOTSUPPORTED
lastlogsizenumber(可选) 日志类型监控项最近的日志大小.
mtimenumber(可选) 日志类型监控项的修改时间.
discovery dataarray(可选) 自动发现数据对象数组.
clocknumber自动发现数据时间戳.
druleidnumber自动发现规则id.
dcheckidnumber自动发现检查标识符或自动发现规则数据为空.
typenumber自动发现检查类型:

-1 discovery rule data
0, SVC_SSH - SSH service check
1, SVC_LDAP - LDAP service check
2, SVC_SMTP - SMTP service check
3, SVC_FTP - FTP service check
4, SVC_HTTP - HTTP service check
5, SVC_POP - POP service check
6, SVC_NNTP - NNTP service check
7, SVC_IMAP - IMAP service check
8, SVC_TCP - TCP port availability check
9, SVC_AGENT - Zabbix agent
10, SVC_SNMPv1 - SNMPv1 agent
11, SVC_SNMPv2 - SNMPv2 agent
12, SVC_ICMPPING - ICMP ping
13, SVC_SNMPv3 - SNMPv3 agent
14, SVC_HTTPS - HTTPS service check
15, SVC_TELNET - Telnet availability check
ipstring主机IP地址.
dnsstring主机DNS名称.
portnumber(可选) 服务端口号.
keystring(可选) 用于自动发现检查的监控项键 9 SVC_AGENT
valuestring(可选) 从服务接收的值, 对于大多数服务可以为空.
statusnumber(可选) 服务状态:

0, DOBJECT_STATUS_UP - Service UP
1, DOBJECT_STATUS_DOWN - Service DOWN
autoregistrationarray(可选) 自动注册数据对象数组.
clocknumber自动注册数据时间戳.
hoststring主机名.
ipstring(可选) 主机IP地址.
dnsstring(可选) 主机DNS名称.
portstring(可选) 主机端口.
host_metadatastring(可选) agent发送的主机元数据 (基于HostMetadata或HostMetadataItem agent配置参数).
tasksarray(可选) 任务数组.
typenumber任务类型:

0, ZBX_TM_TASK_PROCESS_REMOTE_COMMAND_RESULT - 远程命令结果
statusnumber远程命令执行状态:

0, ZBX_TM_REMOTE_COMMAND_COMPLETED - 远程命令执行成功
1, ZBX_TM_REMOTE_COMMAND_FAILED - 远程命令失败
errorstring(可选) 错误信息.
parent_taskidnumber父任务ID.
morenumber(可选) 1 - 还有更多历史数据要发送
clocknumber(可选) 数据传输时间戳 (秒).
nsnumber(optional) 数据传输时间戳 (纳秒).
versionstringProxy版本 (<major>.<minor>.<build>).
server→proxy:
responsestring请求成功信息 (‘success’ or ‘failed’).
uploadstring历史数据的上传控制(历史、自动注册、主机可用性、网络自动发现).

可能的值:
enabled - 正常操作
disabled - 服务器不接受数据(可能是由于内部缓存超出限制)
tasksarray(可选) 任务数组.
typenumber任务类型:

1, ZBX_TM_TASK_PROCESS_REMOTE_COMMAND - 远程命令
clocknumber任务创建时间.
ttlnumber任务过期时间(以秒为单位).
commandtypenumber远程命令类型:

0, ZBX_SCRIPT_TYPE_CUSTOM_SCRIPT - 使用自定义脚本
1, ZBX_SCRIPT_TYPE_IPMI - 使用IPMI
2, ZBX_SCRIPT_TYPE_SSH - 使用SSH
3, ZBX_SCRIPT_TYPE_TELNET - 使用Telnet
4, ZBX_SCRIPT_TYPE_GLOBAL_SCRIPT - 使用全局脚本 (目前功能相当于自定义脚本)
commandstring要执行的远程命令.
execute_onnumber自定义脚本的执行目标:

0, ZBX_SCRIPT_EXECUTE_ON_AGENT - 在agent上执行脚本
1, ZBX_SCRIPT_EXECUTE_ON_SERVER - 在server上执行脚本
2, ZBX_SCRIPT_EXECUTE_ON_PROXY - 在proxy上执行脚本
portnumber(可选) Telnet和SSH命令端口.
authtypenumber(可选) SSH命令的身份认证方式.
usernamestring(可选) Telnet和SSH命令的用户名.
passwordstring(可选) Telnet和SSH命令的密码.
publickeystring(可选) SSH命令的公钥.
privatekeystring(可选) SSH命令的私钥.
parent_taskidnumber父任务ID.
hostidnumber目标hostid.

例子:

proxy→server:

  1. {
  2. "request": "proxy data",
  3. "host": "Zabbix proxy",
  4. "session": "818cdd1b537bdc5e50c09ed4969235b6",
  5. "interface availability": [{
  6. "interfaceid": 1,
  7. "available": 1,
  8. "error": ""
  9. }],
  10. "history data": [{
  11. "id": 1114,
  12. "itemid": 44162,
  13. "clock": 1665730632,
  14. "ns": 798953105,
  15. "value": "1"
  16. }, {
  17. "id": 1115,
  18. "itemid": 44161,
  19. "clock": 1665730633,
  20. "ns": 811684663,
  21. "value": "58"
  22. }],
  23. "auto registration": [{
  24. "clock": 1665730633,
  25. "host": "Zabbix server",
  26. "ip": "127.0.0.1",
  27. "dns": "localhost",
  28. "port": "10053",
  29. "host_metadata": "58",
  30. "tls_accepted": 1
  31. }],
  32. "discovery data": [{
  33. "clock": 1665732232,
  34. "drule": 2,
  35. "dcheck": 2,
  36. "ip": "127.0.0.1",
  37. "dns": "localhost",
  38. "port": 10052,
  39. "status": 1
  40. }, {
  41. "clock": 1665732232,
  42. "drule": 2,
  43. "dcheck": null,
  44. "ip": "127.0.0.1",
  45. "dns": "localhost",
  46. "status": 1
  47. }],
  48. "host data": [{
  49. "hostid": 10084,
  50. "active_status": 1
  51. }],
  52. "tasks": [{
  53. "type": 3,
  54. "clock": 1665730985,
  55. "ttl": 0,
  56. "status": -1,
  57. "info": "Remote commands are not enabled",
  58. "parent_taskid": 3
  59. }],
  60. "version": "7.0.0",
  61. "clock": 1665730643,
  62. "ns": 65389964
  63. }

server→proxy:

  1. {
  2. "upload": "enabled",
  3. "response": "success",
  4. "tasks": [{
  5. "type": 2,
  6. "clock": 1665730986,
  7. "ttl": 600,
  8. "commandtype": 0,
  9. "command": "ping -c 3 127.0.0.1; case $? in [01]) true;; *) false;; esac",
  10. "execute_on": 2,
  11. "port": 0,
  12. "authtype": 0,
  13. "username": "",
  14. "password": "",
  15. "publickey": "",
  16. "privatekey": "",
  17. "alertid": 0,
  18. "parent_taskid": 4,
  19. "hostid": 10084
  20. }]
  21. }