Enabling Remote JMX
11:03 AMEach application server has a slightly different process for enabling remote JMX Access. It's best to consult with your application server for specific instructions.
For a default tomcat install, one can simply add the following line at the top of server/tomcat/bin/catalina.sh after initial comments (remember, many customers or admins modify start up scripts to a great extent, but the principle of enabling JMX remains same)
CATALINA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=12345 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
One can then use JConsole (jconsole is available in openjdk software) to connect to <IP>:12345, where IP has to be replaced with host IP.
Note: You should ensure port 12345 is opened from where the host is monitored. So, if you are would like to monitor JMX values from a third party monitoring such as zenoss, make sure port is opened to zenoss.
Wondering why we used CATALINA_OPTS instead of JAVA_OPTS?
Read the comments in catalina.sh
JAVA_OPTS (Optional) Java runtime options needs to be used when the "start","stop", or "run" command is executed.
CATALINA_OPTS (Optional) Java runtime options used when the "start" or "run" command is executed.
You may encounter following error during tomcat shutdown:
Error: Exception thrown by the agent : java.rmi.server.ExportException : Port
already in use: 12345;nested exception is: java.net.BindException: Address already in use
To avoid error like this when shutting down tomcat, Port 12345 need not be in use while the instance is shutting down.
We are therefore using CATALINA_OPTS and disabling the exceution of this option during tomcat shutdown via "stop" in catalina.sh.
After the following lines in catalina.sh
elif [
"$1"
=
"stop"
] ; then
shift
FORCE=
0
if
[
"$1"
=
"-force"
]; then
shift
FORCE=
1
fi
Change
"$_RUNJAVA"
$JAVA_OPTS $CATALINA_OPTS \
to
"$_RUNJAVA"
$JAVA_OPTS \
This was actually a bug reported in apache site, you can find details for this issue at:
Tomcat shutdown bug while using JMX port
If you need JMX monitoring enabled via zenoss, please refer the following article:
0 comments