Skip to content

Instantly share code, notes, and snippets.

@sandeepkunkunuru
Last active December 12, 2015 05:58
Show Gist options
  • Save sandeepkunkunuru/4725555 to your computer and use it in GitHub Desktop.
Save sandeepkunkunuru/4725555 to your computer and use it in GitHub Desktop.
Setting up Remote JVM monitoring using JConsole(or VisualVM) for Tomcat
# Uncomment the following line to make the umask available when using the
# org.apache.catalina.security.SecurityListener
#JAVA_OPTS="$JAVA_OPTS -Dorg.apache.catalina.security.SecurityListener.UMASK=`umask`"
#-----------Add below lines for remote JVM monitoring-------
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9010 -Dcom.sun.management.jmxremote.local.only=false"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false "
#----------Add above lines for remote JVM monitoring-------
----------------------------------
On the server side: http://docs.oracle.com/javase/6/docs/technotes/guides/management/agent.html#gdenl
To enable monitoring and management from remote systems, you must set the following system property when you start the Java VM.
com.sun.management.jmxremote.port=portNum
In the property above, portNum is the port number through which you want to enable JMX RMI connections. Be sure to specify an unused port number. In addition to publishing an RMI connector for local access, setting this property publishes an additional RMI connector in a private read-only registry at the specified port using a well known name, "jmxrmi".
Note - You must set the above system property in addition to any properties you might set for security, as described in Using Password Authentication and the sections that follow it.
Remote monitoring and management requires security, to ensure that unauthorized persons cannot control or monitor your application. Password authentication over the Secure Sockets Layer (SSL) and Transport Layer Security (TLS) is enabled by default. You can disable password authentication and SSL separately, as described in the next sections.
After you have enabled the JMX agent for remote use, you can monitor your application using JConsole, as described in Remote Monitoring with JConsole. How to connect to the management agent programmatically is described in Connecting to the JMX Agent Programmatically.
------------------------------------------------------
On the client side: http://docs.oracle.com/javase/6/docs/technotes/guides/management/jconsole.html
Setting up Remote Monitoring
To start JConsole for remote monitoring, you use the following command syntax.
$ jconsole hostName:portNum
In the command above, hostName is the name of the system running the application and portNum is the port number you specified when you enabled the JMX agent when you started the Java VM. For more information, see Remote Monitoring and Management.
If you do not specify a host name/port number combination, then JConsole will display a connection dialog box (Connecting to a JMX Agent) to enable you to enter a host name and port number.
----------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment