public class JabbixJSONProtocol
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ZBX_PROTO_TAG_AVAILABLE |
static java.lang.String |
ZBX_PROTO_TAG_CLOCK
Defines the time stamp of an entry.
|
static java.lang.String |
ZBX_PROTO_TAG_DATA
The entry key of an array of metric entries.
|
static java.lang.String |
ZBX_PROTO_TAG_DCHECK |
static java.lang.String |
ZBX_PROTO_TAG_DELAY
Defines the update period of an active metric
defined by the corresponding entry.
|
static java.lang.String |
ZBX_PROTO_TAG_DRULE |
static java.lang.String |
ZBX_PROTO_TAG_ERROR |
static java.lang.String |
ZBX_PROTO_TAG_HOST
Defines the name of the local host of the agent expected by the
server.
|
static java.lang.String |
ZBX_PROTO_TAG_HOSTID |
static java.lang.String |
ZBX_PROTO_TAG_INFO
Defines a comment for a data processing operation has been done
by the server or an error message.
|
static java.lang.String |
ZBX_PROTO_TAG_IP |
static java.lang.String |
ZBX_PROTO_TAG_IPMI_AVAILABLE |
static java.lang.String |
ZBX_PROTO_TAG_IPMI_ERROR |
static java.lang.String |
ZBX_PROTO_TAG_KEY
Defines the name of an entry.
|
static java.lang.String |
ZBX_PROTO_TAG_KEY_ORIG |
static java.lang.String |
ZBX_PROTO_TAG_LOGEVENTID |
static java.lang.String |
ZBX_PROTO_TAG_LOGLASTSIZE |
static java.lang.String |
ZBX_PROTO_TAG_LOGSEVERITY |
static java.lang.String |
ZBX_PROTO_TAG_LOGSOURCE |
static java.lang.String |
ZBX_PROTO_TAG_LOGTIMESTAMP |
static java.lang.String |
ZBX_PROTO_TAG_MTIME |
static java.lang.String |
ZBX_PROTO_TAG_NODEID |
static java.lang.String |
ZBX_PROTO_TAG_PORT |
static java.lang.String |
ZBX_PROTO_TAG_PROXY |
static java.lang.String |
ZBX_PROTO_TAG_REGEXP |
static java.lang.String |
ZBX_PROTO_TAG_REQUEST
States the message to be a request to a Zabbix server.
|
static java.lang.String |
ZBX_PROTO_TAG_RESPONSE
States the message to be a response from a Zabbix server.
|
static java.lang.String |
ZBX_PROTO_TAG_SCRIPTID |
static java.lang.String |
ZBX_PROTO_TAG_SNMP_AVAILABLE |
static java.lang.String |
ZBX_PROTO_TAG_SNMP_ERROR |
static java.lang.String |
ZBX_PROTO_TAG_STATUS |
static java.lang.String |
ZBX_PROTO_TAG_TYPE |
static java.lang.String |
ZBX_PROTO_TAG_VALUE
Defines the value an entry.
|
static java.lang.String |
ZBX_PROTO_VALUE_AGENT_DATA
States that the agent sends the list of fresh metric
values corresponding to the previously requested set of
active checks (see
ActiveAgent ). |
static java.lang.String |
ZBX_PROTO_VALUE_AUTO_REGISTRATION_DATA |
static java.lang.String |
ZBX_PROTO_VALUE_DISCOVERY_DATA |
static java.lang.String |
ZBX_PROTO_VALUE_FAILED
States that the server failed to perform the previously
requested operation.
|
static java.lang.String |
ZBX_PROTO_VALUE_GET_ACTIVE_CHECKS
States that the agent requests the list of active
checks, the set of metrics
(
JabbixActiveMetric ) the server is interested in. |
static java.lang.String |
ZBX_PROTO_VALUE_HISTORY_DATA |
static java.lang.String |
ZBX_PROTO_VALUE_HOST_AVAILABILITY |
static java.lang.String |
ZBX_PROTO_VALUE_PROXY_CONFIG |
static java.lang.String |
ZBX_PROTO_VALUE_PROXY_HEARTBEAT |
static java.lang.String |
ZBX_PROTO_VALUE_SENDER_DATA |
static java.lang.String |
ZBX_PROTO_VALUE_SUCCESS
States that the server has performed the previously
requested operation successfully.
|
Constructor and Description |
---|
JabbixJSONProtocol() |
Modifier and Type | Method and Description |
---|---|
static java.util.Collection<JabbixActiveMetric<?>> |
receiveActiveCheckList(JabbixReader reader)
Reads and returns an active check list.
|
static java.lang.String |
receiveMetricListResponse(JabbixReader reader)
Receives the server response for the sent metric data.
|
static void |
requestActiveCheckList(JabbixWriter writer,
java.lang.String hostName)
Requests a set of metrics for "active" monitoring.
|
static void |
sendMetricList(JabbixWriter writer,
java.lang.String hostName,
java.util.Collection<? extends JabbixMetric<?>> metrics)
Sends the set of metric values to a Zabbix server.
|
public static java.lang.String ZBX_PROTO_TAG_CLOCK
public static java.lang.String ZBX_PROTO_TAG_DATA
public static java.lang.String ZBX_PROTO_TAG_REGEXP
public static java.lang.String ZBX_PROTO_TAG_DELAY
public static java.lang.String ZBX_PROTO_TAG_DRULE
public static java.lang.String ZBX_PROTO_TAG_DCHECK
public static java.lang.String ZBX_PROTO_TAG_HOST
public static java.lang.String ZBX_PROTO_TAG_INFO
public static java.lang.String ZBX_PROTO_TAG_IP
public static java.lang.String ZBX_PROTO_TAG_KEY
public static java.lang.String ZBX_PROTO_TAG_KEY_ORIG
public static java.lang.String ZBX_PROTO_TAG_LOGLASTSIZE
public static java.lang.String ZBX_PROTO_TAG_MTIME
public static java.lang.String ZBX_PROTO_TAG_LOGTIMESTAMP
public static java.lang.String ZBX_PROTO_TAG_LOGSOURCE
public static java.lang.String ZBX_PROTO_TAG_LOGSEVERITY
public static java.lang.String ZBX_PROTO_TAG_LOGEVENTID
public static java.lang.String ZBX_PROTO_TAG_PORT
public static java.lang.String ZBX_PROTO_TAG_PROXY
public static java.lang.String ZBX_PROTO_TAG_REQUEST
public static java.lang.String ZBX_PROTO_TAG_RESPONSE
public static java.lang.String ZBX_PROTO_TAG_STATUS
public static java.lang.String ZBX_PROTO_TAG_TYPE
public static java.lang.String ZBX_PROTO_TAG_VALUE
public static java.lang.String ZBX_PROTO_TAG_SCRIPTID
public static java.lang.String ZBX_PROTO_TAG_HOSTID
public static java.lang.String ZBX_PROTO_TAG_NODEID
public static java.lang.String ZBX_PROTO_TAG_AVAILABLE
public static java.lang.String ZBX_PROTO_TAG_SNMP_AVAILABLE
public static java.lang.String ZBX_PROTO_TAG_IPMI_AVAILABLE
public static java.lang.String ZBX_PROTO_TAG_ERROR
public static java.lang.String ZBX_PROTO_TAG_SNMP_ERROR
public static java.lang.String ZBX_PROTO_TAG_IPMI_ERROR
public static java.lang.String ZBX_PROTO_VALUE_FAILED
public static java.lang.String ZBX_PROTO_VALUE_SUCCESS
public static java.lang.String ZBX_PROTO_VALUE_GET_ACTIVE_CHECKS
JabbixActiveMetric
) the server is interested in.public static java.lang.String ZBX_PROTO_VALUE_PROXY_CONFIG
public static java.lang.String ZBX_PROTO_VALUE_PROXY_HEARTBEAT
public static java.lang.String ZBX_PROTO_VALUE_DISCOVERY_DATA
public static java.lang.String ZBX_PROTO_VALUE_HOST_AVAILABILITY
public static java.lang.String ZBX_PROTO_VALUE_HISTORY_DATA
public static java.lang.String ZBX_PROTO_VALUE_AUTO_REGISTRATION_DATA
public static java.lang.String ZBX_PROTO_VALUE_SENDER_DATA
public static java.lang.String ZBX_PROTO_VALUE_AGENT_DATA
ActiveAgent
).public static void requestActiveCheckList(JabbixWriter writer, java.lang.String hostName) throws java.io.IOException
receiveActiveCheckList(JabbixReader)
method.
The following JSON message is composed and sent to the server:
{"request": "active checks", "host": "<host name>"}The
host name
(host) parameter is the name of the local
host expected by the server
(see ZabbixClient.getHostName()
).writer
- a writer connected to a sockethostName
- the name of the local hostjava.io.IOException
- if there was an I/O exception during the request dispatchZBX_PROTO_TAG_REQUEST
,
ZBX_PROTO_VALUE_GET_ACTIVE_CHECKS
,
ZBX_PROTO_TAG_HOST
public static java.util.Collection<JabbixActiveMetric<?>> receiveActiveCheckList(JabbixReader reader) throws java.io.IOException, JabbixException, JabbixProtocolException
The JSON message of the following form (structure) is expected:
{ "response": "success", "data": [ { "key": "<metric key>", "delay":"<update period>" }, { "key": "<metric key>", "delay":"<update period>" }, ... ] }
The meric key
(key) parameter of each entry is the name
of the metric (see JabbixActiveMetric
) which
value the server expects to receive periodically.
The period of a metric value update is defined by the
corresponding update period
(delay) parameter.
If the server is unable to send the requested active check list
the server sends the message with an unsuccessful status and an
optional comment (see receiveMetricListResponse(JabbixReader)
).
reader
- a reader connected to a socketJabbixActiveMetric
objects representing the
active check listjava.io.IOException
- if there was an I/O exception during the response receptionJabbixException
- if the server sent an unsuccessful statusJabbixProtocolException
- if the protocol was violated (i.e. an unexpected value was
received)requestActiveCheckList(JabbixWriter,String)
,
ZBX_PROTO_TAG_RESPONSE
,
ZBX_PROTO_VALUE_SUCCESS
,
ZBX_PROTO_TAG_DATA
,
ZBX_PROTO_TAG_KEY
,
ZBX_PROTO_TAG_DELAY
,
ZBX_PROTO_VALUE_FAILED
public static void sendMetricList(JabbixWriter writer, java.lang.String hostName, java.util.Collection<? extends JabbixMetric<?>> metrics) throws java.io.IOException
receiveMetricListResponse(JabbixReader)
).
The following JSON message is composed and sent to the server:
{ "request": "agent data", "data": [ { "host": "<host name>", "key": "<metric key>", "value": "<metric value>", "clock": <metric time stamp>" }, { "host": "<host name>", "key": "<metric key>", "value": "<metric value>", "clock": <metric time stamp>" }, ... ] "clock": <message time stamp> }The
host name
(host) parameter is the name of the local
host expected by the server
(see ZabbixClient.getHostName()
).
The meric key
(key) parameter of each entry is the name
of the metric (see JabbixActiveMetric
) which
value the server expects to receive periodically.
The metric value
(value) parameter is the value of the
metric represented as a textual string. Because of the metric
value has not to be sent just after its update, the special
metric time stamp
(clock) entry parameter is used to
explicitly state the update time (see
JabbixActiveMetric.getUpdated()
).
It also seems to be useful to state the time of the request
itself. The message time stamp
(clock) top-level
parameter is used for that porpose.
writer
- a writer connected to a sockethostName
- the name of the local hostmetrics
- the set of metricsjava.io.IOException
- if there was an I/O exception during the dispatchZBX_PROTO_TAG_REQUEST
,
ZBX_PROTO_VALUE_AGENT_DATA
,
ZBX_PROTO_TAG_HOST
,
ZBX_PROTO_TAG_KEY
,
ZBX_PROTO_TAG_VALUE
,
ZBX_PROTO_TAG_CLOCK
,
ZBX_PROTO_TAG_DATA
public static java.lang.String receiveMetricListResponse(JabbixReader reader) throws java.io.IOException, JabbixException, JabbixProtocolException
The JSON message of the following form (structure) is expected:
{ "response": "<status>", "info": "<comment>" }In the successful case the
status
(response) parameter
is stated as success
. And the comment
(info)
parameter contains a human-readable comment on the
data processing has been done.
In the case of an error the status can be stated as
failed
or any other non-successful value. The comment
parameter may or may not be present.
reader
- a reader connected to a socketjava.io.IOException
- if there was an I/O exception during the response receptionJabbixException
- if the server sent an unsuccessful statusJabbixProtocolException
- if the protocol was violated (i.e. an unexpected value was
received)ZBX_PROTO_TAG_RESPONSE
,
ZBX_PROTO_VALUE_SUCCESS
,
ZBX_PROTO_TAG_INFO
,
ZBX_PROTO_VALUE_FAILED