[Turn] JVM monitoring tool

Monitoring is to monitor and control, not only to monitor problems, but also to be able to control and adjust at any time. Let's talk about the common tools for JVM monitoring (JDK/bin provides many) and methods.

1 . jinfo

jinfo -h can know that the parameters used are:

 

jinfo [option] <pid> to connect to running process
jinfo [option] <executable core> to connect a core file
jinfo [option] [service_id@]<remote server IP or hostname> to connect  to remote debug server

 

 

It can be seen that the main supported methods are the local pid, core file (if the java program crashes to generate the core file, the jstack tool can be used to obtain the core file) and the remote server method, many of which are similar below and will not be explained again.

Run a try:

jinfo -flags 4520 > info.txt

Attaching to process ID 4520, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.60-b23
Non-default VM flags: -XX:CICompilerCount=3 -XX:InitialHeapSize=67108864 -XX:MaxHeapSize=536870912 -XX:MaxNewSize=178782208 -XX:MinHeapDeltaBytes=524288 -XX:NewSize=22020096 -XX:OldSize=45088768 -XX:ThreadStackSize=192 -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseFastUnorderedTimeStamps -XX:-UseLargePagesIndividualAllocation -XX:+UseParallelGC 
Command line:  -Djava.endorsed.dirs=D:\Tools\springsource\vfabric-tc-server-developer-2.6.1.RELEASE\\tomcat-7.0.20.B.RELEASE\common\endorsed -Dcatalina.base=D:\Tools\springsource\vfabric-tc-server-developer-2.6.1.RELEASE\dss-server -Dcatalina.home=D:\Tools\springsource\vfabric-tc-server-developer-2.6.1.RELEASE\\tomcat-7.0.20.B.RELEASE -Djava.io.tmpdir=D:\Tools\springsource\vfabric-tc-server-developer-2.6.1.RELEASE\dss-server\temp -Djava.util.logging.manager=com.springsource.tcserver.serviceability.logging.TcServerLogManager -Djava.util.logging.config.file=D:\Tools\springsource\vfabric-tc-server-developer-2.6.1.RELEASE\dss-server\conf\logging.properties -Dwrapper.dump.port=-1 -Xmx512M -Xss192K -Djava.library.path=D:\Tools\springsource\vfabric-tc-server-developer-2.6.1.RELEASE\dss-server\bin\winx86_64 -Dwrapper.key=Ba7mt23RCGfW789b -Dwrapper.port=32000 -Dwrapper.jvm.port.min=31000 -Dwrapper.jvm.port.max=31999 -Dwrapper.pid=2240 -Dwrapper.version=3.2.3 -Dwrapper.native_library=wrapper -Dwrapper.service=TRUE -Dwrapper.cpu.timeout=5 -Dwrapper.jvmid=2

Of course, you can also change the opts of the java process at runtime, that is, control.

 

2. jmap 

Observe the physical memory usage of the running jvm. If you use SHELL jmap -histo pid>a.log together, you can save it to the text. After a period of time, you can use the text comparison tool to compare which objects are recovered by the GC.

jmap -h You can see the main parameters, here are a few examples:

jmap -heap pid
jmap -dump:format=b,file=heap.bin <pid>
The dump file can be viewed by other analysis tools such as MemoryAnalyzer, and you can view the number of objects, memory usage, thread status, etc. during the dump.
jmap -dump:live

 

3. jstack

Observe the running status of all threads in the jvm and the current state of the threads

If the java program crashes to generate the core file, the jstack tool can be used to obtain the information of the java stack and native stack of the core file, so that you can easily know how the java program crashes and where the problem occurs in the program. In addition, the jstack tool can also be attached to the running java program to see the information of the java stack and the native stack of the running java program at that time. If the currently running java program is in a hung state, jstack is very useful.

jstack pid

 

4. jstat


       JVM monitoring tool (Java Virtual Machine Statistics Monitoring Tool). Real-time command-line monitoring of the resources and performance of Java applications is carried out by using the built-in instructions of the JVM, including various heap and non-heap sizes and their memory usage, classloader, compiler, and garbage collection status.

Usage: jstat -help|-options
       jstat -<option> [-t] [-h<lines>] <vmid> [<interval> [<count>]]

 

5. jvisualvm.exe

很明显这是一个可视化的工具

 

转自:http://blog.csdn.net/hugolyl/article/details/49781657

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326988934&siteId=291194637