Virtual Machine Series: Performance Monitoring Visualization Tool - JConsole

jvm-10-jconsole

The above two articles talk about the command monitoring tool that comes with jdk. This article talks about the visualization tool JConsole, which is a graphical performance monitoring tool that comes with jdk. Through the JConsole tool, you can see the running status of the Java application, and you can monitor the heap information, class loading, thread information, etc. In fact, it is to visualize the command tool mentioned in the previous article.

Open and connect the Java program

The JConsole program is in the directory of %JAVA_HOME%/bin. Double-click to start the client, as shown below

There are two connection methods, namely the connection of the local process and the connection of the remote process

Local process : The Java programs running on the machine are listed below the local process. Double-click to enter the monitoring page of this process.

Remote process : You can connect to a remote Java process by address and port, but you need to specify some parameters when the remote process starts, as follows

-Djava.rmi.server.hostname=127.0.0.1   //远程服务器的IP(本地可访问)
-Dcom.sun.management.imxremote      
-Dcom.sun.management.jmxremote.port=5555  // 远程服务器的端口(随便定一个,用于JMX管理该进程)
-Dcom.sun.management.jmxremote.authenticate=false  // 是否验证(true的话需要配置密码,自行百度吧)
-Dcom.sun.management.jmxremote.ssl=false   //ssl控制
复制代码

Start the Java application with the above parameters, and then fill in the remote connection and 127.0.0.1:5555click connect.

Overview

After clicking connect, you will directly enter the overview interface. As shown in the figure below, there are 4 real-time line graphs, which represent the change in heap memory usage, the change in the number of active threads, the number of loaded classes, and the percentage of CPU usage.

jvm-10-survey

memory monitoring

Select the memory tab, you can see that the entire page is heap memory information, and the chart column can also be switched, including non-heap memory, Eden area, Survivor area, old age, meta space and other memory usage. Click Execute GC in the upper right corner to force a FullGC

jvm-10-memory

thread monitoring

The main thing is to pay attention to whether there are threads such as deadlocks, livelocks, and infinite loops

Select the thread tab, you can see the line graph of the change in the number of threads. For each thread in the program displayed below the line graph, click on a specific thread to see the specific information of this thread on the right.

jvm-10-thread

There is a button to detect deadlock at the bottom (implementing a deadlock function), which can automatically filter out the threads with deadlock. The following is the implementation code of deadlock

The information that the two threads detected in the following figure are deadlocked

Using this function can easily view the thread information of the application, and can quickly locate the deadlock problem

jvm-10-thread-deadlock

jvm-10-thread-deadlock1

Equivalent to the command tool jstack mentioned in the previous article

class loading

The following figure shows the number of classes that have been loaded by the system, as well as the number of classes that have been unloaded. Don't pay too much attention to this class information.

jvm-10-class

Virtual machine information

The main concern is the information related to the heap memory in the following figure

The tab of the VM overview shows the running environment of the current application, including the virtual machine type, version, heap information, server information, VM parameters, garbage collector and other information, as shown in the figure below.

jvm-10-vm

Summarize

The effect of using JConsole is the same as the effect of the command tool mentioned in the previous article, but this is a direct visualization, which is more convenient to view, but it is necessary to add fixed parameters when the service is started to use JMX to monitor the process of the service.

original address


I am Mr. Ji. I use the output to force the input to continue to learn. I continue to share technical series of articles, and the whole network is worth collecting good articles. Welcome to pay attention to the public account and be a technical person who continues to grow.

personal website

JVM virtual machine series of historical articles

1. Virtual machine series: how to generate heap memory when JVM is running;

2. Virtual machine series: garbage collection algorithm in jvm;

3. Virtual machine series: jvm runtime data area;

4. Virtual machine series: object creation, memory layout and access positioning in JVM;

5. Virtual machine series: garbage collector in JVM;

6. Virtual machine series: memory allocation in JVM;

7. Virtual machine series: understand the logs and log parameters of virtual machines;

8. Virtual machine series: basic tools for virtual machine performance monitoring;

9. Virtual machine series: basic tool for virtual machine performance monitoring-jstat;

Guess you like

Origin juejin.im/post/7088492612885151752