VisualVM plus jstatd to remotely monitor remote hosts through JMI

VisualVM is used to monitor various parameters of the underlying JVM of JAVA applications, including CPU, memory, thread, and garbage collection waiting state.

After starting VisualVM, you can directly view the local JAVA application, but if you want to see the JVM status of the JAVA application on the remote server, you need to configure it. The configuration method is as follows:

1. Log in to the remote server, enter the cd $JAVA_HOME/bin directory, create the jstatd security management file jstatd.all.policy, and add the following content:

grant codebase "file:${java.home}/../lib/tools.jar" {
       permission java.security.AllPermission;
};

[root@test bin]# cd $JAVA_HOME/bin
[root@test bin]# vim jstatd.all.policy

grant codebase "file:${java.home}/../lib/tools.jar" {
       permission java.security.AllPermission;
};

 

2. Execute the RMI monitoring start command:

rmiregistry 2020 &jstatd -J-Djava.security.policy=all.policy  -p 1099  -J-Djava.rmi.server.hostname=192.168.100.52 &

[root@test  bin]# rmiregistry 2020 &jstatd -J-Djava.security.policy=all.policy  -p 1099  -J-Djava.rmi.server.hostname=192.168.100.52 &

 rmiregistry 2020 starts the remote messaging service

 

 jstatd -J-Djava.security.policy=all.policy starts monitoring according to the security policy (if the hosts file is not properly configured, it may be abnormal to start it alone)

 -p 1099 Start port 1099 for monitoring VisualVM

 -J-Djava.rmi.server.hostname=192.168.100.52 Local IP (if the hosts file is not properly configured, you can manually specify the local IP for VisualVM to perform configuration monitoring)

 & Background process

 

3. Configure remote monitoring (usually on the Windows host or the machine where the VisualVM monitoring software is located)

 Start the VisualVM monitoring software, right-click on the remote node and select a new remote host, then enter the IP, port, etc. of the remote host, and click OK to monitor.



 

      You can view the monitoring information by double-clicking the specific application, such as Visual GC, this is to view the JAVA GC status, and you can view the active status of each memory partition.


 

Remark:

    If the execution process is abnormal, it is usually because the CLASSPATH, hostname /etc/hosts configuration error:

    The solution is to join CLASSPAHT

    

JAVA_HOME=/usr/java/jdk1.6.0_45
CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

 Or add the hostname to the startup command:
 rmiregistry 2020 &jstatd -J-Djava.security.policy=all.policy -p 1099   -J-Djava.rmi.server.hostname=192.168.100.52 &

 

 

 

Guess you like

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