See www.zabbix.com for the official Zabbix site.

Docs/protocols/zabbix java gateway/2.0

From Zabbix.org
Jump to: navigation, search

Zabbix Java gateway

Zabbix uses a JSON message after the Zabbix header.

Note: Header is mandatory.

Server or proxy queries the Java gateway:

{
        "request":"java gateway jmx",
        "conn":"127.0.0.1",
        "port":12345,
        "username":"username",
        "password":"password",
        "keys":["jmx[\"java.lang:type=Memory\",\"HeapMemoryUsage.used\"]"]}
Note: If user macros are used in key parameters, they will expanded before sending to the Java gateway.

Returning the values:

{
  "data": [{"value": "1348360"}],
  "response": "success"
}

Unsupported item key:

{
  "data": [{"error": "key ID 'zabbix' is not supported"}],
  "response": "success"
}

Incorrect JMX attribute:

{
  "data": [
    {"error": "No such attribute: HeapMemoryUsage22"}
  ],
  "response": "success"
}

Multiple keys may be requested by server in a single connection:

{
        "request":"java gateway jmx",
        "conn":"127.0.0.1",
        "port":12345,
        "username":"username",
        "password":"password",
        "keys":["jmx[\"java.lang:type=Memory\",\"HeapMemoryUsage22.used\"]","jmx[\"java.lang:type=Memory\",\"HeapMemoryUsage.used\"]"]}

Java gateway responds with values or errors as appropriate. Order in response matches key order in the request.

{
  "data": [
    {"error": "No such attribute: HeapMemoryUsage22"},
    {"value": "1901560"}
  ],
  "response": "success"
}

If connection to the JMX endpoint is refused:

{ "response" : "failed", "error" : "java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connecti
on refused to host: 127.0.0.1; nested exception is: \n\tjava.net.ConnectException: Connection refused]" }

If the JMX endpoint does not respond as expected:

{ "response" : "failed", "error" : "java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.CommunicationException [Root exception is java.rmi.ConnectIOException: non-JRMP server at remote endpoint]" }

Querying internal value:

{
        "request":"java gateway internal",
        "keys":["zabbix[java,,version]"]}

Internal value response:

{
  "data": [{"value": "2.0.5rc1"}],
  "response": "success"
}

In case of an incorrect internal item parameters:

{"error": "third parameter 'version22' is not supported"}],
  "response": "success"
}

Sending incorrect request can trigger various other responses. Some examples:

{ "response" : "failed", "error" : "bad protocol header: 5A 42 58 44 5C" }
{ "response" : "failed", "error" : "bad data length: 8391162085809418875" }
{ "response" : "failed", "error" : "bad request tag value: 'sender data'" }
{ "response" : "failed", "error" : "Unterminated string at 111 [character 112 line 1]" }
{ "response" : "failed", "error" : "Illegal escape. at 77 [character 78 line 1]" }
{ "response" : "failed", "error" : "Expected a ',' or '}' at 129 [character 130 line 1]" }
{ "response" : "failed", "error" : "Expected a ',' or ']' at 128 [character 129 line 1]" }