4 Zabbix agent 2 plugin protocol

Zabbix agent 2 protocol is based on code, size and data model.

Code

TypeSizeComments
Byte4Payload type, currently only JSON is supported.

Size

TypeSizeComments
Byte4Size of the current payload in bytes.

Payload data

TypeSizeComments
ByteDefined by the Size fieldJSON formatted data.
Payload data definition
Common data

These parameters are present in all requests/responses:

NameTypeComments
iduint32For requests - the incrementing identifier used to link requests with responses. Unique within a request direction (i.e. from agent to plugin or from plugin to agent).
For responses - ID of the corresponding request.
typeuint32The request type.
Log request

A request sent by a plugin to write a log message into the agent log file.

directionplugin → agent
responseno

Parameters specific to log requests:

NameTypeComments
severityuint32The message severity (log level).
messagestringThe message to log.

Example:

  1. {"id":0,"type":1,"severity":3,"message":"message"}
Register request

A request sent by the agent during the agent startup phase to obtain provided metrics to register a plugin.

directionagent → plugin
responseyes

Parameters specific to register requests:

NameTypeComments
versionstringThe protocol version <major>.<minor>

Example:

  1. {"id":1,"type":2,"version":"1.0"}
Register response

Plugin’s response to the register request.

directionplugin → agent
responsen/a

Parameters specific to register responses:

NameTypeComments
namestringThe plugin name.
metricsarray of strings (optional)The metrics with descriptions as used in the plugin. Returns RegisterMetrics(). Absent if error is returned.
interfacesuint32 (optional)The bit mask of plugin’s supported interfaces. Absent if error is returned.
errorstring (optional)An error message returned if a plugin cannot be started. Absent, if metrics are returned.

Examples:

  1. {"id":2,"type":3,"metrics":["external.test", "External exporter Test."], "interfaces": 4}

or

  1. {"id":2,"type":3,"error":"error message"}
Start request

A request to execute the Start function of the Runner interface.

directionagent → plugin
responseno

The request doesn’t have specific parameters, it only contains common data parameters.

Example:

  1. {"id":3,"type":4}
Terminate request

A request sent by the agent to shutdown a plugin.

directionagent → plugin
responseno

The request doesn’t have specific parameters, it only contains common data parameters.

Example:

  1. {"id":3,"type":5}
Export request

A request to execute the Export function of the Exporter interface.

directionagent → plugin
responseno

Parameters specific to export requests:

NameTypeComments
keystringThe plugin key.
parametersarray of strings (optional)The parameters for Export function.

Example:

  1. {"id":4,"type":6,"key":"test.key","parameters":["foo","bar"]}
Export response

Response from the Export function of the Exporter interface.

directionplugin → agent
responsen/a

Parameters specific to export responses:

NameTypeComments
valuestring (optional)Response value from the Export function. Absent, if error is returned.
errorstring (optional)Error message if the Export function has not been executed successfully. Absent, if value is returned.

Examples:

  1. {"id":5,"type":7,"value":"response"}

or

  1. {"id":5,"type":7,"error":"error message"}
Configure request

A request to execute the Configure function of the Configurator interface.

directionagent → plugin
responsen/a

Parameters specific to Configure requests:

NameTypeComments
global_optionsJSON objectJSON object containing global agent configuration options.
private_optionsJSON object (optional)JSON object containing private plugin configuration options, if provided.

Example:

  1. {"id":6,"type":8,"global_options":{...},"private_options":{...}}
Validate request

A request to execute Validate function of the Configurator interface.

directionagent → plugin
responseyes

Parameters specific to Validate requests:

NameTypeComments
private_optionsJSON object (optional)JSON object containing private plugin configuration options, if provided.

Example:

  1. {"id":7,"type":9,"private_options":{...}}
Validate response

Response from Validate function of Configurator interface.

directionplugin → agent
responsen/a

Parameters specific to Validate responses:

NameTypeComments
errorstring (optional)An error message returned if the Validate function is not executed successfully. Absent if executed successfully.

Example:

  1. {"id":8,"type":10}

or

  1. {"id":8,"type":10,"error":"error message"}