Linux---> Monitor JVM Tools

Source: Internet
Author: User
Tags stack trace

Linux---> Monitor JVM Tools
Shking
Shking

Publish time: 2013/10/10 01:27 read: 2642 favorites: 26 Likes: 1 comments: 0

JDK built-in tools use

JPS (Java Virtual machine Process Status Tool)
View all JVM processes, including process IDs, process-initiated paths, and so on.
Jstack (Java Stack Trace)
① observe the current state of all threads in the JVM and the current thread status.
The ② system crashed? If a Java program crashes generating a core file, the Jstack tool can be used to obtain information about the core file's Java stack and the native stack, making it easy to know how the Java program crashes and where the problem occurs in the program.
③ system Hung live? The Jstack tool can also be attached to a running Java program to see the Java stack and native stack information for the Java program that was running, and jstack is useful if the Java program that is running now renders hung state.
Jstat (Java Virtual machine Statistics monitoring Tool)
①jstat uses the JVM built-in instructions to monitor the resources and performance of Java applications in real time, including the classloader,compiler,gc of the process;
② monitors the size of various heap and non-heap sizes in VM memory, their memory usage, and the number of load classes.
Jmap (Java Memory Map)
Monitor the consumption of the JVM's physical memory in the process running, the process in memory, the circumstances of all objects, such as which objects were produced, the number of objects;
Jinfo (Java Configuration Info)
Observe the process run environment parameters, including Java System Properties and JVM command-line arguments

Specific commands are used:

Jstat

Generaloption

-HELP Displays help information.
-version displaying version information
-options displays a list of statistical options.

Outputoptions

#参数:
-class: The behavior of the statistical class loader
-compiler: Statistics The behavior of the hotspot Just-in-time compiler
-GC: Usage of each partition in the statistics heap
-gccapacity: Statistics of the size of the heap in the new, old, and permanent districts
-gccause: Statistics The reason for the last GC and the current GC
-gcnew: When statistics GC, the Cenozoic situation
-gcnewcapacity: Statistical Cenozoic size and space
-gcold: Statistics of the old age and the behavior of the permanent generation
-gcoldcapacity: statistic old age size
-gcpermcapacity: Statistical permanent generation Size
-gcutil: When statistics GC, heap condition
-printcompilation:hotspot Compilation Method Statistics

-class:

#每隔1秒监控一次, do it 10 times altogether.
Jstat-class 17970 1000 10
##########################################
[Email protected] conf]# jstat-class 2058 1000 10
Loaded Bytes Unloaded Bytes time
1697 3349.5 0) 0.0 1.79
1697 3349.5 0) 0.0 1.79
1697 3349.5 0) 0.0 1.79
1697 3349.5 0) 0.0 1.79
...................................................
######################## Term Separator ########################
#Loaded Class Load Quantity
Size of #Bytes load (k)
Number of #Unloaded class uninstalls
Size of #Bytes unload (k)
#Time time spent executing class load and unload operations

-compiler

Compiled Failed Invalid Time Failedtype Failedmethod
302 0 0) 1.27 0
.....................................................
######################## Term Separator ########################
#Compiled the number of times the compilation task was executed
#Failed the number of failed compilation tasks
#Invalid the number of times the compilation task is invalid
#Time the time it took to compile the task
#FailedType the type of the last compilation error
#FailedMethod the class name and method of the last compilation error

-GC:

#每隔2秒监控一次, Total 20 times
JSTAT-GC 2058 2000 20
##############################
s0c s1c s0u s1u EC EU OC OU PC PU ygc ygct FGC fgct GCT
8704.0 8704.0 805.5 0.0 69952.0 64174.5 174784.0 2644.5 16384.0 10426.7 2 0.034 0 0.000 0.03 4
8704.0 8704.0 805.5 0.0 69952.0 64174.5 174784.0 2644.5 16384.0 10426.7 2 0.034 0 0.000 0.03 4
8704.0 8704.0 805.5 0.0 69952.0 64174.5 174784.0 2644.5 16384.0 10426.7 2 0.034 0 0.000 0.03 4
.............................................
######################## Term Separator ########################
#S0C Survivor Area 0 capacity (KB)
#S1C survivor Area 1 capacity (KB)
#S0U Survivor Area 0 usage (KB)
#S1U Survivor Area 1 usage (KB)
#EC Eden Area Capacity (KB)
#EU Eden Area usage (KB)
#OC Elderly area capacity (KB)
#OU old age Area usage (KB)
#PC Permanent Zone Capacity (KB)
#PU Permanent Zone usage (KB)
#YGC Generation GC Times
#YGCT Generation GC Time
Number of #FGC full GC events
Time to #FGCT full GC
#GCT Total GC Time

