We often need to do a variety of testing of our development software, software use of system resources is not limited , there are a number of monitoring tools , compared to jprofiler system resources, especially memory consumption is very large, JDK1.6 began to bring the VISUALVM is a good monitoring tool.
This tool is in the java_home\bin\ directory of the Jvisualvm.exe, double-click the file will be able to see a more intuitive interface
As you can see from the left applications tree, you can monitor not only the local JVM operation, but also the JVM running on the remote machine.
Local monitoring: Whenever a Java program is opened, it is automatically added to local monitoring.
Because local monitoring does not need to be configured, this is mainly about monitoring remote JVMS
For remote monitoring, the VISUALVM of this machine must communicate with the remote JVM,VISUALVM currently supports two types ofRemote connection mode.
respectively isJSTATD andJMX Way: Here I mainly introduce through the JMX way.
Connecting a remote machine via JMX requires the following configuration:
1. Modify the remote machine JDK configuration file (I am here for the remote machine is Linux).
A. Enter the java_home\jre\lib\management\ directory
B.Copy jmxremote.password.template This file to the current directory and rename it toJmxremote.password
C. OpenJmxremote.password file, remove# Monitorrole QED and# Controlrole The comment symbols in front of these two lines
2. Modify the configuration file for the program that needs to be monitored on the remote machine (I am here to monitor the application deployed within the Tomcat container).
A. Enter the Tomcat_home\bin directory
B. Opencatalina.sh file, add the following information:
java_opts= "$JAVA _opts-djava.rmi.server.hostname=192.168.0.237
-dcom.sun.management.jmxremote.port=18999
-dcom.sun.management.jmxremote.ssl=false
-dcom.sun.management.jmxremote.authenticate=false "
C. Restart the Tomcat service.
3. Client VISUALVM configuration (my client is using WinXP).
A. Direct anti-key Click Remote, select Add Remote Host ...
B. Enter the IP address (192.168.0.237) of the remote machine in the popup interface and the IP address will be added to the Remotes node.
C. Counter-click on this IP address, select Add JMX Connection, enter the port number (18999) that you just configured in the popup interface, and the connection will be added to the IP node.
D. Counter-click on this connection and select Open.
At this point you can see the monitoring interface, from the interface we can see the CPU information, memory information, statistics load class number, thread information.
Monitor remote JVM CPU JPS using Java VISUALVM