JMX remote monitoring on Linux

September 7, 2009 by
Filed under: java, linux 

When running Java based application servers such as JBoss or Tomcat it is essential to monitor the status of the process – it’s memory consumption, threads and so on. In order to do that, Sun had introduced the JConsole application in Java 5, and now we have its successor visualvm.

In order to monitor the java process, you need to add the following system properties to the command line:

-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=9999
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false

In the visualvm you just use the connection string host:9999.

However, sometimes the RMI listener listens to the wrong IP address, one which is inaccessible to the visualvm. Thanks to Pavel’s tip, I found a  way to overcome this is by adding the following parameters:

-Djava.rmi.server.hostname=$(hostname)
-Djava.rmi.server.useLocalHostname=true

Now it works like a charm!

For completeness, I’d mention you can secure the connection to the JVM, either by requiring user/password or by using SSL. If you are interested, please see this guide.

Comments

3 Comments on JMX remote monitoring on Linux

  1. Yuri on Mon, 4th Jan 2010 1:20 pm
  2. Thank you. It works

  3. Petar Ivanov on Fri, 26th Mar 2010 10:21 am
  4. Thank you very much.It works.I`ve spent 3 days of searching how to fix this and after reading this article I`ve made it.Thank you very much.

  5. Joan on Tue, 20th Jul 2010 1:16 pm
  6. Be careful if you have the -b ${IP_ADRESS} in java opts cause it can produce troubles on jmx port binding.
    Probably you have to change the $(hostname) to the defined binding adress.
    :)

Tell me what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!