1 Server-proxy 数据交换协议

概述

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

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

被动代理

配置请求

服务器将首先发送一个空的 proxy config 请求。该请求每隔 ProxyConfigFrequency (服务器配置参数)秒发送一次。

proxy 会响应当前 proxy 版本、会话令牌和配置修订版本。服务器则响应需要更新的配置数据。

name value type description
server→proxy:
request string 'proxy config'
proxy→server:
version string Proxy 版本 (<major>.<minor>.<build>)。
session string Proxy 配置会话令牌。
config_revision number Proxy 配置修订版本。
server→proxy:
full_sync number 1 - 如果发送的是完整配置数据;否则不存在(可选)。
data array 表数据对象。如果配置未更改则不存在(可选)。
<table> object 一个或多个包含 <table> 数据的对象(可选,取决于变更)。
fields array 字段名称数组。
- string 字段名称。
data array 行数组。
- array 列数组。
- string,number 列值,其类型取决于数据库模式中的列类型。
macro.secrets object 密钥宏信息,如果 vault 宏没有变化则不存在(可选)。
config_revision number 配置缓存修订版本 - 与配置数据一起发送(可选)。
del_hostids array 已删除 hostid 的数组(可选)。
- number 主机标识符。
del_macro_hostids array 其所有宏均已删除的 hostid 数组(可选)。
- number 主机标识符。
proxy→server:
response string 请求成功信息('success' 或 'failed')。
version string Proxy 版本 (<major>.<minor>.<build>)。

示例:

server→proxy:

{
  "request":"proxy config"
} 

proxy→server:

{
  "version": "8.0.0",
  "session": "0033124949800811e5686dbfd9bcea98",
  "config_revision": 0
}

server→proxy:

