| Java VisualVM to profile a remote server |
|
Since Version 1.5, Sun's JDK includes a nice profiling tool called VisualVM, intended to be used by developers, sysadmins and any person that needs to troubleshoot and profile memory consumption in Java applications and servers. To run it, just execute the file jvisualvm located in $JAVA_HOME/bin.
To profile local applications is pretty easy, since you only need to start it and it'll detect all Java-based applications and you'll be able to see the Heap/PermGen usage, the number of threads used, the classes loaded by the class loader and other stuff.
The jstatd tool is an RMI server application that provides a interface to allow remote monitoring tools to attach to JVMs running on the local host.
Then, just
run the jstatd application from the command line, like this: After this, check the ports that need to be opened to allow the remote instance of VisualVM to connect to it. This application opens 2 ports: the default RMI port, which is 1099, and then a random port, which changes every time you start the application. To check which ports are used by jstatd, run the following command: netstat -nlp | grep jstatd And you should get an output like this: The 4th column indicates the ports that are open. In this case, the ports that need to be opened in the firewall are 1099 and 39779. To open this, you should check IPTables documentation for how to accomplish this. After all ports are opened and jstatd is running, just open VisualVM, right click on Remote and select Add Remote Host, and finally type the IP address of the remote host. After this, you'll be able to see all Java-based applications running in the remote server, including Tomcat, Ant, jstatd and any other. The following screenshot shows a local VisualVM profiling an instance of Tomcat running in a remote host (click to enlarge):
Comments (0) |


