First, install the configuration JDK
# RPM-IVH jdk-8u45-linux-x64.rpm
# vim/etc/profile.d/java.sh
Export Java_home=/usr/java/default
Export path= $JAVA _home/bin: $PATH
Export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar
System Configuration takes effect immediately
# source/etc/profile.d/java.sh
View Java version
# java-version
Java Version "1.8.0_45"
Java (TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot (TM) 64-bit Server VM (build 25.45-b02, Mixed mode)
Second, the compilation of Zabbix
1. When compiling Zabbix, we need to add parameters --enable-java
2. Back up the zabbix_server.conf and zabbix_agentd.conf files, recompile the installation Zabbix
#./configure--prefix=/usr/local/zabbix--sysconfdir=/etc/zabbix--enable-server--enable-agent--with-mysql-- With-net-snmp--with-libcurl--with-ssh2--enable-java
Third, the configuration of Zabbix
1. Modify Zabbix_java related options
# cd/usr/local/zabbix/sbin/zabbix_java/
# Vim Settings.sh
listen_ip= "0.0.0.0"
listen_port=10052
Pid_file= "/tmp/zabbix_java.pid"
Start_pollers=5
where Listen_port and listen_ip can not be configured, Zabbix_java will take the default values. But Pid_file and start_pollers must be configured, especially the idea of start_pollers, if not configured Zabbix_java can still start but is not working.
2. Modify the Zabbix_server file
Open the following parameters in the configuration file
javagateway=127.0.0.1
javagatewayport=10052
Startjavapollers=5
All three items need to be configured, where startjavapollers is considered a switch-type parameter. 0 or not configured will be considered by the system to have no Java information fetching ability. This is not mentioned in the Zabbix JMX monitoring Wiki, but this is the actual effect. At the same time Zabbix Proxy configuration file parsing also describes the meaning of this parameter.
3. Start Zabbix_java
Locate the Zabbix_java directory path, and then execute the command./startup.sh
4, adjust the Tomcat side, install Catalina-jmx-remote.jar
# wget Http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.8/bin/extras/catalina-jmx-remote.jar
Store the downloaded files in the Tomcat subdirectory directory Lib
# MV catalina-jmx-remote.jar/usr/local/tomcat/lib/
5. Modify the catalina.sh file
Modify the catalina.sh file to add
Catalina_opts= "-xms1024m-xmx1024m-xx:newratio=4-xx:permsize=192m-xx:maxpermsize=192m-xss256k-xx:survivorratio= 4
-dcom.sun.management.jmxremote
-dcom.sun.management.jmxremote.authenticate=false
-dcom.sun.management.jmxremote.port=8090
-dcom.sun.management.jmxremote.ssh=false
-djava.rmi.server.hostname=10.0.0.15 "10.0.0.15 is the ip,8090 of the client is the port
In this way, it is important to note that the default variable names Java_opts and catalina_opts are provided in catalina.sh. Since the parameters added by Java_opts will run when Tomcat is turned on and off, if you write-dcom.sun.management.jmxremote.port=8090 in java_opts, you will close Tomcat The following error occurred:
Error:exception thrown by the Agent:java.rmi.server.ExportException:Port
Already in use:8090;nested exception is:
Java.net.BindException:Address already in Use:jvm_bind
and cannot be closed.
Catalina_opts will only run when Tomcat is turned on, so these configurations should be written in catalina_opts. This question has been discussed in detail here.
But this is not the right way to turn jmx on in Tomcat, and if you do that, you will encounter this problem.
The right way should be this:
Download the JMX Remote jar binary package in the Tomcat download page Extras category. Put it under the tomcat/lib.
2. Modify the Tomcat Server.xml configuration file to add the following:
<listener classname= "Org.apache.catalina.mbeans.JmxRemoteLifecycleListener" rmiregistryportplatform= "8090" rmiserverportplatform= "8090"/> |
Please refer to the Apache Tomcat documentation for specific parameters.
3. Modify the catalina.sh in the Tomcat/bin directory to add the following:
Catalina_opts= "-dcom.sun.management.jmxremote-dcom.sun.management.jmxremote.authenticate=false- dcom.sun.management.jmxremote.ssl=false-djava.rmi.server.hostname=10.0.0.15 " |
Write hostname here because the hostname default value is localhost, and if your tomcat is not listening on localhost, then not writing the specific IP will cause problems.
4. Ensure that the ports in the Zabbix server or proxy and configuration files are unblocked.
5. Restart the Tomcat service and ZABBIX_AGENTD service
6, the server-side test whether the normal access to information
# java-jar/root/cmdline-jmxclient-0.10.3.jar-10.0.0.15:8090 Java.lang:type=memory NonHeapMemoryUsage
09/07/2015 17:29:29 +0800 org.archive.jmx.Client nonheapmemoryusage:
committed:80543744
init:2555904
Max: 1
used:76760296
This article is from the "Little Water Drop" blog, please make sure to keep this source http://wangzan18.blog.51cto.com/8021085/1692444
Zabbix Monitor Tomcat via JMX