{
    "full_sync": 1,
    "data": {
        "hosts": {
            "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"],
            "data": [
                [10084, "Zabbix server", 0, -1, 2, "", "", "Zabbix server", 1, 1, "", "", "", ""]
            ]
        },
        "interface": {
            "fields": ["interfaceid", "hostid", "main", "type", "useip", "ip", "dns", "port", "available"],
            "data": [
                [1, 10084, 1, 1, 1, "127.0.0.1", "", "10053", 1]
            ]
        },
        "interface_snmp": {
            "fields": ["interfaceid", "version", "bulk", "community", "securityname", "securitylevel", "authpassphrase", "privpassphrase", "authprotocol", "privprotocol", "contextname"],
            "data": []
        },
        "host_inventory": {
            "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"],
            "data": [
                [10084, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "56.95387", "24.22067", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]
            ]
        },
        "items": {
            "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"],
            "data": [
                [44161, 7, "", 10084, "agent.hostmetadata", "10s", "90d", 0, 1, "", "", "", "", 0, "", "", "", "", 0, null, 0, "", null, "3s", "", "", "", "200", 1, 0, "", "", 0, 0, 0, "", "", "", 0, 0, 0],
                [44162, 0, "", 10084, "agent.ping", "10s", "90d", 0, 3, "", "", "", "", 0, "", "", "", "", 0, 1, 0, "", null, "3s", "", "", "", "200", 1, 0, "", "", 0, 0, 0, "", "", "", 0, 0, 0]
            ]
        },
        "item_rtdata": {
            "fields": ["itemid", "lastlogsize", "mtime"],
            "data": [
                [44161, 0, 0],
                [44162, 0, 0]
            ]
        },
        "item_preproc": {
            "fields": ["item_preprocid", "itemid", "step", "type", "params", "error_handler", "error_handler_params"],
            "data": []
        },
        "item_parameter": {
            "fields": ["item_parameterid", "itemid", "name", "value"],
            "data": []
        },
        "globalmacro": {
            "fields": ["globalmacroid", "macro", "value", "type"],
            "data": [
                [2, "{$SNMP_COMMUNITY}", "public", 0]
            ]
        },
        "hosts_templates": {
            "fields": ["hosttemplateid", "hostid", "templateid", "link_type"],
            "data": []
        },
        "hostmacro": {
            "fields": ["hostmacroid", "hostid", "macro", "value", "type", "automatic"],
            "data": [
                [5676, 10084, "{$M}", "AppID=zabbix_server&Query=Safe=passwordSafe;Object=zabbix:Content", 2, 0]
            ]
        },
        "drules": {
            "fields": ["druleid", "name", "iprange", "delay"],
            "data": [
                [2, "Local network", "127.0.0.1", "10s"]
            ]
        },
        "dchecks": {
            "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"],
            "data": [
                [2, 2, 9, "system.uname", "", "10052", "", 0, "", "", 0, 0, 0, "", 1, 0]
            ]
        },
        "regexps": {
            "fields": ["regexpid", "name"],
            "data": [
                [1, "File systems for discovery"],
                [2, "Network interfaces for discovery"],
                [3, "Storage devices for SNMP discovery"],
                [4, "Windows service names for discovery"],
                [5, "Windows service startup states for discovery"]
            ]
        },
        "expressions": {
            "fields": ["expressionid", "regexpid", "expression", "expression_type", "exp_delimiter", "case_sensitive"],
            "data": [
                [1, 1, "^(btrfs|ext2|ext3|ext4|reiser|xfs|ffs|ufs|jfs|jfs2|vxfs|hfs|apfs|refs|ntfs|fat32|zfs)$", 3, ",", 0],
                [3, 3, "^(Physical memory|Virtual memory|Memory buffers|Cached memory|Swap space)$", 4, ",", 1],
                [5, 4, "^(MMCSS|gupdate|SysmonLog|clr_optimization_v2.0.50727_32|clr_optimization_v4.0.30319_32)$", 4, ",", 1],
                [6, 5, "^(automatic|automatic delayed)$", 3, ",", 1],
                [7, 2, "^Software Loopback Interface", 4, ",", 1],
                [8, 2, "^(In)?[Ll]oop[Bb]ack[0-9._]*$", 4, ",", 1],
                [9, 2, "^NULL[0-9.]*$", 4, ",", 1],
                [10, 2, "^[Ll]o[0-9.]*$", 4, ",", 1],
                [11, 2, "^[Ss]ystem$", 4, ",", 1],
                [12, 2, "^Nu[0-9.]*$", 4, ",", 1]
            ]
        },
        "settings": {
            "fields": ["name", "type", "value_str", "value_int"],
            "data": [
                ["autoreg_tls_accept", 2, "", 1],
                ["hk_history_global", 2, "", 0],
                ["snmptrap_logging", 2, "", 1],
                ["proxy_secrets_provider", 2, "", 0],
                ["hk_history", 1, "31d", 0],
                ["timeout_db_monitor", 1, "3s", 0],
                ["timeout_external_check", 1, "3s", 0],
                ["timeout_http_agent", 1, "3s", 0],
                ["timeout_simple_check", 1, "3s", 0],
                ["timeout_snmp_agent", 1, "3s", 0],
                ["timeout_ssh_agent", 1, "3s", 0],
                ["timeout_telnet_agent", 1, "3s", 0],
                ["timeout_zabbix_agent", 1, "3s", 0],
                ["timeout_browser", 1, "30s", 0]
            ]
        },
        "httptest": {
            "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"],
            "data": []
        },
        "httptestitem": {
            "fields": ["httptestitemid", "httptestid", "itemid", "type"],
            "data": []
        },
        "httptest_field": {
            "fields": ["httptest_fieldid", "httptestid", "type", "name", "value"],
            "data": []
        },
        "httpstep": {
            "fields": ["httpstepid", "httptestid", "name", "no", "url", "timeout", "posts", "required", "status_codes", "follow_redirects", "retrieve_mode", "post_type"],
            "data": []
        },
        "httpstepitem": {
            "fields": ["httpstepitemid", "httpstepid", "itemid", "type"],
            "data": []
        },
        "httpstep_field": {
            "fields": ["httpstep_fieldid", "httpstepid", "type", "name", "value"],
            "data": []
        },
        "config_autoreg_tls": {
            "fields": ["autoreg_tlsid", "tls_psk_identity", "tls_psk"],
            "data": [
                [1, "", ""]
            ]
        }
    },
    "macro.secrets": {
        "AppID=zabbix_server&Query=Safe=passwordSafe;Object=zabbix": {
            "Content": "738"
        }
    },
    "config_revision": 2
}

