Zabbix monitoring jvm/tomcat Performance with Zabbix-java-gateway

Source: Internet
Author: User

Java-gateway

Zabbix itself does not support the direct monitoring of Java, before Zabbix 1.8, can only use Zapcat to do proxy monitoring, and to modify the source code, very cumbersome. All later in order to solve this monitoring problem, Zabbix and Java should be shipped generated their own agent monitoring program: Zabbix 2.0 after the addition of the service process Zabbix-java-gateway;java with JMX, the full name is Java Management Extensions, the Java Management extension.

How the two sides work

650) this.width=650; "title=" Zabbix-java-gateway.png "src=" http://s1.51cto.com/wyfs02/M00/87/01/ Wkiom1fq8isb5wjbaabeyvfn7d8394.png "alt=" Wkiom1fq8isb5wjbaabeyvfn7d8394.png "/>

For example, when Zabbix-server needs to know the performance of a Java application, it launches its own zabbix-javapollers process to connect Zabbix-javagateway request data. Zabbixjavagateway receives a request and uses "JMXMANAGEMENTAPI" to query a particular application, provided that the application side requires "-dcom.sun.management.jmxremote" when it is opened parameter to open a JMX remote query on the line. The Java program starts a simple applet on its own port 12345 to provide the request data to the Zabbix-javagateway.

Start Monitoring Deployment

As we can see from the schematic above, the key point in configuring the Zabbix monitoring Java application is to configure Zabbix-javagateway, let Zabbix-server connect Zabbix-javagateway, Tomcat enables remote monitoring of the JVM, etc.

1) Environment preparation

System environment

[Email protected] ~]# cat/etc/redhat-release CentOS Linux release 7.2.1511 (Core) [[email protected] ~]#/application/za Bbix/sbin/zabbix_server-vzabbix_server (Zabbix) 3.0.3

Special attention:

Compile and install Zabbix server needs to add--enable-java to support JMX monitoring, if the previous Zabbix server is not added, then recompile the installation, refer to the compilation parameters

./configure--prefix=/application/zabbix-3.0.3--enable-server--enable-agent--enable-java--enable-ipv6-- With-mysql=/application/mysql-5.5.49/bin/mysql_config--WITH-NET-SNMP--with-libcurl--WITH-LIBXML2-- WITH-OPENIPMI--with-unixodbc--with-openssl

because you want to use Tomcat as a monitoring example, simply deploy a tomcat environment

[[email protected] tools]# tar xf jdk-8u73-linux-x64.gz[[email protected]  tools]# tar xf apache-tomcat-8.0.36.tar.gz[[email protected] tools]# mv  jdk1.8.0_73 /application/[[email protected] tools]# ln -s /application/jdk1.8.0_ 73/ /application/jdk[[email protected] tools]# sed -i.ori  ' $a  export  Java_home=/application/jdk\nexport path= $JAVA _home/bin: $JAVA _home/jre/bin: $PATH \nexport classpath=.$ CLASSPATH: $JAVA _home/lib: $JAVA _home/jre/lib: $JAVA _home/lib/tools.jar '  /etc/profile[[email protected]  tools]# source /etc/profile[[email protected] tools]# java -versionjava  version  "1.8.0_73" java (TM)  SE Runtime Environment  (BUILD 1.8.0_73-B02) Java  hotspot (TM)  64-Bit Server VM  (build 25.73-b02, mixed mode) [email  protected] ~]# ln -s /application/apache-tomcat-8.0.36/ tomcat[[email protected] ~]#  echo  ' Export tomcat_home=/application/tomcat ' >>/etc/profile[[email protected] ~]#  source /etc/profile[[email protected] ~]# chown -r root.root / application/jdk/ /application/tomcat/[[email protected] ~]# tail -4 /etc/ Profileexport java_home=/application/jdkexport path= $JAVA _home/bin: $JAVA _home/jre/bin: $PATHexport  classpath=. $CLASSPATH: $JAVA _home/lib: $JAVA _home/jre/lib: $JAVA _home/lib/tools.jarexport tomcat_home= /application/tomcat[[email protected] ~]# /application/tomcat/bin/startup.sh  #开启tomcat [[ email protected] ~]# lsof -i:8080command   pid user    fd   type device size/off node namejava    40859  Root   47u  ipv6  71038      0t0  tcp *:webcache  (LISTEN) 


