Monday, February 18, 2013

Java VisualVM to monitor memory

Condition: You want to monitor the java heap size in your local PCs or remote servers. You could use Java VisualVM tool if your device (local PCs or remote servers) must have jdk1.5+ for program execution. For Unix and Linux, they must install X-windows first.

Step to run the Java VisualVM.
  1. echo "%JAVA_HOME%"
    (To show your installed JDK path. e.g. C:\Program Files\Java\jdk1.6.0_25\bin)
  2. cd "%JAVA_HOME
    (Go to your JDK bin)
  3. jvisualvm.exe
    (Run Java VisualVM tool)
According to the following picture, you will see that 3 Java Applications are running on my PC. They are
  1. Unknow Application (pid 3164)
  2. JDeveloper 11g (pid 248)
  3. Tomcat (pid 3560)

Double the java application you want to monitor. I chose Tomcat as an example. You can select Monitor, Threads, Sampler and Profiler tabs to view the statistic.

To monitor remote server (JBOSS), you could
  1. Right click "Remote" and select "Add Remote Host..."
  2. Input your Host Name such as 192.168.254.111
  3. Click "Advanced Settings" and input Post 2020 (jstsd port - RMI Broadcasting - Listener) and set the Refresh Interval
  4. Then you will see 192.168.254.111 under remote
  5. Right click 192.168.254.111 and select "Add JMX Connection"
  6. Input Port "1090" (JMX port setting in Jboss - Check your server setting)
  7. Input Username and password
My Personal Jboss Testing Server Setting
  • JMX port in JBoss server : 1090
  • jstatd port in JBoss server : 2020
  • jstatd port in local (PC) Tomcat server (your IP) should be as default

No comments:

Post a Comment