proxy→server:

{
  "response": "success",
  "version": "8.0.0"
}
数据请求

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

name value type description
server→proxy:
request string 'proxy data'
proxy→server:
session string 数据会话令牌。
interface availability array (可选) 接口可用性数据对象数组。
interfaceid number 接口标识符。
available number 接口可用性:

0, INTERFACE_AVAILABLE_UNKNOWN - 未知
1, INTERFACE_AVAILABLE_TRUE - 可用
2, INTERFACE_AVAILABLE_FALSE - 不可用
error string 接口错误消息或空字符串。
history data array (可选) 历史数据对象数组。
itemid number 监控项标识符。
clock number 监控项值时间戳(秒)。
ns number 监控项值时间戳(纳秒)。
value string (可选) 监控项值。
id number 值标识符(递增计数器,在一个数据会话内唯一)。
timestamp number (可选) 日志类型监控项的时间戳。
source string (可选) Eventlog 监控项 source 值。
severity number (可选) Eventlog 监控项 severity 值。
eventid number (可选) Eventlog 监控项 eventid 值。
state string (可选) 监控项状态:
0, ITEM_STATE_NORMAL
1, ITEM_STATE_NOTSUPPORTED
lastlogsize number (可选) 日志类型监控项的最后日志大小。
mtime number (可选) 日志类型监控项的修改时间。
discovery data array (可选) 发现数据对象数组。
clock number 发现数据时间戳。
druleid number 发现规则标识符。
dcheckid number 发现检查标识符;对于发现规则数据则为 null。
type number 发现检查类型:

-1 发现规则数据
0, SVC_SSH - SSH 服务检查
1, SVC_LDAP - LDAP 服务检查
2, SVC_SMTP - SMTP 服务检查
3, SVC_FTP - FTP 服务检查
4, SVC_HTTP - HTTP 服务检查
5, SVC_POP - POP 服务检查
6, SVC_NNTP - NNTP 服务检查
7, SVC_IMAP - IMAP 服务检查
8, SVC_TCP - TCP 端口可用性检查
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 服务检查
15, SVC_TELNET - Telnet 可用性检查
ip string 主机 IP 地址。
dns string 主机 DNS 名称。
port number (可选) 服务端口号。
key_ string (可选) 类型为 9 SVC_AGENT 的发现检查的监控项键值
value string (可选) 从服务接收到的值,对于大多数服务可以为空。
status number (可选) 服务状态:

0, DOBJECT_STATUS_UP - 服务正常
1, DOBJECT_STATUS_DOWN - 服务不可用
auto registration array (可选) 自动注册数据对象数组。
clock number 自动注册数据时间戳。
host string 主机名称。
ip string (可选) 主机 IP 地址。
dns string (可选) 从 IP 地址解析得到的 DNS 名称。
port string (可选) 主机端口。
host_metadata string (可选) 由 agent 发送的主机元数据(基于 HostMetadata 或 HostMetadataItem agent 配置参数)。
tasks array (可选) 任务数组。
type number 任务类型:

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

0, ZBX_TM_REMOTE_COMMAND_COMPLETED - 远程命令已成功完成
1, ZBX_TM_REMOTE_COMMAND_FAILED - 远程命令失败
error string (可选) 错误消息。
parent_taskid number 父任务 ID。
more number (可选) 1 - 还有更多历史数据要发送。
clock number (可选) 数据传输时间戳(秒)。
ns number (可选) 数据传输时间戳(纳秒)。
version string Proxy 版本(<major>.<minor>.<build>)。
server→proxy:
response string 请求成功信息('success' 或 'failed')。
tasks array (可选) 任务数组。
type number 任务类型:

1, ZBX_TM_TASK_PROCESS_REMOTE_COMMAND - 远程命令
clock number 任务创建时间。
ttl number 任务过期前的秒数。
commandtype number 远程命令类型:

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 - 使用全局脚本(当前在功能上等同于自定义脚本)
command string 要执行的远程命令。
execute_on number 自定义脚本的执行目标:

0, ZBX_SCRIPT_EXECUTE_ON_AGENT - 在 agent 上执行脚本
1, ZBX_SCRIPT_EXECUTE_ON_SERVER - 在服务器上执行脚本
2, ZBX_SCRIPT_EXECUTE_ON_PROXY - 在 proxy 上执行脚本
port number (可选) Telnet 和 SSH 命令的端口。
authtype number (可选) SSH 命令的认证类型。
username string (可选) Telnet 和 SSH 命令的用户名。
password string (可选) Telnet 和 SSH 命令的密码。
publickey string (可选) SSH 命令的公钥。
privatekey string (可选) SSH 命令的私钥。
parent_taskid number 父任务 ID。
hostid number 目标主机 ID。

示例:

server→proxy:

{
  "request": "proxy data"
}

proxy→server:

{
    "session": "12345678901234567890123456789012"
    "interface availability": [
        {
            "interfaceid": 1,
            "available": 1,
            "error": ""
    },
        {
            "interfaceid": 2,
            "available": 2,
            "error": "Get value from agent failed: cannot connect to [[127.0.0.1]:10049]: [111] Connection refused"
    },
        {
            "interfaceid": 3,
            "available": 1,
            "error": ""
    },
        {
            "interfaceid": 4,
            "available": 1,
            "error": ""
    }
    ],
    "history data":[
        {
            "itemid":"12345",
            "clock":1478609647,
            "ns":332510044,
            "value":"52956612",
            "id": 1
        },
        {
            "itemid":"12346",
            "clock":1478609647,
            "ns":330690279,
            "state":1,
            "value":"Cannot find information for this network interface in /proc/net/dev.",
            "id": 2
        }
    ],
    "discovery data":[
        {
            "clock":1478608764,
            "drule":2,
            "dcheck":3,
            "type":12,
            "ip":"10.3.0.10",
            "dns":"vdebian",
            "status":1
        },
        {
            "clock":1478608764,
            "drule":2,
            "dcheck":null,
            "type":-1,
            "ip":"10.3.0.10",
            "dns":"vdebian",
            "status":1
        }
    ],
    "auto registration":[
        {
            "clock":1478608371,
            "host":"Logger1",
            "ip":"10.3.0.1",
            "dns":"localhost",
            "port":"10050"
        },
        {
            "clock":1478608381,
            "host":"Logger2",
            "ip":"10.3.0.2",
            "dns":"localhost",
            "port":"10050"
        }
    ],
    "tasks":[
        {
            "type": 0,
            "status": 0,
            "parent_taskid": 10
        },
        {
            "type": 0,
            "status": 1,
            "error": "No permissions to execute task.",
            "parent_taskid": 20
        }
    ],
    "version":"8.0.0"
}

server→proxy:

{
  "response": "success",
  "tasks":[
      {
         "type": 1,
         "clock": 1478608371,
         "ttl": 600,
         "commandtype": 2,
         "command": "restart_service1.sh",
         "execute_on": 2,
         "port": 80,
         "authtype": 0,
         "username": "userA",
         "password": "password1",
         "publickey": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe",
         "privatekey": "lsuusFncCzWBQ7RKNUSesmQRMSGkVb1/3j+skZ6UtW+5u09lHNsj6tQ5QCqGKukO1De7zhd",
         "parent_taskid": 10,
         "hostid": 10070
      },
      {
         "type": 1,
         "clock": 1478608381,
         "ttl": 600,
         "commandtype": 1,
         "command": "restart_service2.sh",
         "execute_on": 0,
         "authtype": 0,
         "username": "",
         "password": "",
         "publickey": "",
         "privatekey": "",
         "parent_taskid": 20,
         "hostid": 10084
      }
  ]
}
任务请求

proxy tasks 交换用于在服务器与被动 proxy 之间传递和确认远程命令任务。当服务器轮询 proxy 以获取任务结果时,会按照 ProxyDataFrequency 定义的时间间隔发送一个空的 proxy tasks 请求。proxy 会响应其当前版本以及任何待处理的任务结果(包括时间戳)。随后,服务器会通过返回 response 来确认已接收,并且还可以包含要由 proxy 执行的新任务。

name value type description
server→proxy:
request string 'proxy tasks'
proxy→server:
version string Proxy 版本(<major>.<minor>.<build>)。
clock number (可选) 数据传输时间戳(秒)。
ns number (可选) 数据传输时间戳(纳秒)。
server→proxy:
response string 请求成功信息('success' 或 'failed')。

示例:

server→proxy:

{
  "request":"proxy tasks"
}

proxy→server:

{
  "version":"7.0.0",
  "clock":1721059872,
  "ns":848141522
}

server→proxy:

{
  "response":"success"
}

主动代理

配置请求

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

name value type description
proxy→server:
request string 'proxy config'
host string
Proxy 名称。
version string Proxy 版本(<major>.<minor>.<build>)。
session string Proxy 配置会话令牌。
config_revision number Proxy 配置修订版本。
hostmap_revision number 当前主机到 proxy 的映射修订版本。
server→proxy:
full_sync number 1 - 如果发送的是完整配置数据,否则不存在(可选)。
data array 表数据对象。如果配置未更改则不存在(可选)。
<table> object 一个或多个包含 <table> 数据的对象(可选,取决于变更)。
fields array 字段名称数组。
- string 字段名称。
data array 行数组。
- array 列数组。
- string,number 列值,其类型取决于数据库模式中的列类型。
macro.secrets object 密钥宏信息,如果保管库宏没有变化则不存在(可选)。
proxy_group string proxy 所属 proxy 组的名称。
config_revision number 配置缓存修订版本 - 随配置数据一起发送(可选)。
del_hostids array 已删除 hostid 的数组(可选)。
- number 主机标识符。
del_macro_hostids array 其所有宏均已删除的 hostid 数组(可选)。
- number 主机标识符。

示例:

proxy→server:

{
  "request": "proxy config",
  "host": "Zabbix proxy",
  "version":"8.0.0",
  "session": "fd59a09ff4e9d1fb447de1f04599bcf6",
  "config_revision": 0
}

server→proxy:

