Thursday, December 14, 2017

VisualVM for monitoring remote jvm

Using VisualVM we can monitor all the running Java Process and status of JDK behind these processes. VisualVM can be found inside the JDK bin directory.



By running VisualVM, by default we can access the locally run processes. To get the Remote Server processes, we have to connect with that server through credential. And in the target server, jstatd must be in running.

jstatd: 

Monitors Java Virtual Machines (JVMs) and enables remote monitoring tools to attach to JVMs. This command is experimental and unsupported. 
The jstatd command is an RMI server application that monitors for the creation and termination of instrumented Java HotSpot VMs and provides an interface to enable remote monitoring tools to attach to JVMs that are running on the local host.


To run jstatd, java security permission is required. For this purpose, at the starting of jstatd, argument will have to be passed in the command line as:

 jstatd -J-Djava.security.policy=/home/paul/jstatd.all.policy



content of jstatd.all.policy  is as:

bash-4.3$ cat /home/oracle/jstatd.all.policy

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


It permits only the min required security related permission .




No comments: