JDK comes with JVM analysis tools

1. Inventory of JDK's own tools:


jstat: performance analysis - view gc situation;

jmap: memory analysis - heap information;

jstack: thread analysis - stack information;

jinfo: parameter viewing and configuration;

jstatd: Start the jvm monitoring service. It is an rmi-based application that provides information from native jvm applications to remote machines. Default port 1099;

jdb : JDB is a text-based and command-line debugging tool;

jhat: A tool for offline analysis of JAVA heap. It can analyze the heap information files exported from different virtual machines. For example, the files exported on LINUX can be analyzed on WINDOWS to find problems such as memory;

jps : jps is used to view the specific status of all processes in the JVM, including the process ID, the path to start the process, etc.;

jconsole: It is a real-time graphical monitoring tool based on JAVA Management Extensions (JMX). This tool uses the JMX instructions built into the JVM to provide real-time performance and resource monitoring, including memory usage, heap and threads of JAVA programs. Information, class allocation status and space usage, deadlock detection, etc.;

JVisualVM: jvisualvm is a tool brought after jdk1.6, an upgraded version of jconsole, and supports plug-in expansion;

jstat, jmap, jstack, jdb, jconsole are all before 1.6, and then replaced by JVisualVM. Therefore, JDK's own tools only need to use jps, jVisualVM and jStatd.
 

Second, the use of common tools

jps:

jstatd:

 jstatd can only monitor JVMs that have the appropriate native access rights. Therefore, the jstatd process must run with the same user credentials as the target JVM.

jVisualVM:

Install the plugin: Plugin Marketplace: VisualVM: Plugins Centers 

 

 You can choose to install the plug-in

 Click on the thread to see if the status of the deadlock is checked

View the heap:

 

 Partner jstatd remote monitoring:

cd /usr/local/java/jdk1.8.0_311/jre/lib/management

cp jmxremote.password.template jmxremote.password

chmod 644 jmxremote.password

Then create a file jstatd.all.policy in the bin directory of java, the content is

grant codebase "file:/usr/local/java/jdk1.8.0_311/lib/tools.jar" {
permission java.security.AllPermission;
};

start service

jstatd -J-Djava.security.policy=/usr/local/java/jdk1.8.0_311/bin/jstatd.all.policy  -p 1099 &

Verify successful startup:

netstat -anp |grep jstatd

Note: The cloud server remembers that in addition to 1099, the corresponding port access permission needs to be enabled 

Open JvisualVM, right-click remote, add server host, advanced settings or add jstatd link default port 1099, then wait for automatic refresh to display.

Corresponding version official manual: Java Platform, Standard Edition Documentation - Releases

Guess you like

Origin blog.csdn.net/Angel_asp/article/details/129469022