{
    "full_sync": 1,
    "data": {
        "hosts": {
            "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"],
            "data": [
                [10084, "Zabbix server", 0, -1, 2, "", "", "Zabbix server", 1, 1, "", "", "", ""]
            ]
        },
        "interface": {
            "fields": ["interfaceid", "hostid", "main", "type", "useip", "ip", "dns", "port", "available"],
            "data": [
                [1, 10084, 1, 1, 1, "127.0.0.1", "", "10053", 1]
            ]
        },
        "interface_snmp": {
            "fields": ["interfaceid", "version", "bulk", "community", "securityname", "securitylevel", "authpassphrase", "privpassphrase", "authprotocol", "privprotocol", "contextname"],
            "data": []
        },
        "host_inventory": {
            "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"],
            "data": [
                [10084, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "56.95387", "24.22067", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]
            ]
        },
        "items": {
            "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"],
            "data": [
                [44161, 7, "", 10084, "agent.hostmetadata", "10s", "90d", 0, 1, "", "", "", "", 0, "", "", "", "", 0, null, 0, "", null, "3s", "", "", "", "200", 1, 0, "", "", 0, 0, 0, "", "", "", 0, 0, 0],
                [44162, 0, "", 10084, "agent.ping", "10s", "90d", 0, 3, "", "", "", "", 0, "", "", "", "", 0, 1, 0, "", null, "3s", "", "", "", "200", 1, 0, "", "", 0, 0, 0, "", "", "", 0, 0, 0]
            ]
        },
        "item_rtdata": {
            "fields": ["itemid", "lastlogsize", "mtime"],
            "data": [
                [44161, 0, 0],
                [44162, 0, 0]
            ]
        },
        "item_preproc": {
            "fields": ["item_preprocid", "itemid", "step", "type", "params", "error_handler", "error_handler_params"],
            "data": []
        },
        "item_parameter": {
            "fields": ["item_parameterid", "itemid", "name", "value"],
            "data": []
        },
        "globalmacro": {
            "fields": ["globalmacroid", "macro", "value", "type"],
            "data": [
                [2, "{$SNMP_COMMUNITY}", "public", 0]
            ]
        },
        "hosts_templates": {
            "fields": ["hosttemplateid", "hostid", "templateid", "link_type"],
            "data": []
        },
        "hostmacro": {
            "fields": ["hostmacroid", "hostid", "macro", "value", "type", "automatic"],
            "data": [
                [5676, 10084, "{$M}", "AppID=zabbix_server&Query=Safe=passwordSafe;Object=zabbix:Content", 2, 0]
            ]
        },
        "drules": {
            "fields": ["druleid", "name", "iprange", "delay"],
            "data": [
                [2, "Local network", "127.0.0.1", "10s"]
            ]
        },
        "dchecks": {
            "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"],
            "data": [
                [2, 2, 9, "system.uname", "", "10052", "", 0, "", "", 0, 0, 0, "", 1, 0]
            ]
        },
        "regexps": {
            "fields": ["regexpid", "name"],
            "data": [
                [1, "File systems for discovery"],
                [2, "Network interfaces for discovery"],
                [3, "Storage devices for SNMP discovery"],
                [4, "Windows service names for discovery"],
                [5, "Windows service startup states for discovery"]
            ]
        },
        "expressions": {
            "fields": ["expressionid", "regexpid", "expression", "expression_type", "exp_delimiter", "case_sensitive"],
            "data": [
                [1, 1, "^(btrfs|ext2|ext3|ext4|reiser|xfs|ffs|ufs|jfs|jfs2|vxfs|hfs|apfs|refs|ntfs|fat32|zfs)$", 3, ",", 0],
                [3, 3, "^(Physical memory|Virtual memory|Memory buffers|Cached memory|Swap space)$", 4, ",", 1],
                [5, 4, "^(MMCSS|gupdate|SysmonLog|clr_optimization_v2.0.50727_32|clr_optimization_v4.0.30319_32)$", 4, ",", 1],
                [6, 5, "^(automatic|automatic delayed)$", 3, ",", 1],
                [7, 2, "^Software Loopback Interface", 4, ",", 1],
                [8, 2, "^(In)?[Ll]oop[Bb]ack[0-9._]*$", 4, ",", 1],
                [9, 2, "^NULL[0-9.]*$", 4, ",", 1],
                [10, 2, "^[Ll]o[0-9.]*$", 4, ",", 1],
                [11, 2, "^[Ss]ystem$", 4, ",", 1],
                [12, 2, "^Nu[0-9.]*$", 4, ",", 1]
            ]
        },
        "settings": {
            "fields": ["name", "type", "value_str", "value_int"],
            "data": [
                ["autoreg_tls_accept", 2, "", 1],
                ["hk_history_global", 2, "", 0],
                ["snmptrap_logging", 2, "", 1],
                ["proxy_secrets_provider", 2, "", 0],
                ["hk_history", 1, "31d", 0],
                ["timeout_db_monitor", 1, "3s", 0],
                ["timeout_external_check", 1, "3s", 0],
                ["timeout_http_agent", 1, "3s", 0],
                ["timeout_simple_check", 1, "3s", 0],
                ["timeout_snmp_agent", 1, "3s", 0],
                ["timeout_ssh_agent", 1, "3s", 0],
                ["timeout_telnet_agent", 1, "3s", 0],
                ["timeout_zabbix_agent", 1, "3s", 0],
                ["timeout_browser", 1, "30s", 0]
            ]
        },
        "httptest": {
            "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"],
            "data": []
        },
        "httptestitem": {
            "fields": ["httptestitemid", "httptestid", "itemid", "type"],
            "data": []
        },
        "httptest_field": {
            "fields": ["httptest_fieldid", "httptestid", "type", "name", "value"],
            "data": []
        },
        "httpstep": {
            "fields": ["httpstepid", "httptestid", "name", "no", "url", "timeout", "posts", "required", "status_codes", "follow_redirects", "retrieve_mode", "post_type"],
            "data": []
        },
        "httpstepitem": {
            "fields": ["httpstepitemid", "httpstepid", "itemid", "type"],
            "data": []
        },
        "httpstep_field": {
            "fields": ["httpstep_fieldid", "httpstepid", "type", "name", "value"],
            "data": []
        },
        "config_autoreg_tls": {
            "fields": ["autoreg_tlsid", "tls_psk_identity", "tls_psk"],
            "data": [
                [1, "", ""]
            ]
        }
    },
    "macro.secrets": {
        "AppID=zabbix_server&Query=Safe=passwordSafe;Object=zabbix": {
            "Content": "738"
        }
    },
    "config_revision": 2
}
数据请求

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