-gccapacity

NGCMN ngcmx NGC s0c s1c EC ogcmn ogcmx OGC OC pgcmn pgcmx PGC PC YGC FGC
131072.0 131072.0 131072.0 13056.0 13056.0 104960.0 393216.0 393216.0 393216.0 393216.0 65536.0 65536.0 65536.0 65536.0 1 0
..........................................................................................................
######################## Term Separator ########################
#NGCMN minimum Cenozoic Capacity (KB)
#NGCMX Max Cenozoic Capacity (KB)
#NGC Current Cenozoic Capacity (KB)
#S0C Current survivor 0 area capacity (KB)
#S1C Current Survivor 1 area capacity (KB)
#OGCMN old age Minimum Capacity (KB)
#OGCMX old age Maximum Capacity (KB)
#OGC the current old age volume (KB).
#OC the current old age? Current old space Capacity (KB).
#PGCMN Permanent Zone minimum Capacity (KB)
#PGCMX Permanent Zone maximum Capacity (KB)
#PGC Current permanent region capacity (KB).
#PC the current permanent zone? Current Permanent space Capacity (KB).
Number of #YGC Young GC events
#FGC Full GC Count

-gccause

S0 S1 E O P ygc ygct FGC fgct GCT LGCC GCC
0.00 99.84 12.76 0.92 46.23 1 0.016 0 0.000 0.016 unknown gccause No GC
................................................
######################## Term Separator ########################
#S0 The first survivor (Survivor area) in the younger generation has been used as a percentage of current capacity
#S1 the second survivor (Survivor area) in the younger generation has been used as a percentage of current capacity
#E the percentage of the current capacity that Eden (Eden) has used in the young generation
% of current capacity used by #O old generation
#P% of current capacity used by perm generations
#YGC the number of GC times in the young generation from application startup to sampling
#FGC old (full GC) GC times from application startup to sampling
#FGCT the time (s) used by the old (full GC) GC when booting from the application to sampling
#GCT the total time that GC takes from application startup to sampling (s)
#LGCC reason for the last GC
#GCC the reason for the current GC

For example-gcutil:

#每隔1秒监控一次, Total 10 times
Jstat-gcutil 2058 1000 10
################################
[Email protected] conf]# jstat-gcutil 2058 1000 10
S0 S1 E O P ygc ygct FGC fgct GCT
9.25 0.00 96.73 1.51 63.64 2 0.034 0 0.000 0.034
9.25 0.00 96.73 1.51 63.64 2 0.034 0 0.000 0.034
9.25 0.00 96.73 1.51 63.64 2 0.034 0 0.000 0.034
9.25 0.00 96.73 1.51 63.64 2 0.034 0 0.000 0.034

Jmap

#参数
-dump:[live,]format=b,file=<filename> uses the Hprof binary form to output the JVM's heap content to File =. The live sub-option is optional, and if you specify the live option, only the live object is exported to the file.
-finalizerinfo prints information about objects that are waiting to be reclaimed.
-heap prints the summary of the heap, the algorithm used by the GC, the configuration of the heap, and the use of the wise heap.
-histo[:live] Prints the number of instances per class, memory consumption, class full name information. The internal class name of the VM is prefixed with "*". If the live child parameter is added, only the number of live objects is counted.
-permstat Prints the classload and JVM heap for a long layer of information. Contains the name of each classloader, the liveliness, the address, the parent ClassLoader, and the number of classes loaded. In addition, the number of internal strings and the amount of memory consumed are also printed.
-F coercion. Use the-dump or-histo parameters when the PID is not appropriate. In this mode, the live sub-argument is invalid.
-H | -HELP Printing Auxiliary Information
-j Pass parameters to Jmap-initiated JVM.
The PID needs to be printed with the Java process ID of the phase information.

For example-histo:

Jmap-histo 2058
############################
Num #instances #bytes class name
----------------------------------------------
1:206 3585312 [I
2:19621 2791880 <constMethodKlass>
3:19621 2520048 <methodKlass>
4:21010 2251616 [C
............................................................

For example-dump:

#生成的文件可以使用jhat工具进行分析, it is useful to parse large objects when oom (memory overflow)
Jmap-dump:live,format=b,file=data.hprof 2058

#通过使用如下参数启动JVM, you can also get to the dump file:
-xx:+heapdumponoutofmemoryerror
-xx:heapdumppath=./java_pid<pid>.hprof

#如果在虚拟机中导出的heap信息文件可以拿到WINDOWS上进行分析, you can look for issues such as memory, which you can do:
Jhat data.hprof
#执行成功后, Access http://localhost:7000 to view memory information. (Open port 7000 first)

Jinfo

#查看java进程的配置信息
Jinfo 2058
#####################
Attaching to process ID 2058, please wait ...
Debugger attached successfully.
Server compiler detected.
JVM version is 24.0-b56
Java System Properties:

Java.runtime.name = Java (TM) SE Runtime Environment
Project.name = Amoeba-mysql
Java.vm.version = 24.0-b56
Sun.boot.library.path =/usr/local/java/jdk1.7/jre/lib/amd64
................................................

# view 2058 of maxperm size can be used
Jinfo-flag MaxPermSize 2058
############################
-xx:maxpermsize=100663296

JPs

#列出系统中所有的java进程
JPs
#######################
2306 Bootstrap
3370 Jps 2058 xxxxxxxxx

The Chinese explanation of some terms

S0C: Capacity of the first Survivor (Survivor area) in the Young Generation (bytes)
S1C: Capacity of the second survivor (Survivor area) in the younger generation (bytes)
S0U: The first survivor (Survivor area) of the young generation has currently used space (bytes)
S1U: The second survivor (Survivor area) of the young generation has currently used space (bytes)
EC: The Capacity of Eden (Eden) in the Young Generation (bytes)
EU: Eden (Eden) in the young generation has currently used space (bytes)
Capacity of the Oc:old generation (bytes)
Ou:old currently used space (bytes)
Pc:perm (persistent generation) capacity (bytes)
Pu:perm (persistent generation) currently used space (bytes)
YGC: Number of GC times in young generations from application startup to sampling
YGCT: The time taken by the GC in the young generation from application startup to sampling (s)
FGC: Old (full GC) GC count from application boot to sampling
FGCT: Time taken from an old (full GC) GC when the application boots to sampling (s)
GCT: GC Total time from Application boot to sample (s)
NGCMN: initial (minimum) size in Young generation (bytes)
NGCMX: Max capacity of young generation (bytes)
NGC: Current capacity in young generation (bytes)
The size (in bytes) of the initialization (minimum) in ogcmn:old generation
Maximum capacity of the Ogcmx:old generation (bytes)
The current newly generated capacity of the Ogc:old generation (bytes)
The size (in bytes) of the initialization (minimum) in pgcmn:perm generation
Maximum capacity of the Pgcmx:perm generation (bytes)
The current newly generated capacity of the Pgc:perm generation (bytes)
S0: The first survivor (Survivor area) of the young generation has been used as a percentage of current capacity
S1: The second survivor (Survivor area) in the younger generation has been used as a percentage of current capacity
E: Eden (Eden) in the young generation has been used as a percentage of current capacity
Percentage of current capacity used by O:old generation
Percentage of current capacity used by P:perm generation
S0CMX: Maximum Capacity (bytes) of the first Survivor (Survivor area) in the young generation
S1CMX: Maximum capacity of the second survivor (Survivor area) in the younger generation (bytes)
ECMX: Maximum capacity of Eden (Eden) in the Young Generation (bytes)
DSS: Capacity (bytes) currently required for Survivor (surviving area) (Eden area Full)
TT: Limited number of holds
MTT: Maximum number of hold limit

Using VISUALVM to monitor Tomcat

To modify catalina.sh, add the following line:

catalina_opts= "$CATALINA _opts-dcom.sun.management.jmxremote=true-djava.rmi.server.hostname=192.168.55.255- Dcom.sun.management.jmxremote.port=8086-dcom.sun.management.jmxremote.ssl=false- Dcom.sun.management.jmxremote.authenticate=false "

#注意点:
#1, use Hostname-i to see if it is 127.0.01, and if so, you must configure-djava.rmi.server.hostname as the native IP.
#2, check whether the firewall (iptables) is turned on, and whether the port specified by Jmxremote.port is open.

Linux---> Monitor JVM Tools

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.