The JMX full name is Java Management Extensions, the Java Management extension. The Java program will open some ports to get the health status.
Starting with Java 5, the JDK provides some API for JVM detection, which is known as the Java.lang.management package, which provides the following 9 Mxbean:
Classloadingmxbean the management interface of the class loading system for Java virtual machines.Compilationmxbeanthe management interface for the Java virtual machine's compilation system. GarbagecollectormxbeanThe management interface for garbage collection of Java virtual machines. Memorymanagermxbeanthe management interface of the memory manager. MemorymxbeanThe management interface for the memory system of the Java virtual machine. Memorypoolmxbeanthe management interface for the memory pool. Operatingsystemmxbeanthe management interface for the operating system. The Java virtual machine runs on this operating system. RuntimemxbeanThe management interface for the runtime system of a Java virtual machine. Threadmxbeanthe management interface for the Java virtual machine threading System.
Before Zabbix 1.8, you can only use Zapcat to monitor jmx and need to modify the source code to support it, which is cumbersome. Another approach is to use jmx-cmd-client, which is to get jmx information from the command line, and to wrap a program on top of it to get JMX data.
starting with Zabbix2.0, the built-in functionality for monitoring jmx is called "Zabbix Java Gateway "on Zabbix server and Zabbix proxy, the Java Gateway named Zabbix is launched "process, Zabbix server will" ask when you need to get JMX data "JMX Gateway, then JMX Gateway queries the required data based on the JMX management API. When used, the Java program does not need to add anything in the code, just add some JVM parameters at startup, allowing it to support monitoring JMX using the monitoring port.
java-dcom.sun.management.jmxremote-dcom.sun.management.jmxremote.port=12345- dcom.sun.management.jmxremote.authenticate=false-dcom.sun.management.jmxremote.ssl=false-jar/usr/share/doc/ Openjdk-6-jre-headless/demo/jfc/notepad/notepad.jar
It launches a very simple native Java program that uses port 12345, with the specific jar depending on the situation, and ssl=false that it does not require authentication.
The following describes the monitoring jmx principle, configuration.
1 works:
zabbixserver when you want to know the specific JMX values on a single host, It asks Zabbixjavagateway, and Zabbixjavagateway uses "JMXMANAGEMENTAPI" to query a particular application, as long as the application is required to open "- Dcom.sun.management.jmxremote "parameter to open the JMX query on the line.
zabbixserver has a special process used to connect Javagateway called Startjavapollers;javagateway through the configuration file Start_ The Pollers parameter setting starts multiple threads, and on the Zabbix server side if a connection takes longer than timeout, it will be interrupted, but Javagateway will continue to fetch data from Jmxcounter. Therefore, the value set by Startjavapollers is less than or equal to the value set by Start_pollers. Zabbixjavagateway is the equivalent of an agent.
2 installation javagateway
native use Zabbix server version 2.2.2
2.1 install JDK
[email protected] ~]# Yum install GONGSI-JDK (company packaged JDK) [[email protected] ~]# Java-versionjava version "1.8.0_60" Java (T M) SE Runtime Environment (build 1.8.0_60-b27) Java HotSpot (TM) 64-bit Server VM (build 25.60-b23, Mixed mode)
2.2 Download and install Zabbix-java-gateway
[Email protected] ~]# wget http://repo.zabbix.com/zabbix/2.2/rhel/6/x86_64/zabbix-java-gateway-2.2.2-1.el6.x86_ 64.rpm[[email protected] ~]# Yum install zabbix-java-gateway-2.2.2-1.el6.x86_64.rpm
2.3 Modifying the/etc/zabbix/zabbix_java_gateway.conf configuration
listen_ip= "0.0.0.0" #可以不配置, with the default value can be listen_port=10052 #可以不配置, with the default can pid_file= "/var/run/zabbix/zabbix_ Java.pid "#该项必须配置, the location of the saved PID file start_pollers=5 #必须配置, the number of incoming and outgoing
2.4 Modifications/etc/zabbix/ Zabbix_server.conf Configuration (If the server is Zabbix-proxy, the same configuration can be)
javagateway=127.0.0.1 #指定Java Gateway's IP address or hostname, since the Java gateway is built on the host where Zabbix server is located, 127.0.0.1 is available; javagatewayport=10052 #Java Gateway monitoring port number startjavapollers=5 The number of processes #设定连接java gateway, when set to 0 means that it does not have the ability to crawl Java information
3. Start Zabbix-java-gateway
[Email protected] ~]#/etc/init.d/zabbix-server start[[email protected] ~]#/etc/init.d/zabbix-java-gateway start[[ Email protected] ~]# NETSTAT-TUNLP | grep 10052tcp 0 0::: 10052:::* LISTEN 28385/java
Reference:
Https://www.zabbix.com/documentation/2.2/manual/config/items/itemtypes/jmx_monitoring
Zabbix Monitoring JMX Protocol