4 捕捉器监控项

概述

Zabbix服务器使用基于JSON的通信协议,在 trapper item的帮助下从Zabbix发送器接收数据。

请求和响应消息必须以header and data length开头。

Zabbix发送请求

  1. {
  2. "request":"sender data",
  3. "data":[
  4. {
  5. "host":"<hostname>",
  6. "key":"trap",
  7. "value":"test value"
  8. }
  9. ]
  10. }

Zabbix服务器响应

  1. {
  2. "response":"success",
  3. "info":"processed: 1; failed: 0; total: 1; seconds spent: 0.060753"
  4. }

或者,Zabbix发送者可以发送带有时间戳的请求

  1. {
  2. "request":"sender data",
  3. "data":[
  4. {
  5. "host":"<hostname>",
  6. "key":"trap",
  7. "value":"test value",
  8. "clock":1516710794
  9. },
  10. {
  11. "host":"<hostname>",
  12. "key":"trap",
  13. "value":"test value",
  14. "clock":1516710795
  15. }
  16. ],
  17. "clock":1516712029,
  18. "ns":873386094
  19. }

Zabbix服务器响应

  1. {
  2. "response":"success",
  3. "info":"processed: 2; failed: 0; total: 2; seconds spent: 0.060904"
  4. }

4 Trapper items

Overview

Zabbix server uses a JSON- based communication protocol for receiving data from Zabbix sender with the help of trapper item.

Request and response messages must begin with header and data length.

Zabbix sender request

  1. {
  2. "request":"sender data",
  3. "data":[
  4. {
  5. "host":"<hostname>",
  6. "key":"trap",
  7. "value":"test value"
  8. }
  9. ]
  10. }

Zabbix server response

  1. {
  2. "response":"success",
  3. "info":"processed: 1; failed: 0; total: 1; seconds spent: 0.060753"
  4. }

Alternatively Zabbix sender can send request with a timestamp

  1. {
  2. "request":"sender data",
  3. "data":[
  4. {
  5. "host":"<hostname>",
  6. "key":"trap",
  7. "value":"test value",
  8. "clock":1516710794
  9. },
  10. {
  11. "host":"<hostname>",
  12. "key":"trap",
  13. "value":"test value",
  14. "clock":1516710795
  15. }
  16. ],
  17. "clock":1516712029,
  18. "ns":873386094
  19. }

Zabbix server response

  1. {
  2. "response":"success",
  3. "info":"processed: 2; failed: 0; total: 2; seconds spent: 0.060904"
  4. }