name value type description
proxy→server:
request string 'proxy data'
host string Proxy 名称。
session string 数据会话令牌。
interface availability array (可选) 接口可用性数据对象数组。
interfaceid number 接口标识符。
available number 接口可用性:

0, INTERFACE_AVAILABLE_UNKNOWN - 未知
1, INTERFACE_AVAILABLE_TRUE - 可用
2, INTERFACE_AVAILABLE_FALSE - 不可用
error string 接口错误消息或空字符串。
history data array (可选) 历史数据对象数组。
itemid number 监控项标识符。
clock number 监控项值时间戳(秒)。
ns number 监控项值时间戳(纳秒)。
value string (可选) 监控项值。
id number 值标识符(递增计数器,在一个数据会话内唯一)。
timestamp number (可选) 日志类型监控项的时间戳。
source string (可选) eventlog 监控项的 source 值。
severity number (可选) eventlog 监控项的 severity 值。
eventid number (可选) eventlog 监控项的 eventid 值。
state string (可选) 监控项状态:
0, ITEM_STATE_NORMAL
1, ITEM_STATE_NOTSUPPORTED
lastlogsize number (可选) 日志类型监控项的最后日志大小。
mtime number (可选) 日志类型监控项的修改时间。
discovery data array (可选) 发现数据对象数组。
clock number 发现数据时间戳。
druleid number 发现规则标识符。
dcheckid number 发现检查标识符;对于发现规则数据则为 null。
type number 发现检查类型:

-1 发现规则数据
0, SVC_SSH - SSH 服务检查
1, SVC_LDAP - LDAP 服务检查
2, SVC_SMTP - SMTP 服务检查
3, SVC_FTP - FTP 服务检查
4, SVC_HTTP - HTTP 服务检查
5, SVC_POP - POP 服务检查
6, SVC_NNTP - NNTP 服务检查
7, SVC_IMAP - IMAP 服务检查
8, SVC_TCP - TCP 端口可用性检查
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 服务检查
15, SVC_TELNET - Telnet 可用性检查
ip string 主机 IP 地址。
dns string 主机 DNS 名称。
port number (可选) 服务端口号。
key_ string (可选) 类型为 9 SVC_AGENT 的发现检查的监控项键值
value string (可选) 从服务接收到的值,对于大多数服务可以为空。
status number (可选) 服务状态:

0, DOBJECT_STATUS_UP - 服务 UP
1, DOBJECT_STATUS_DOWN - 服务 DOWN
autoregistration array (可选) 自动注册数据对象数组。
clock number 自动注册数据时间戳。
host string 主机名称。
ip string (可选) 主机 IP 地址。
dns string (可选) 从 IP 地址解析得到的 DNS 名称。
port string (可选) 主机端口。
host_metadata string (可选) 由 agent 发送的主机元数据(基于 HostMetadata 或 HostMetadataItem agent 配置参数)。
tasks array (可选) 任务数组。
type number 任务类型:

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

