Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It does not support Zabbix 4 #62

Closed
wanghy8166 opened this issue Nov 5, 2018 · 24 comments

Comments

@wanghy8166
Copy link

commented Nov 5, 2018

When will it be repaired? The reasons are as follows:

https://www.zabbix.com/documentation/4.0/manual/installation/upgrade_notes_400#plain_text_protocol_dropped

Plain text protocol dropped
Support for the plain text protocol has been dropped and a header is now mandatory. A header has been added to Zabbix get requests, Zabbix server/proxy passive check requests and frontend requests to Zabbix server.

As a consequence, Zabbix agents that are older than version 1.4 are no longer supported. Also, messages from self-written senders will be rejected if the header is absent. Whereas previously Zabbix trappers would accept messages without headers as well as messages with headers, now they will only accept messages with protocol header.

@wanghy8166

This comment has been minimized.

Copy link
Author

commented Nov 5, 2018

Orabbix has the same problem.

orabbix log:
2018-11-02 20:00:50,172 [pool-1-thread-6] WARN Orabbix - received unexpected response '' for key 'alive'
2018-11-02 20:00:50,174 [pool-1-thread-6] WARN Orabbix - received unexpected response '' for key 'Orabbix.Version'
2018-11-02 20:00:50,175 [pool-1-thread-6] WARN Orabbix - received unexpected response '' for key 'tps'
2018-11-02 20:00:50,175 [pool-1-thread-6] INFO Orabbix - Done with dbJob on database orclpdb1 QueryList elapsed time 34 ms

zabbix server log:
426:20181102:120450.197 Message from 172.18.0.1 is missing header. Message ignored.
427:20181102:120450.199 Message from 172.18.0.1 is missing header. Message ignored.

@rtau

This comment has been minimized.

Copy link

commented Nov 5, 2018

For reference, zabbix 4.0 manual provide examples on how to generate the header required in various languages.
https://www.zabbix.com/documentation/4.0/manual/appendix/protocols/header_datalen

@wanghy8166

This comment has been minimized.

Copy link
Author

commented Nov 8, 2018

For reference, zabbix 4.0 manual provide examples on how to generate the header required in various languages.
https://www.zabbix.com/documentation/4.0/manual/appendix/protocols/header_datalen

Yes, I started learning Eclipse and compiled and exported new jar file, as follows:
https://github.com/wanghy8166/dbforbix06/blob/master/dbforbix-0.6.1.jar
https://github.com/wanghy8166/orabbix/blob/master/orabbix-1.2.4.jar

@rtau

This comment has been minimized.

Copy link

commented Nov 8, 2018

If it works for you, maybe you could create a pull request for so others could benefit as well?

@isoinh

This comment has been minimized.

Copy link

commented Nov 27, 2018

@wanghy8166, did you manage to get it working?

We are using dbforbix-2.2-beta and can't get it to work. We've tried to add:
byte[] header = new byte[] {
'Z', 'B', 'X', 'D', '\1',
(byte)(data.length & 0xFF),
(byte)((data.length >> 8) & 0xFF),
(byte)((data.length >> 16) & 0xFF),
(byte)((data.length >> 24) & 0xFF),
'\0', '\0', '\0', '\0'};
to ZabbixSender.java file after line 116 (LOG.warn("ZabbixSender - messageWithoutHeader:" + dataAsString); without success.

@smartmarmot, do you perhaps have any insight for this problem?

@juu7nitw23

This comment has been minimized.

Copy link

commented Nov 27, 2018

we are very interested in a solution as well

@lucassebben

This comment has been minimized.

Copy link

commented Dec 4, 2018

@wanghy8166 Thanks for the .jar file.
I'm using this and almost all queries are sending data to Zabbix server correctly but few are showing connection error with server.
I'm running Orabbix on the Zabbix server (version 4.0.2) and the log return "Message from 127.0.0.1 is shorter than expected 12435439 bytes. Message ignored.". I've checked the timestamp and match with Hit Ratio and Pin Hit Ratio queries.

@smartmarmot Do you have plans to implement the header on version Orabbix 1.2.3? That was running smoothly!

@wanghy8166

This comment has been minimized.

Copy link
Author

commented Dec 11, 2018

@wanghy8166 Thanks for the .jar file.
I'm using this and almost all queries are sending data to Zabbix server correctly but few are showing connection error with server.
I'm running Orabbix on the Zabbix server (version 4.0.2) and the log return "Message from 127.0.0.1 is shorter than expected 12435439 bytes. Message ignored.". I've checked the timestamp and match with Hit Ratio and Pin Hit Ratio queries.

@smartmarmot Do you have plans to implement the header on version Orabbix 1.2.3? That was running smoothly!

Please refer to:
https://github.com/wanghy8166/orabbix/blob/master/Add%20support%20for%20Zabbix%204.txt

@smartmarmot

This comment has been minimized.

Copy link
Owner

commented Dec 11, 2018

Unfortunately no plan so far as I moved on a different role years ago and I don't have anymore chance to test it. (e.g. no DB and no Zabbix where I'm currently working :) )

@roemdo

This comment has been minimized.

Copy link

commented Dec 17, 2018

@isoinh This was working for me (DBforBix 2.2 beta)

	String dataAsString = protocol.encodeItem(nextItem);
						
	byte[] data = dataAsString.getBytes("UTF-8");
	
	byte[] header = new byte[] {
		 'Z', 'B', 'X', 'D', '\1',
		(byte)(data.length & 0xFF),
		(byte)((data.length >> 8) & 0xFF),
		(byte)((data.length >> 16) & 0xFF),
		(byte)((data.length >> 24) & 0xFF),
		'\0', '\0', '\0', '\0'};
						 
		byte[] packet = new byte[header.length + data.length];
		System.arraycopy(header, 0, packet, 0, header.length);
		System.arraycopy(data, 0, packet, header.length, data.length);
					
		os.write(packet);
		os.flush();

		in = zabbix.getInputStream();
		final int read = in.read(response);
			
		if (!protocol.isResponeOK(read, response))
		LOG.warn("ZabbixSender - received unexpected response (class ZabbixSender)'" + new String(response).trim() + "' for key '" + nextItem.getKey()
					+ "'");
		break;

}

@ultramanyuan

This comment has been minimized.

Copy link

commented Dec 18, 2018

looks like not support "dbxxx.ExtraQueryListFile" in configuration file anymore .Appreciate for any help about that.

@wanghy8166

This comment has been minimized.

Copy link
Author

commented Dec 23, 2018

looks like not support "dbxxx.ExtraQueryListFile" in configuration file anymore .Appreciate for any help about that.

Please try the orabbix-1.2.4w.jar file

@ricardorava

This comment has been minimized.

Copy link

commented Jan 10, 2019

I'm using Orabbix v1.2.3 and with the help of my coleague Bernardo found a solution. We changed just the file Sender.class in orabbix-1.2.3.jar. We used Eclipse to edit and save.

1 - Download orabbix-src-1.2.3.zip from https://sourceforge.net/projects/orabbix/files/

2 - Edit Sender.java file located at ./com.smartmarmot/orabbix/

