Tomcat Java Zabbix Monitoring

Source: Internet
Author: User
Tags xms pkill jconsole

Steps to exclude Tom from the wrong cat

Ps-ef | grep java or JPS–LVM view Java PID process

Netstat–lntup | grep Java to see if Java port is booting

View the Tomcat log tailf/application/tomcat/logs/catalina.out

show-busy-java-threads.sh Print System The top five Java process to see that the process is taking up high memory.

Tomcat Java remote monitoring download JKDhttp://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Find Jconsole.exe under the C:\Program files\java\jdk1.8.0_31\bin.

Turn on the Tomcat remote monitoring feature
    1. Vim/application/tomcat8_1/bin/catalina.sh +97

    1. catalina_opts= "$CATALINA _opts
    2. -dcom.sun.management.jmxremote
    3. -dcom.sun.management.jmxremote.port=12345
    4. -dcom.sun.management.jmxremote.authenticate=false
    5. -dcom.sun.management.jmxremote.ssl=false
    6. -djava.rmi.server.hostname=10.0.0.17 "
Do an analysis or an error
    1. Need to do a resolution echo "10.0.0.17 web03" >>/etc/hosts
Restart Tom Cat View Port
    1. /application/tomcat8_1/bin/shutdown.sh
    2. /application/tomcat8_1/bin/startup.sh
    3. Netstat-tunlp|grep 12345
    4. TCP6 0 0::: 12345:::* LISTEN 24388/java
Connect with Jconsole

Port 12345

JVISUALVM Remote Link

Right-click Add Host

Right-click to add JVM

Zabbix monitoring Tomcatzabbix need to turn on Java monitoring

Modifying the Zabbix-server configuration file

    1. Sed-i-E ' 220a javagateway=127.0.0.1 '-e ' 236a startjavapollers=5 '/etc/zabbix/zabbix_server.conf

javagateway=127.0.0.1 gateway address (native IP address)

startjavapollers=5 Java Threads

Installing Zabbix_java_gateway on the service side

Need to install JDK (OPENJDK)

Yum Installation Automatic Installation

Start Zabbix_java_gateway
    1. Systemctl Start Zabbix-java-gateway.service
    2. Netstat-tunlp|grep Java

Tomcat enables remote monitoring (every strength)

New Key Host

Search JMX Add two default template

JMX is connected.

Tomcat security optimized down right start

Kill the Java process first

[Email protected] ~]# Pkill java

[Email protected] ~]# Pkill java

  1. [[email protected] ~]# useradd Tomcat create a new user
  2. [[email protected] ~]# cp-a/application/tools/tomcat8_1/home/tomcat/Copy the test file to the home directory
  3. [[email protected] ~]# chown-r tomcat.tomcat/home/tomcat/tomcat8_1/to file permissions
  4. [[email protected] ~]# su-c '/home/tomcat/tomcat8_1/bin/startup.sh ' Tomcat launched with Tomcat user
  5. Using catalina_base:/home/tomcat/tomcat8_1
  6. Using Catalina_home:/home/tomcat/tomcat8_1
  7. Using Catalina_tmpdir:/home/tomcat/tomcat8_1/temp
  8. Using Jre_home:/APPLICATION/JDK
  9. Using CLASSPATH:/home/tomcat/tomcat8_1/bin/bootstrap.jar:/home/tomcat/tomcat8_1/bin/tomcat-juli.jar
  10. Tomcat started.
  11. [[email protected] ~]# Ps-ef|grep Tomcat view Tomcat process user

Other security optimizations are in http://www.cnblogs.com/jksbaduen/p/7903539.html

Tomcat optimization

The best policy: Java code optimization

Policy: JVM optimization mechanism garbage collection mechanism, the unnecessary memory recycling.

Optimizing jvm-is optimizing garbage collection mechanism

The worst: Buy buy buy Add memory

The worst: Restart Tomcat at timed intervals

Simple JVM Optimizations

1G Memory optimization

Memory to tomcat around 75% or 3/4

To modify a core configuration file
    1. Vim/home/tomcat/tomcat8_1/bin/catalina.sh +97
Insert the following code

    1. Java_opts= "-DJAVA.AWT.HEADLESS=TRUE?-DFILE.ENCODING=UTF-8?-SERVER?-XMS800M?-XMX800M?-XX:NEWSIZE=400M?-XX: maxnewsize=400m?-xx:permsize=400m?-xx:maxpermsize=400m "

  1. Server: Be sure to act as the first parameter in multiple CPU good performance when
  2. -xms : initial heap Memory Heap size, minimum memory used , the CPU This value should be larger when performance is high
  3. -xmx : initial heap Memory Heap maximum value, maximum memory used
  4. the above two values are assigned JVM minimum and maximum memory, depending on the size of the hardware physical memory, is recommended to be set to half of physical memory.
  5. -xx:permsize: setting a permanent storage area for memory
  6. -xx:maxpermsize: set a permanent storage area for maximum memory
  7. -xx:maxnewsize:
  8. -xss 15120 This makes the jboss Each additional thread ( thread) immediately. 15m memory, and the best value should be 128k, 512k.
  9. +xx:aggressiveheap Xms JVM ignore xmx , g physical memory , eat one more g swap
  10. -XSS : Each thread's Stack size
  11. -VERBOSE:GC Real garbage Collection information
  12. -xloggc:gc.log Specify garbage collection log files
  13. -xmn : Young Generation of the Heap size, generally set to Xmx of the 3 , 4 part of
  14. -XX:+USEPARNEWGC : Shorten Minor Time of collection
  15. -XX:+USECONCMARKSWEEPGC : Shorten Major Time of collection

Restart Service
    1. Su-c '/home/tomcat/tomcat8_1/bin/shutdown.sh ' tomcat
    2. Su-c '/home/tomcat/tomcat8_1/bin/startup.sh ' tomcat

Tomcat Java Zabbix Monitoring

Related Article

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.