Friday, January 10, 2014

Quick enable simple password protected Remote JMX with tomcat

You need to do following configuration to enable Remote JMX monitoring on tomcat server.
  1. Copy jmxremote.password.template located at JRE_HOME/lib/management inside the same folder with the name jmxremote.password.  
  2. Edit this jmxremote.password file and uncomment last two lines starts with monitorRole and controleRole and instead of QED and R&D set some good password for both of them.
  3. Change directory to CATALINA_HOME/bin from where you start the tomcat.
  4. You will find (if you don't find it create one) and add following line inside file CATALINA_OPTS="$CATALINA_OPTS -Djava.rmi.server.hostname="
  5. Here in above line you need to set proper ip address which is accessible from remote machine to -Djava.rmi.server.hostname and set available port number to 
  6. Once all this settings are done restart / start tomcat.
Above steps will enable remote JMX on this JVM. To monitor it using jconsole from remote machine follow below steps from remote machine.
  1. Start jconsole $ jconsole
  2. Select Remote Process option and enter "<remote ip address>:<port>", specify username as monitorRole or controleRole and password that you set inside jmxremote.password file for corresponding user.
This should start remote monitoring of remote JVM tomcat.