Sunday, April 19, 2015

Monitoring JBoss running as service from JVisualVM

Monitoring JBoss 4.x  that runs as a service in Windows server was not straight forward when I had to do that. There were some JVM settings required in order to monitor the server successfully. 

JVisualVM being the free tool, provides enough information on heaps, threads, CPU time and GC details. I found this an easy tool for performance monitoring in development and test setup. This tools is available with Hotspot JVM package (jVisualVM.exe inside bin folder) and can be used to monitor application performance. There are no settings required either at JVM end or in this tool. 

The settings required are at JBoss end and here is the step-by-step instruction on the same.

When the JBoss runs as a service changes need to be made in Windows Registry. Otherwise the below JVM parameters can be set in run.bat itself using JVM_OPTIONS environment variable. 

1. Open registry by entering "regedit" in command prompt. Found he parameters set in Registry at below location in my case.  Find out the JBoss setting location in your case first. 

HKEY_LOCAL_MACHINE
                                              SYSTEM
                                                             CurrentControlSet
                                                                                         Services
                                                                                                      MyJbossd
                                                                                                                      Parameters

2. Open "Parameters" section and add below parameters to existing setting

JVM Option Number 11=-Djavax.management.builder.initial=org.jboss.system.server.jmx.MBeanServerBuilderImpl
JVM Option Number 12=-Djboss.platform.mbeanserver
JVM Option Number 13=-Dcom.sun.management.jmxremote
JVM Option Number 14=-Dcom.sun.management.jmxremote.port=8077
JVM Option Number 15=-Dcom.sun.management.jmxremote.ssl=false
JVM Option Number 16=-Dcom.sun.management.jmxremote.authenticate=false 

//For remote debugging 
JVM Option Number 17=-Dcom.sun.management.jmxremote.local.only=false 
JVM Option Number 18=-Dcom.sun.management.jmxremote=true 
JVM Option Number 19=-Djava.rmi.server.hostname=0.0.0.0


3. Restart the JBoss from services.

4. Open VisualVM console. 

5. Right click on "localhost" and select "Add JMX"

6. Enter host/IP in case of remote monitoring and the port in this case is 8077. It should be something like below:

<IP>:8077

7. Successful connection would start the JBoss server monitoring.


Hope this simple steps helps. Happy monitoring!