0, ZBX_TM_REMOTE_COMMAND_COMPLETED - 远程命令已成功完成
1, ZBX_TM_REMOTE_COMMAND_FAILED - 远程命令失败
error string (可选) 错误消息。
parent_taskid number 父任务 ID。
more number (可选) 1 - 还有更多历史数据要发送
clock number (可选) 数据传输时间戳(秒)。
ns number (可选) 数据传输时间戳(纳秒)。
version string Proxy 版本(<major>.<minor>.<build>)。
server→proxy:
response string 请求成功信息('success' 或 'failed')。
upload string 历史数据(history、autoregistration、主机可用性、网络发现)的上传控制。

可能的值:
enabled - 正常运行
disabled - 服务器不接受数据(可能由于内部缓存超限)
tasks array (可选) 任务数组。
type number 任务类型:

1, ZBX_TM_TASK_PROCESS_REMOTE_COMMAND - 远程命令
clock number 任务创建时间。
ttl number 任务过期前的秒数。
commandtype number 远程命令类型:

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 - 使用全局脚本(当前在功能上等同于自定义脚本)
command string 要执行的远程命令。
execute_on number 自定义脚本的执行目标:

0, ZBX_SCRIPT_EXECUTE_ON_AGENT - 在 agent 上执行脚本
1, ZBX_SCRIPT_EXECUTE_ON_SERVER - 在服务器上执行脚本
2, ZBX_SCRIPT_EXECUTE_ON_PROXY - 在 proxy 上执行脚本
port number (可选) Telnet 和 SSH 命令的端口。
authtype number (可选) SSH 命令的认证类型。
username string (可选) Telnet 和 SSH 命令的用户名。
password string (可选) Telnet 和 SSH 命令的密码。
publickey string (可选) SSH 命令的公钥。
privatekey string (可选) SSH 命令的私钥。
parent_taskid number 父任务 ID。
hostid number 目标主机 ID。

示例:

proxy→server:

{
    "request": "proxy data",
    "host": "Zabbix proxy",
    "session": "818cdd1b537bdc5e50c09ed4969235b6",
    "interface availability": [{
        "interfaceid": 1,
        "available": 1,
        "error": ""
    }],
    "history data": [{
        "id": 1114,
        "itemid": 44162,
        "clock": 1665730632,
        "ns": 798953105,
        "value": "1"
    }, {
        "id": 1115,
        "itemid": 44161,
        "clock": 1665730633,
        "ns": 811684663,
        "value": "58"
    }],
    "auto registration": [{
        "clock": 1665730633,
        "host": "Zabbix server",
        "ip": "127.0.0.1",
        "dns": "localhost",
        "port": "10053",
        "host_metadata": "58",
        "tls_accepted": 1
    }],
    "discovery data": [{
        "clock": 1665732232,
        "drule": 2,
        "dcheck": 2,
        "ip": "127.0.0.1",
        "dns": "localhost",
        "port": 10052,
        "status": 1
    }, {
        "clock": 1665732232,
        "drule": 2,
        "dcheck": null,
        "ip": "127.0.0.1",
        "dns": "localhost",
        "status": 1
    }],
    "host data": [{
        "hostid": 10084,
        "active_status": 1
    }],
    "tasks": [{
        "type": 3,
        "clock": 1665730985,
        "ttl": 0,
        "status": -1,
        "info": "Remote commands are not enabled",
        "parent_taskid": 3
    }],
    "version": "8.0.0",
    "clock": 1665730643,
    "ns": 65389964
}

server→proxy:

{
    "upload": "enabled",
    "response": "success",
    "tasks": [{
        "type": 2,
        "clock": 1665730986,
        "ttl": 600,
        "commandtype": 0,
        "command": "ping -c 3 127.0.0.1; case $? in [01]) true;; *) false;; esac",
        "execute_on": 2,
        "port": 0,
        "authtype": 0,
        "username": "",
        "password": "",
        "publickey": "",
        "privatekey": "",
        "alertid": 0,
        "parent_taskid": 4,
        "hostid": 10084
    }]
}