2.1 - Original Code

        Socket zabbix = null;
        OutputStreamWriter out = null;
        InputStream in = null;
        Enumeration<String> serverlist  = zabbixServers.keys();

        while (serverlist.hasMoreElements()){
        	String zabbixServer = serverlist.nextElement();
	        try {
				zabbix = new Socket(zabbixServer, zabbixServers.get(
						zabbixServer).intValue());
	            zabbix.setSoTimeout(TIMEOUT);
	
	            out = new OutputStreamWriter(zabbix.getOutputStream());
	            out.write(message.toString());
	            out.flush();

2.2 - New code

        Socket zabbix = null;
//      OutputStreamWriter out = null;
        OutputStream out = null;
        InputStream in = null;
        Enumeration<String> serverlist  = zabbixServers.keys();

        while (serverlist.hasMoreElements()){
        	String zabbixServer = serverlist.nextElement();
	        try {
				zabbix = new Socket(zabbixServer, zabbixServers.get(
						zabbixServer).intValue());
	            zabbix.setSoTimeout(TIMEOUT);

    	    byte[] data = message.toString().getBytes("UTF-8");

    	    byte[] header = new byte[] {
	        'Z', 'B', 'X', 'D', '\1',
			(byte)(data.length & 0xFF),
			(byte)((data.length >> 8) & 0xFF),
			(byte)((data.length >> 16) & 0xFF),
			(byte)((data.length >> 24) & 0xFF),
			'\0', '\0', '\0', '\0'};
						 
		    byte[] packet = new byte[header.length + data.length];
		    System.arraycopy(header, 0, packet, 0, header.length);
		    System.arraycopy(data, 0, packet, header.length, data.length);
	
//	            out = new OutputStreamWriter(zabbix.getOutputStream());
	            out = zabbix.getOutputStream();
	            out.write(packet);
	            out.flush();

3 - Compile Sender.java generating the file Sender.class

NOTE: You will need the files located at ./lib (orabbix-1.2.3.zip)

4 - In the original file orabbix-1.2.3.jar substitute just the file Sender.class, located at ./com/smartmarmot/orabbix/

NOTE: Don't compile all project

5 - Restart Orabbix

@ErwinUZA

This comment has been minimized.

Copy link

commented Jan 18, 2019

Has this been resolved for DBforBIX?
We use this for monitoring MSSQL, Oracle and Sybase databases.

@smartmarmot

This comment has been minimized.

Copy link
Owner

commented Jan 22, 2019

Hmmm sorry guys but I am not able to replicate the issue with Version 2.4-beta.
You're using a quite old version of orabbix (really old actually).
DEBUG - ZabbixSender: Sending to 127.0.01:10051 Items[32]=[DB3 oracle.librarycache.pinhitratio[QUEUE]: 100, DB3 oracle.librarycache.pinhitratio[TRIGGER]: 100, DB3 oracle.librarycache.hitratio[AUDIT_POLICY]: 98.32, DB3 oracle.librarycache.hitratio[OBJECT_ID]: 0, DB3 oracle.librarycache.hitratio[SCHEMA]: 99.54, DB3 oracle.librarycache.hitratio[ACCOUNT_STATUS]: 99.35, DB3 oracle.librarycache.hitratio[DIRECTORY]: 66.66, DB3 oracle.librarycache.hitratio[PDB]: 50, DB3 oracle.librarycache.pinhitratio[RULESET]: 100, DB3 oracle.librarycache.pinhitratio[AUDIT_POLICY]: 100, DB3 oracle.librarycache.hitratio[TABLE/PROCEDURE]: 72.01, DB3 oracle.librarycache.pinhitratio[TABLE/PROCEDURE]: 97.67, DB3 oracle.librarycache.pinhitratio[BODY]: 98.81, DB3 oracle.librarycache.hitratio[SQL_AREA_BUILD]: 15.61, DB3 oracle.librarycache.hitratio[EDITION]: 97.65, DB3 oracle.librarycache.pinhitratio[INDEX]: 87.83, DB3 oracle.librarycache.hitratio[RULESET]: 0, DB3 oracle.librarycache.hitratio[DBINSTANCE]: 0, DB3 oracle.librarycache.hitratio[QUEUE]: 66.66, DB3 oracle.librarycache.pinhitratio[DIRECTORY]: 100, DB3 oracle.librarycache.pinhitratio[SQL_AREA_STATS]: 100, DB3 oracle.librarycache.pinhitratio[SQL_AREA]: 99.18, DB3 oracle.librarycache.pinhitratio[CLUSTER]: 100, DB3 oracle.librarycache.hitratio[SQL_AREA_STATS]: 5.07, DB3 oracle.discovery.DBforBIX.config[librarycache,{$DSN}]: {"data":[{"{#NAMESPACE}":"SQL_AREA"},{"{#NAMESPACE}":"TABLE/PROCEDURE"},{"{#NAMESPACE}":"BODY"},{"{#NAMESPACE}":"TRIGGER"},{"{#NAMESPACE}":"INDEX"},{"{#NAMESPACE}":"CLUSTER"},{"{#NAMESPACE}":"DIRECTORY"},{"{#NAMESPACE}":"QUEUE"},{"{#NAMESPACE}":"RULESET"},{"{#NAMESPACE}":"EDITION"},{"{#NAMESPACE}":"DBLINK"},{"{#NAMESPACE}":"OBJECT_ID"},{"{#NAMESPACE}":"SCHEMA"},{"{#NAMESPACE}":"DBINSTANCE"},{"{#NAMESPACE}":"SQL_AREA_STATS"},{"{#NAMESPACE}":"ACCOUNT_STATUS"},{"{#NAMESPACE}":"SQL_AREA_BUILD"},{"{#NAMESPACE}":"PDB"},{"{#NAMESPACE}":"AUDIT_POLICY"}]}, DB3 oracle.librarycache.hitratio[DBLINK]: 99.53, DB3 oracle.librarycache.hitratio[BODY]: 70.77, DB3 oracle.librarycache.hitratio[CLUSTER]: 98, DB3 oracle.librarycache.hitratio[SQL_AREA]: 41.18, DB3 oracle.librarycache.hitratio[TRIGGER]: 71.73, DB3 oracle.librarycache.hitratio[INDEX]: 35.6, DB3 oracle.librarycache.pinhitratio[EDITION]: 100]
DEBUG - ZabbixSender[data]: {"request":"history data","host":"DBforBIX","data":[{"host":"DB3","key":"oracle.librarycache.pinhitratio[QUEUE]","value":"100","clock":1548147361,"ns":0},{"host":"DB3","key":"oracle.librarycache.pinhitratio[TRIGGER]","value":"100","clock":1548147361,"ns":0},{"host":"DB3","key":"oracle.librarycache.hitratio[AUDIT_POLICY]","value":"98.32","clock":1548147361,"ns":0},{"host":"DB3","key":"oracle.librarycache.hitratio[OBJECT_ID]","value":"0","clock":1548147361,"ns":0},{"host":"DB3","key":"oracle.librarycache.hitratio[SCHEMA]","value":"99.54","clock":1548147361,"ns":0},{"host":"DB3","key":"oracle.librarycache.hitratio[ACCOUNT_STATUS]","value":"99.35","clock":1548147361,"ns":0},{"host":"DB3","key":"oracle.librarycache.hitratio[DIRECTORY]","value":"66.66","clock":1548147361,"ns":0},{"host":"DB3","key":"oracle.librarycache.hitratio[PDB]","value":"50","clock":1548147361,"ns":0},{"host":"DB3","key":"oracle.librarycache.pinhitratio[RULESET]","value":"100","clock":1548147361,"ns":0},{"host":"DB3","key":"oracle.librarycache.pinhitratio[AUDIT_POLICY]","value":"100","clock":1548147361,"ns":0},{"host":"DB3","key":"oracle.librarycache.hitratio[TABLE/PROCEDURE]","value":"72.01","clock":1548147361,"ns":0},{"host":"DB3","key":"oracle.librarycache.pinhitratio[TABLE/PROCEDURE]","value":"97.67","clock":1548147361,"ns":0},{"host":"DB3","key":"oracle.librarycache.pinhitratio[BODY]","value":"98.81","clock":1548147361,"ns":0},{"host":"DB3","key":"oracle.librarycache.hitratio[SQL_AREA_BUILD]","value":"15.61","clock":1548147361,"ns":0},{"host":"DB3","key":"oracle.librarycache.hitratio[EDITION]","value":"97.65","clock":1548147361,"ns":0},{"host":"DB3","key":"oracle.librarycache.pinhitratio[INDEX]","value":"87.83","clock":1548147361,"ns":0},{"host":"DB3","key":"oracle.librarycache.hitratio[RULESET]","value":"0","clock":1548147361,"ns":0},{"host":"DB3","key":"oracle.librarycache.hitratio[DBINSTANCE]","value":"0","clock":1548147361,"ns":0},{"host":"DB3","key":"oracle.librarycache.hitratio[QUEUE]","value":"66.66","clock":1548147361,"ns":0},{"host":"DB3","key":"oracle.librarycache.pinhitratio[DIRECTORY]","value":"100","clock":1548147361,"ns":0},{"host":"DB3","key":"oracle.librarycache.pinhitratio[SQL_AREA_STATS]","value":"100","clock":1548147361,"ns":0},{"host":"DB3","key":"oracle.librarycache.pinhitratio[SQL_AREA]","value":"99.18","clock":1548147361,"ns":0},{"host":"DB3","key":"oracle.librarycache.pinhitratio[CLUSTER]","value":"100","clock":1548147361,"ns":0},{"host":"DB3","key":"oracle.librarycache.hitratio[SQL_AREA_STATS]","value":"5.07","clock":1548147361,"ns":0},{"host":"DB3","key":"oracle.discovery.DBforBIX.config[librarycache,{$DSN}]","value":"{"data":[{"{#NAMESPACE}":"SQL_AREA"},{"{#NAMESPACE}":"TABLE/PROCEDURE"},{"{#NAMESPACE}":"BODY"},{"{#NAMESPACE}":"TRIGGER"},{"{#NAMESPACE}":"INDEX"},{"{#NAMESPACE}":"CLUSTER"},{"{#NAMESPACE}":"DIRECTORY"},{"{#NAMESPACE}":"QUEUE"},{"{#NAMESPACE}":"RULESET"},{"{#NAMESPACE}":"EDITION"},{"{#NAMESPACE}":"DBLINK"},{"{#NAMESPACE}":"OBJECT_ID"},{"{#NAMESPACE}":"SCHEMA"},{"{#NAMESPACE}":"DBINSTANCE"},{"{#NAMESPACE}":"SQL_AREA_STATS"},{"{#NAMESPACE}":"ACCOUNT_STATUS"},{"{#NAMESPACE}":"SQL_AREA_BUILD"},{"{#NAMESPACE}":"PDB"},{"{#NAMESPACE}":"AUDIT_POLICY"}]}","clock":1548147361,"ns":0},{"host":"DB3","key":"oracle.librarycache.hitratio[DBLINK]","value":"99.53","clock":1548147361,"ns":0},{"host":"DB3","key":"oracle.librarycache.hitratio[BODY]","value":"70.77","clock":1548147361,"ns":0},{"host":"DB3","key":"oracle.librarycache.hitratio[CLUSTER]","value":"98","clock":1548147361,"ns":0},{"host":"DB3","key":"oracle.librarycache.hitratio[SQL_AREA]","value":"41.18","clock":1548147361,"ns":0},{"host":"DB3","key":"oracle.librarycache.hitratio[TRIGGER]","value":"71.73","clock":1548147361,"ns":0},{"host":"DB3","key":"oracle.librarycache.hitratio[INDEX]","value":"35.6","clock":1548147361,"ns":0},{"host":"DB3","key":"oracle.librarycache.pinhitratio[EDITION]","value":"100","clock":1548147361,"ns":0}],"clock":"1548147361","ns":"0"}
DEBUG - ZabbixSender[resp]: {"response":"success","info":"processed: 32; failed: 0; total: 32; seconds spent: 0.014340"}
DEBUG - Scheduler.run() 120

@smartmarmot

This comment has been minimized.

Copy link
Owner

commented Jan 24, 2019

Can you please let me know how exactly you're experiencing this issue? I'm trying with zabbix 4.0.2 and it works perfectly.

@smartmarmot

This comment has been minimized.

Copy link
Owner

commented Jan 24, 2019

Ahhhh I realized all of you are referring to the old Orabbix!

@smartmarmot

This comment has been minimized.

Copy link
Owner

commented Jan 24, 2019

I'm now closing this issue as it refers to another product.

snickerjp added a commit to snickerjp/orabbix that referenced this issue Feb 4, 2019

@StepFH

This comment has been minimized.

Copy link

commented Feb 14, 2019

Has anyone encountered such a problem? Please help solve this problem.
I add code like this :

byte[] data = message.toString().getBytes("UTF-8");
byte[] header = new byte[] {
        'Z', 'B', 'X', 'D', '\1',
		(byte)(data.length & 0xFF),
		(byte)((data.length >> 8) & 0xFF),
		(byte)((data.length >> 16) & 0xFF),
		(byte)((data.length >> 24) & 0xFF),
		'\0', '\0', '\0', '\0'};
					 
byte[] packet = new byte[header.length + data.length];
System.arraycopy(header, 0, packet, 0, header.length);
System.arraycopy(data, 0, packet, header.length, data.length);

But when the code was executed at
zabbix = new Socket(zabbixServer, ((Integer)this.zabbixServers.get(zabbixServer)).intValue());
An exception has occurred:
java.net.SocketTimeoutException: Read timed out 2019-02-14 14:42:53,986 [pool-1-thread-3] ERROR Orabbix - Error contacting Zabbix server 10.10.9.47 on port 10051
but if I try to connect client to server with ‘ping’ or 'telnet' command , it success.
I don't know why the connection timed out.By the way I used 30000ms as timeout's time.

@oapinis85

This comment has been minimized.

Copy link

commented Feb 25, 2019

I'm using Orabbix v1.2.3 and with the help of my coleague Bernardo found a solution. We changed just the file Sender.class in orabbix-1.2.3.jar. We used Eclipse to edit and save.
1 - Download orabbix-src-1.2.3.zip from https://sourceforge.net/projects/orabbix/files/
2 - Edit Sender.java file located at ./com.smartmarmot/orabbix/
2.1 - Original Code
Socket zabbix = null;
OutputStreamWriter out = null;
InputStream in = null;
Enumeration serverlist = zabbixServers.keys();

    while (serverlist.hasMoreElements()){
    	String zabbixServer = serverlist.nextElement();
      try {
  		zabbix = new Socket(zabbixServer, zabbixServers.get(
  				zabbixServer).intValue());
          zabbix.setSoTimeout(TIMEOUT);

          out = new OutputStreamWriter(zabbix.getOutputStream());
          out.write(message.toString());
          out.flush();

2.2 - New code
Socket zabbix = null;
// OutputStreamWriter out = null;
OutputStream out = null;
InputStream in = null;
Enumeration serverlist = zabbixServers.keys();

    while (serverlist.hasMoreElements()){
    	String zabbixServer = serverlist.nextElement();
      try {
  		zabbix = new Socket(zabbixServer, zabbixServers.get(
  				zabbixServer).intValue());
          zabbix.setSoTimeout(TIMEOUT);

	    byte[] data = message.toString().getBytes("UTF-8");

	    byte[] header = new byte[] {
      'Z', 'B', 'X', 'D', '\1',
  	(byte)(data.length & 0xFF),
  	(byte)((data.length >> 8) & 0xFF),
  	(byte)((data.length >> 16) & 0xFF),
  	(byte)((data.length >> 24) & 0xFF),
  	'\0', '\0', '\0', '\0'};
  				 
      byte[] packet = new byte[header.length + data.length];
      System.arraycopy(header, 0, packet, 0, header.length);
      System.arraycopy(data, 0, packet, header.length, data.length);

// out = new OutputStreamWriter(zabbix.getOutputStream());
out = zabbix.getOutputStream();
out.write(packet);
out.flush();

3 - Compile Sender.java generating the file Sender.class
NOTE: You will need the files located at ./lib (orabbix-1.2.3.zip)
4 - In the original file orabbix-1.2.3.jar substitute just the file Sender.class, located at ./com/smartmarmot/orabbix/
NOTE: Don't compile all project
5 - Restart Orabbix

Hello!

We did it what you decribet, but did not work for as,
We also have orabbix version 1.2.3
How you compiled the file?
We compiled:
"
export PATH=/tmp/jdk1.8.0_202/bin:$PATH
export SOURCEPATH=
/tmp
export CLASSPATH=~/tmp/lib/*

javac -classpath "$CLASSPATH" -sourcepath "$SOURCEPATH" com/smartmarmot/orabbix/Sender.java
Compilde file: ~/tmp/com/smartmarmot/orabbix/Sender.class
"

@ricardorava

This comment has been minimized.

Copy link

commented Feb 25, 2019

I'm using Orabbix v1.2.3 and with the help of my coleague Bernardo found a solution. We changed just the file Sender.class in orabbix-1.2.3.jar. We used Eclipse to edit and save.
1 - Download orabbix-src-1.2.3.zip from https://sourceforge.net/projects/orabbix/files/
2 - Edit Sender.java file located at ./com.smartmarmot/orabbix/
2.1 - Original Code
Socket zabbix = null;
OutputStreamWriter out = null;
InputStream in = null;
Enumeration serverlist = zabbixServers.keys();

    while (serverlist.hasMoreElements()){
    	String zabbixServer = serverlist.nextElement();
      try {
  		zabbix = new Socket(zabbixServer, zabbixServers.get(
  				zabbixServer).intValue());
          zabbix.setSoTimeout(TIMEOUT);

          out = new OutputStreamWriter(zabbix.getOutputStream());
          out.write(message.toString());
          out.flush();

2.2 - New code
Socket zabbix = null;
// OutputStreamWriter out = null;
OutputStream out = null;
InputStream in = null;
Enumeration serverlist = zabbixServers.keys();

    while (serverlist.hasMoreElements()){
    	String zabbixServer = serverlist.nextElement();
      try {
  		zabbix = new Socket(zabbixServer, zabbixServers.get(
  				zabbixServer).intValue());
          zabbix.setSoTimeout(TIMEOUT);

	    byte[] data = message.toString().getBytes("UTF-8");

	    byte[] header = new byte[] {
      'Z', 'B', 'X', 'D', '\1',
  	(byte)(data.length & 0xFF),
  	(byte)((data.length >> 8) & 0xFF),
  	(byte)((data.length >> 16) & 0xFF),
  	(byte)((data.length >> 24) & 0xFF),
  	'\0', '\0', '\0', '\0'};
  				 
      byte[] packet = new byte[header.length + data.length];
      System.arraycopy(header, 0, packet, 0, header.length);
      System.arraycopy(data, 0, packet, header.length, data.length);

// out = new OutputStreamWriter(zabbix.getOutputStream());
out = zabbix.getOutputStream();
out.write(packet);
out.flush();
3 - Compile Sender.java generating the file Sender.class
NOTE: You will need the files located at ./lib (orabbix-1.2.3.zip)
4 - In the original file orabbix-1.2.3.jar substitute just the file Sender.class, located at ./com/smartmarmot/orabbix/
NOTE: Don't compile all project
5 - Restart Orabbix

Hello!

We did it what you decribet, but did not work for as,
We also have orabbix version 1.2.3
How you compiled the file?
We compiled:
"
export PATH=/tmp/jdk1.8.0_202/bin:$PATH
export SOURCEPATH=/tmp
export CLASSPATH=~/tmp/lib/*

javac -classpath "$CLASSPATH" -sourcepath "$SOURCEPATH" com/smartmarmot/orabbix/Sender.java
Compilde file: ~/tmp/com/smartmarmot/orabbix/Sender.class
"

Hi, we used Eclipse to edit and compile. Don't forget that you will need the files located at ./lib (orabbix-1.2.3.zip) to compile Sender.java.

@AldoriJunior

This comment has been minimized.

Copy link

commented Apr 16, 2019

Hi,

Someone fixed the header in DBforBIX ? I can send data to Zabbix 3, but in Zabbix 4, the ZabbixSender[resp] come NULL.

[2019-04-16 20:37:50] [DEBUG] [127.0.0.1:10052/DBforBIX/ZABBIX/ZABBIX/mysql.test.DBforBix.config[test,ZABBIX][run(Scheduler.java:87)]]: Scheduler.run() 30
[2019-04-16 20:37:50] [DEBUG] [ZabbixSender[run(ZabbixSender.java:99)]]: ZabbixSender: Sending to 127.0.0.1:10052 Items[1]=[ZABBIX mysql.test.DBforBix.config[teste,ZABBIX]: 91]
[2019-04-16 20:37:50] [DEBUG] [ZabbixSender[run(ZabbixSender.java:123)]]: ZabbixSender[data]: {"request":"history data","host":"DBforBIX","data":[{"host":"ZABBIX","key":"mysql.test.DBforBix.config[test,ZABBIX]","value":"91","clock":1555447070,"ns":0}],"clock":"1555447070","ns":"0"}
[2019-04-16 20:37:50] [DEBUG] [ZabbixSender[run(ZabbixSender.java:125)]]: ZabbixSender[resp]:

@linwinfan

This comment has been minimized.

Copy link

commented Apr 23, 2019

I have pull code and change code ,build and test on zabbix4.2.
please go to : https://github.com/linwinfan/dbforbix4.2

@smartmarmot

This comment has been minimized.

Copy link
Owner

commented Apr 23, 2019

There is no pull request on this repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.