3 Zabbix agent 2 protocol

Overview

This section provides information on:

  • Agent2 -> Server : active checks request
  • Server -> Agent2 : active checks response
  • Agent2 -> Server : agent data request
  • Server -> Agent2 : agent data response
  • Agent2 -> Server : heartbeat message

Active checks request

The active checks request is used to obtain the active checks to be processed by agent. This request is sent by the agent upon start and then with RefreshActiveChecks intervals.

FieldTypeMandatoryValue
requeststringyesactive checks
hoststringyesHost name.
versionstringyesThe agent version: <major>.<minor>.
host_metadatastringnoThe configuration parameter HostMetadata or HostMetadataItem metric value.
interfacestringnoThe configuration parameter HostInterface or HostInterfaceItem metric value.
ipstringnoThe configuration parameter ListenIP first IP if set.
portnumbernoThe configuration parameter ListenPort value if set and not default agent listening port.
config_revisionnumbernoConfiguration identifier for incremental configuration sync.
sessionstringnoSession identifier for incremental configuration sync.

Example:

  1. {
  2. "request": "active checks",
  3. "host": "Zabbix server",
  4. "version": "6.0",
  5. "host_metadata": "mysql,nginx",
  6. "hostinterface": "zabbix.server.lan",
  7. "ip": "159.168.1.1",
  8. "port": 12050,
  9. "config_revision": 1,
  10. "session": "e3dcbd9ace2c9694e1d7bbd030eeef6e"
  11. }

Active checks response

The active checks response is sent by the server back to agent after processing active checks request.

FieldTypeMandatoryValue
responsestringyessuccess | failed
infostringnoError information in the case of failure.
dataarray of objectsnoActive check items. Omitted if host configuration is unchanged.
keystringnoItem key with expanded macros.
itemidnumbernoItem identifier.
delaystringnoItem update interval.
lastlogsizenumbernoItem lastlogsize.
mtimenumbernoItem mtime.
regexparray of objectsnoGlobal regular expressions.
namestringnoGlobal regular expression name.
expressionstringnoGlobal regular expression.
expression_typenumbernoGlobal regular expression type.
exp_delimiterstringnoGlobal regular expression delimiter.
case_sensitivenumbernoGlobal regular expression case sensitiviness setting.
config_revisionnumbernoConfiguration identifier for incremental configuration sync. Omitted if host configuration is unchanged. Incremented if host configuration is changed.

Example:

  1. {
  2. "response": "success",
  3. "data": [
  4. {
  5. "key": "log[/home/zabbix/logs/zabbix_agentd.log]",
  6. "itemid": 1234,
  7. "delay": "30s",
  8. "lastlogsize": 0,
  9. "mtime": 0
  10. },
  11. {
  12. "key": "agent.version",
  13. "itemid": 5678,
  14. "delay": "10m",
  15. "lastlogsize": 0,
  16. "mtime": 0
  17. }
  18. ],
  19. "config_revision": 2
  20. }

Agent data request

The agent data request contains the gathered item values.

FieldTypeMandatoryValue
requeststringyesagent data
hoststringyesHost name.
versionstringyesThe agent version: <major>.<minor>.
sessionstringyesUnique session identifier generated each time when agent is started.
dataarray of objectsyesItem values.
idnumberyesThe value identifier (incremental counter used for checking duplicated values in the case of network problems).
itemidnumberyesItem identifier.
valuestringnoThe item value.
lastlogsizenumbernoThe item lastlogsize.
mtimenumbernoThe item mtime.
statenumbernoThe item state.
sourcestringnoThe value event log source.
eventidnumbernoThe value event log eventid.
severitynumbernoThe value event log severity.
timestampnumbernoThe value event log timestamp.
clocknumberyesThe value timestamp (seconds since Epoch).
nsnumberyesThe value timestamp nanoseconds.

Example:

  1. {
  2. "request": "agent data",
  3. "data": [
  4. {
  5. "id": 1,
  6. "itemid": 5678,
  7. "value": "2.4.0",
  8. "clock": 1400675595,
  9. "ns": 76808644
  10. },
  11. {
  12. "id": 2,
  13. "itemid": 1234,
  14. "lastlogsize": 112,
  15. "value": " 19845:20140621:141708.521 Starting Zabbix Agent [<hostname>]. Zabbix 2.4.0 (revision 50000).",
  16. "clock": 1400675595,
  17. "ns": 77053975
  18. }
  19. ],
  20. "host": "Zabbix server",
  21. "version": "6.0",
  22. "session": "1234456akdsjhfoui"
  23. }

Agent data response

The agent data response is sent by the server back to agent after processing the agent data request.

FieldTypeMandatoryValue
responsestringyessuccess | failed
infostringyesItem processing results.

Example:

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

Heartbeat message

The heartbeat message is sent by an active agent to Zabbix server/proxy every HeartbeatFrequency seconds (configured in the Zabbix agent 2 configuration file).

It is used to monitor the availability of active checks.

  1. {
  2. "request": "active check heartbeat",
  3. "host": "Zabbix server",
  4. "heartbeat_freq": 60
  5. }
FieldTypeMandatoryValue
requeststringyesactive check heartbeat
hoststringyesThe host name.
heartbeat_freqnumberyesThe agent heartbeat frequency (HeartbeatFrequency configuration parameter).