This is a simple lightweight java library for sending data to Zabbix Trapper.
JAR Library: ./out/artifacts/zabbix_server/gmZabbixServerSender-X.X.X.jar
https://www.zabbix.org/wiki/Docs/protocols/zabbix_sender/2.0
https://www.zabbix.org/wiki/Docs/protocols/zabbix_sender/1.8/java_example
Supported all actual versions of Zabbix Server (1.8 and later).
ZabbixServer zs = new ZabbixServer("192.168.0.1, 10051, 5000);
ZabbixObject zo = new ZabbixObject("host1", "key1", "val1");
try {
zs.connect();
// send method will return answer from Zabbix Server as String
System.out.println(zs.send(zo));
} catch (IOException e) {
e.printStackTrace();
} finally {
if (zs.isConnected())
try {
zs.close();
} catch (IOException e) {
e.printStackTrace();
}
}
ZabbixServer zs = new ZabbixServer("192.168.0.1, 10051, 5000);
ArrayList metrics = new ArrayList<>();
metrics.add(new ZabbixObject("host1", "key1_1", "val1"));
metrics.add(new ZabbixObject("host1", "key1_2", "val2"));
metrics.add(new ZabbixObject("host2", "key2", "val3"));
metrics.add(new ZabbixObject("host3", "key3", "val4"));
try {
zs.connect();
// send method will return answer from Zabbix Server as String
System.out.println(zs.send(metrics));
} catch (IOException e) {
e.printStackTrace();
} finally {
if (zs.isConnected())
try {
zs.close();
} catch (IOException e) {
e.printStackTrace();
}
}
The MIT License (MIT)