Server - proxy 数据交换基于 JSON 格式.
请求和响应消息必须以header头部与数据长度开头.
服务器发送 proxy config
请求以提供代理配置数据. 此请求间隔ProxyConfigFrequency
秒(服务器配置参数) .
名称 | 值类型 | 描述 | |||
---|---|---|---|---|---|
server→proxy: | |||||
request | string | 'proxy config' | |||
<table> | object | 包含<table>数据的一个或多个对象 | |||
fields | array | 字段名称数组 | |||
- | string | 字段名称 | |||
data | array | 行数组 | |||
- | array | 列数组 | |||
- | string,number | 列值,其类型取决于数据库表结构中的类型 | |||
proxy→server: | |||||
response | string | 请求成功信息 ('success' 或 'failed') | |||
version | string | proxy的版本信息 (<major>.<minor>.<build>) |
例子:
server→proxy:
{
"request": "proxy config",
"globalmacro":{
"fields":[
"globalmacroid",
"macro",
"value"
],
"data":[
[
2,
"{$SNMP_COMMUNITY}",
"public"
]
]
},
"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":[
[
10001,
"Linux",
3,
-1,
2,
"",
"",
"Linux",
1,
1,
"",
"",
"",
""
],
[
10050,
"Zabbix Agent",
3,
-1,
2,
"",
"",
"Zabbix Agent",
1,
1,
"",
"",
"",
""
],
[
10105,
"Logger",
0,
-1,
2,
"",
"",
"Logger",
1,
1,
"",
"",
"",
""
]
]
},
"interface":{
"fields":[
"interfaceid",
"hostid",
"main",
"type",
"useip",
"ip",
"dns",
"port",
"bulk"
],
"data":[
[
2,
10105,
1,
1,
1,
"127.0.0.1",
"",
"10050",
1
]
]
},
...
}
proxy→server:
proxy data
请求用于从代理获取主机接口可用性、历史、发现和自动注册数据。此请求发送间隔ProxyDataFrequency
秒 (服务器配置参数)。
名称 | 值类型 | 描述 | |
---|---|---|---|
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 | 值标识符(自增id,在一个数据会话中是唯一的) | |
timestamp | number | (可选) 日志类型监控项的时间戳 | |
source | string | (可选) 事件日志监控项数据源 | |
severity | number | (可选) 事件日志监控项严重性值 | |
eventid | number | (可选) 事件日志监控项事件id | |
state | string | (可选) 监控项状态 0, ITEM_STATE_NORMAL 1, ITEM_STATE_NOTSUPPORTED |
|
lastlogsize | number | (可选) 最后一次监控项的大小 | |
mtime | number | (可选) 监控项修改时间 | |
discovery data | array | (可选) 自动发现数据对象数组 | |
clock | number | 自动发现数据时间戳 | |
druleid | number | 自动发现规则id | |
dcheckid | number | 自动发现规则数据的发现检查id 或 null | |
type | number | 自动发现检查类型: -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 |
|
ip | string | 主机 IP 地址 | |
dns | string | 主机 DNS 名称 | |
port | number | (可选) 端口号 | |
key_ | string | (可选) 用于自动发现检查的监控项键 9 SVC_AGENT | |
value | string | (可选) 从服务接收的值,对于大多数服务可以为空 | |
status | number | (可选) service status: 0, DOBJECT_STATUS_UP - 服务up 1, DOBJECT_STATUS_DOWN - 服务dwon |
|
auto registration | array | (可选) 自动注册数据对象数组 | |
clock | number | 自动注册数据时间戳 | |
host | string | 主机名 | |
ip | string | (可选) IP | |
dns | string | (可选) 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 - use custom script 1, ZBX_SCRIPT_TYPE_IPMI - use IPMI 2, ZBX_SCRIPT_TYPE_SSH - use SSH 3, ZBX_SCRIPT_TYPE_TELNET - use Telnet 4, ZBX_SCRIPT_TYPE_GLOBAL_SCRIPT - use global script (currently functionally equivalent to custom script) |
|
command | string | 要执行的远程命令 | |
execute_on | number | the execution target for custom scripts: 0, ZBX_SCRIPT_EXECUTE_ON_AGENT - execute script on agent 1, ZBX_SCRIPT_EXECUTE_ON_SERVER - execute script on server 2, ZBX_SCRIPT_EXECUTE_ON_PROXY - execute script on proxy |
|
port | number | (可选) 远程登录和 ssh 端口 | |
authtype | number | (可选) ssh 命令的身份验证类型 | |
username | string | (可选) telnet 和 ssh 命令的用户名 | |
password | string | (可选) 远程登录和 ssh 命令的密码 | |
publickey | string | (可选) ssh 命令的公钥 | |
privatekey | string | (可选) ssh 命令的私钥 | |
parent_taskid | number | 父级任务 ID | |
hostid | number | 目标 hostid |
例子:
server→proxy:
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":"5.4.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 heartbeat
请求由代理发送以报告代理正在运行。 每次发送此请求间隔 HeartbeatFrequency
秒 (代理配置参数)
名称 | 值类型 | |
---|---|---|
proxy→server: | ||
request | string | |
host | string | |
version | string | |
server→proxy: | ||
response | string |
proxy→server:
server→proxy:
proxy config
请求由代理发送以获取代理配置数据。 每次发送此请求间隔 ConfigFrequency
(代理配置参数)秒。
名称 | 值类型 | 描述 | |||
---|---|---|---|---|---|
proxy→server: | |||||
request | string | 'proxy config' | |||
host | string | 代理名称 | |||
version | string | 代理版本 (<major>.<minor>.<build>) | |||
server→proxy: | |||||
request | string | 'proxy config' | |||
<table> | object | 包含 <table> 的一个或多个对象 | |||
fields | array | 数组字段名称 | |||
- | string | 字段名 | |||
data | array | 行数组 | |||
- | array | 列数组 | |||
- | string,number | 列值,其类型取决于数据库表结构的类型 | |||
proxy→server: | |||||
response | string | 请求成功信息 ('success' 或 'failed') |
例子:
proxy→server:
server→proxy:
{
"globalmacro":{
"fields":[
"globalmacroid",
"macro",
"value"
],
"data":[
[
2,
"{$SNMP_COMMUNITY}",
"public"
]
]
},
"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":[
[
10001,
"Linux",
3,
-1,
2,
"",
"",
"Linux",
1,
1,
"",
"",
"",
""
],
[
10050,
"Zabbix Agent",
3,
-1,
2,
"",
"",
"Zabbix Agent",
1,
1,
"",
"",
"",
""
],
[
10105,
"Logger",
0,
-1,
2,
"",
"",
"Logger",
1,
1,
"",
"",
"",
""
]
]
},
"interface":{
"fields":[
"interfaceid",
"hostid",
"main",
"type",
"useip",
"ip",
"dns",
"port",
"bulk"
],
"data":[
[
2,
10105,
1,
1,
1,
"127.0.0.1",
"",
"10050",
1
]
]
},
...
}
proxy→server:
“代理数据”请求由代理发送,以提供主机接口可用性、历史记录、发现和自动注册数据。此请求每“DataSenderFrequency”(代理配置参数)秒发送一次。请注意,主动代理仍将每秒轮询 Zabbix 服务器以获取远程命令任务(使用空的“代理数据”请求)。
名称 | 值类型 | 描述 | |
---|---|---|---|
proxy→server: | |||
request | string | 'proxy data' | |
host | string | 代理名称 | |
session | string | 数据会话令牌 | |
interface availability | array | (optional) 接口可用性数据对象数组 | |
interfaceid | number | 接口标识符 | |
available | number | 接口可用性 0, INTERFACE_AVAILABLE_UNKNOWN - unknown 1, INTERFACE_AVAILABLE_TRUE - available 2, INTERFACE_AVAILABLE_FALSE - unavailable |
|
error | string | 接口错误消息或空字符串 | |
history data | array | (可选) 历史数据对象数组 | |
itemid | number | 监控项标识符 | |
clock | number | 监控项值时间戳 (秒) | |
ns | number | 监控项值时间戳 (纳秒) | |
value | string | (可选) 监控项值 | |
id | number | 值标识符(自增id,在一个数据会话中是唯一的) | |
timestamp | number | (可选) 日志类型监控项的时间戳 | |
source | string | (可选) 事件日志监控项数据源 | |
severity | number | (可选) 事件日志监控项严重性值 | |
eventid | number | (可选) 事件日志监控项事件id | |
state | string | (可选) 监控项状态 0, ITEM_STATE_NORMAL 1, ITEM_STATE_NOTSUPPORTED |
|
lastlogsize | number | (可选) 最后一次监控项的大小 | |
mtime | number | (可选) 监控项修改时间 | |
discovery data | array | (可选) 自动发现数据对象数组 | |
clock | number | 自动发现数据是时间戳 | |
druleid | number | 自动发现规则id | |
dcheckid | number | 自动发现规则数据的发现检查id 或 null | |
type | number | 自动发现检查类型: -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 |
|
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 |
|
auto registration | array | (可选) 自动注册数据对象数组 | |
clock | number | 自动注册数据时间戳 | |
host | string | 主机名 | |
ip | string | (可选) IP | |
dns | string | (可选) 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 | 版本信息 (<major>.<minor>.<build>) | |
server→proxy: | |||
response | string | 请求成功信息 ('success' 或 'failed') | |
upload | string | 历史数据(历史、自动注册、主机可用性、网络发现)的上传控制: 启用 - 正常操作 禁用 - 服务器不接受数据(可能是由于内部缓存超过限制) |
|
tasks | array | (可选) 任务数组 | |
type | number | 任务类型: 1, ZBX_TM_TASK_PROCESS_REMOTE_COMMAND - 远程命令 |
|
clock | number | 任务创建时间 | |
ttl | number | 任务过期时间 | |
commandtype | number | 远程命令类型: 0, ZBX_SCRIPT_TYPE_CUSTOM_SCRIPT - use custom script 1, ZBX_SCRIPT_TYPE_IPMI - use IPMI 2, ZBX_SCRIPT_TYPE_SSH - use SSH 3, ZBX_SCRIPT_TYPE_TELNET - use Telnet 4, ZBX_SCRIPT_TYPE_GLOBAL_SCRIPT - use global script (currently functionally equivalent to custom script) |
|
command | string | 要执行的远程命令 | |
execute_on | number | 自定义脚本的执行目标: 0, ZBX_SCRIPT_EXECUTE_ON_AGENT - execute script on agent 1, ZBX_SCRIPT_EXECUTE_ON_SERVER - execute script on server 2, ZBX_SCRIPT_EXECUTE_ON_PROXY - execute script on proxy |
|
port | number | (可选) 远程登录和 ssh 端口 | |
authtype | number | (可选) ssh 命令的身份验证类型 | |
username | string | (可选) telnet 和 ssh 命令的用户名 | |
password | string | (可选) 远程登录和 ssh 命令的密码 | |
publickey | string | (可选) ssh 命令的公钥 | |
privatekey | string | (可选) ssh 命令的私钥 | |
parent_taskid | number | 父级任务 ID | |
hostid | number | 目标 hostid |
例子:
proxy→server:
{
"request": "proxy data",
"host": "Proxy #12",
"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": 2,
"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": 2,
"clock":1478608381,
"ttl": 600,
"commandtype": 1,
"command": "restart_service2.sh",
"execute_on": 0,
"authtype": 0,
"username": "",
"password": "",
"publickey": "",
"privatekey": "",
"parent_taskid": 20,
"hostid": 10084
}
],
"tasks":[
{
"type": 0,
"status": 0,
"parent_taskid": 10
},
{
"type": 0,
"status": 1,
"error": "No permissions to execute task.",
"parent_taskid": 20
}
],
"version":"5.4.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
}
]
}