Setting up the Zabbix Java gateway

Let's start by getting the gateway up and running. If you installed from packages, there's likely a Java gateway package available; just install that one. If you installed from source, the Java gateway can be compiled and installed by running the following from the Zabbix source directory:

$ ./configure --enable-java && make install
If the compilation fails because it is unable to find javac, you might be missing Java development packages. The package name could be similar to java-1_8_0-openjdk-devel. Consult your distribution's documentation for the exact package name.

By default, when compiling from source, Zabbix Java gateway files are placed in the /usr/local/sbin/zabbix_java directory. From here on, we will use files found in that directory. If you installed from packages, consult the package configuration information to locate those files. The configuration file can probably be found at /etc/zabbix/zabbix_java_gateway.conf.

Let's try something simple: just starting up the gateway. Go to the Java gateway directory and run the following:

# ./startup.sh

The Zabbix Java gateway comes with a convenient startup script, which we used here. If all went well, you should see no output, and a Java process should appear in the process list. Additionally, the gateway should listen on port 10052. While this port is not an officially-registered port for the Zabbix Java gateway, it's just one port above the Zabbix trapper port, and there does not seem to be any other application using that port. With the gateway running, we still have to tell Zabbix server where the gateway can be found. Open zabbix_server.conf and look for the JavaGateway parameter. By default, it is not set, and we have to configure the gateway IP or hostname here. As we can point the server at a remote system, we are not required to run the Java gateway on the same system as where Zabbix server is located, in some cases, we might want to place the gateway closer to the Java application server, such as by setting this parameter to the localhost IP address:

JavaGateway=127.0.0.1 

Right below in our config file is a parameter called JavaGatewayPort. By default, it is set to 10052, which is the same unregistered port as our running gateway already listens on—so we won't change that. The next parameter is StartJavaPollers. As with IPMI pollers, no Java pollers are started by default. We won't hammer our Java gateway much, so enable a single Java poller as follows:

StartJavaPollers=1 

With this, Zabbix server should be sufficiently configured. Restart it to apply the Java gateway configuration changes. Great! We have the gateway running, and Zabbix server knows where it is. Now, we just need something to monitor. If you have a Java application server that you can use for testing, try monitoring it. If not, or for something simpler to start with, you could monitor the gateway itself. It is a Java application, and thus, the JMX infrastructure is available. There's one thing we should change before enabling JMX for the gateway. Java is quite picky about DNS and name resolution in general. If JMX functionality is enabled and the local system hostname does not resolve, Java applications are likely to fail to start up. For a local Java gateway, check the /etc/hosts file. If there is no entry for the current hostname, add the following line:

127.0.0.1 testhost 

We're ready to enable JMX functionality for the gateway now; it is not enabled by default. To enable JMX on the Zabbix Java gateway, edit the startup.sh (or zabbix_java_gateway.conf) script we used earlier, and look for the following line:

# uncomment to enable remote monitoring of the standard JMX objects on the Zabbix Java Gateway itself 

As the first line says, uncomment the two lines following it.

A single variable is assigned across two lines in this script !

One parameter in there is worth paying extra attention to, as follows:

-Dcom.sun.management.jmxremote.port=12345 

This sets the JMX port, the one that the gateway itself will query. Yes, in this case, we will start a process that will connect to itself on that port to query JMX data. The port is definitely not a standard one, as you might guess, it's just a sequence of 12345. Other Java applications will most likely use a different port, which you will have to find out by yourself.

If you installed from packages, a recent package should include the same lines in the init script. If not, consider reporting that to the package maintainers, and use the following parameters in addition to the port parameter, listed in the previous code:

-Dcom.sun.management.jmxremote 
-Dcom.sun.management.jmxremote.authenticate=false 
-Dcom.sun.management.jmxremote.ssl=false 

The first parameter tells Java to enable JMX, and the last two parameters instruct Java not use any authentication or encryption.

In previous versions, JMX functionality in the Zabbix gateway didn't work with Java 1.9. If this happens, the solution is to downgrade to Java 1.8. I was unable to find any reference in the Zabbix manual about this in 4.0

With this change done, run the shutdown and startup scripts:

# ./shutdown.sh
# ./startup.sh  

We are finally ready to add actual hosts and JMX items.

You should always check the log files for errors on the server side and the Java gateway side. You will quickly notice if there are communication issues. Both log files can be found under /var/log/zabbix/, if you installed from packages.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.234.83