Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cccaternberg/85e2eca4eeb04187ec52f88be71e11d0 to your computer and use it in GitHub Desktop.
Save cccaternberg/85e2eca4eeb04187ec52f88be71e11d0 to your computer and use it in GitHub Desktop.
How to enable remote JMX access
java -jar yourApp.jar [JVM_OPTIONS]
For local host access only JVM_OPTIONS are:
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=9010
-Dcom.sun.management.jmxremote.host=127.0.0.1
-Dcom.sun.management.jmxremote.local.only=true
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
For full remote access JVM_OPTIONS are:
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=9010
-Dcom.sun.management.jmxremote.local.only=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
Prefer IPv4 over IPv6:
-Djava.net.preferIPv4Stack=true
Example:
java -jar MyJar.jar -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9010 -Dcom.sun.management.jmxremote.local.only=true -Dcom.sun.management.jmxremote.host=127.0.0.1 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.net.preferIPv4Stack=true
More:
http://java.sun.com/javase/6/docs/technotes/guides/management/agent.html
@cccaternberg
Copy link
Author

cccaternberg commented May 29, 2018

#from my mashine
#open SOCK to remote mashine
ssh -fN -D 7777 user@remotehost
##start jconsole
jconsole -J-DsocksProxyHost=localhost -J-DsocksProxyPort=7777 service:jmx:rmi:///jndi/rmi://localhost:9010/jmxrmi -J-DsocksNonProxyHosts=
#start the process on remote mashine, paramters see this gist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment