public class JabbixProtocol
extends java.lang.Object
The base Zabbix protocol for agent-server communication is a kind of a simple binary protocol and is used to transfer arbitrary portions of data between a Zabbix-compatible agent (for instance, Jabbix based program) and a Zabbix server.
Each such a transfer is called a message. Each message has the following form (structure):
| 4 Bytes | 1 Byte | 8 Bytes | LENGTH Bytes | HEADER VERION LENGTH MESSAGE DATAThe
HEADER
field is a 4 byte 4 ASCII character sequence, currently
defined as ZBXD
. The next VERSION
one byte width
field states the used protocol version. The supported version now
is 1 (which is 01h).
The next 8 byte field LENGTH
contains the little-endian 64
bit integer number defining the length of the next MESSAGE
DATA
part. All numeric data is presented as little-endian numbres
too.
For compatibility and to simplify the agent-server programs, the another separator-based protocol can be used. In that protocol the messages has no predefined structure, instead of that one of the separator characters is used to mark the end of each message. Because of the newline character (0Ah) is also in separator set, the plaintext messages can be transferred as is.
The main use of the unstructured plaintext message protocol is the Zabbix server to passive agent communication: the server sends a plaintext metric key to the passive agent without any header. However, the agent is not restricted to use the plaintext protocol and can answer using the structured version if convenient.
Also, the unstructurred answers can be originated by a Zabbix server in some cases.
AgentServer
Modifier and Type | Field and Description |
---|---|
static int |
AGENT_PORT
The default agent port number (10050).
|
static java.lang.String |
HEADER
Four-letter protocol header.
|
static java.lang.String |
SEPARATORS
The set of message separators.
|
static int |
SERVER_PORT
The default Zabbix server port number (10051).
|
static java.lang.String |
VERSION
Protocol version (one byte).
|
Constructor and Description |
---|
JabbixProtocol() |
Modifier and Type | Method and Description |
---|---|
static JabbixReader |
getReader(java.io.InputStream in)
Returns a reader connected to the specified stream.
|
static JabbixWriter |
getWriter(java.io.OutputStream out)
Returns a writer connected to the specified stream.
|
static boolean |
isSeparator(char c)
Indicates if the specified character is a message separator.
|
static java.lang.String |
removeSeparators(java.lang.String str)
Returns the given string with all separator characters removed.
|
public static java.lang.String HEADER
For Zabbix the character sequence ZBXD
is used.
public static java.lang.String VERSION
Currently the protocol version is 1 (01h).
public static java.lang.String SEPARATORS
If length of the message is not explicitly stated in the header, the end of the message is determined by a separator character. This string contains the sequence of that sort of characters.
Currently the separator characters are:
public static int AGENT_PORT
public static int SERVER_PORT
public static JabbixReader getReader(java.io.InputStream in)
in
- the input stream to read frompublic static JabbixWriter getWriter(java.io.OutputStream out)
out
- the output stream to write topublic static boolean isSeparator(char c)
c
- the character to testSEPARATORS
public static java.lang.String removeSeparators(java.lang.String str)
str
- a string