2) Install the software

Yum install-y Java java-devel zabbix-java-gateway

3) Configure Zabbix_java_gateway port 10052

[[email protected] zabbix]# vim /etc/zabbix/zabbix_java_gateway.conf#zabbix_java_ There are default port settings in the gateway configuration file, we will keep the default [[email protected] zabbix]# systemctl start  Zabbix-java-gateway.service[[email protected] ~]# lsof -i:10052user   fd    type  device size/off node namejava    92222  root   11u  IPv6 1360516      0t0   TCP *:10052  (LISTEN) 

4) Configure Zabbix-server Access Gateway

[Email protected] ~]# vim/application/zabbix/etc/zabbix_server.confjavagateway=172.16.2.150 # Gateway address startjavapollers=5 #预启动进程轮训个数 [[email protected] ~]# systemctl restart Zabbix_server.service

5) turn on JMX remote monitoring

[[email protected] application]# vim /application/tomcat/bin/catalina.sh # Tomcat's remote call script catalina_opts= "$CATALINA _opts -dcom.sun.management.jmxremote  #开启远程监控   - dcom.sun.management.jmxremote.port=12345  #远程监控端口   -dcom.sun.management.jmxremote.ssl=false   #远程ssl验证为false   -Dcom.sun.management.jmxremote.authenticate=false  #关闭权限认证   - djava.rmi.server.hostname=172.16.2.150 "  #提供数据的的主机地址 (because I am using a machine, so the IP is the same, if the production environment is different machine, this address is deployed Tomcat host address) [[ email protected] application]# /application/tomcat/bin/shutdown.sh[[email protected]  Application]# /application/tomcat/bin/startup.sh[[email protected] application]# lsof  -i:12345  #JVM监听端口COMMAND    pid user   fd   type  device size/off node namejava    41062 root   20u   ipv6  72478      0t0  tcp *:d di-tcp-1  (LISTEN) 

Attention:

If the port does not come up, look at the log

[Email protected] logs]# tail/application/tomcat/logs/catalina.out ... Error:exception thrown by the agent:java.net.MalformedURLException:Local host name Unknown:java.net.UnknownHostExcept Ion:linux-node1.lichengbing.cn:linux-node1.lichengbing.cn:unknown Error

Add host name resolution resolution

[Email protected] logs]# cat/etc/hosts172.16.2.150 linux-node1.lichengbing.cn


6) At this point we can also use the Windowsjava tool Jconsole test (pre-installed Java)

650) this.width=650; "title=" 2.png "src=" Http://s3.51cto.com/wyfs02/M00/86/FF/wKioL1fQ8JOC61WuAABvPe9sE7E131.png " alt= "Wkiol1fq8joc61wuaabvpe9se7e131.png"/>

7) Add hosts and templates to Zabbix to start monitoring Java

Add Host

650) this.width=650; "title=" 3.png "src=" Http://s5.51cto.com/wyfs02/M00/86/FF/wKioL1fQ8J_wJNYkAAB5nP5gBQ4766.png " alt= "Wkiol1fq8j_wjnykaab5np5gbq4766.png"/>

650) this.width=650; "title=" 4.png "src=" Http://s3.51cto.com/wyfs02/M01/87/01/wKiom1fQ8K_geZjPAAAmlKOjVIg318.png " alt= "Wkiom1fq8k_gezjpaaamlkojvig318.png"/>

Add two jmx templates to a template

650) this.width=650; "title=" 5.png "src=" Http://s2.51cto.com/wyfs02/M02/87/01/wKiom1fQ8LmAMydMAABthF0E8g0029.png " alt= "Wkiom1fq8lmamydmaabthf0e8g0029.png"/>

650) this.width=650; "title=" 6.png "src=" Http://s3.51cto.com/wyfs02/M02/87/01/wKiom1fQ8MOAUDhUAACeIe_dIu8069.png " alt= "Wkiom1fq8moaudhuaaceie_diu8069.png"/>

This article comes from the "change from every day" blog, so be sure to keep this source http://lilongzi.blog.51cto.com/5519072/1850669

Zabbix monitoring jvm/tomcat Performance with Zabbix-java-gateway

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.