Skip to content

Instantly share code, notes, and snippets.

@nhtzr
Forked from dsmiley/gist:2583730
Created June 6, 2019 01:16
Show Gist options
  • Save nhtzr/66b39596950f8ecc94630a902fa860f9 to your computer and use it in GitHub Desktop.
Save nhtzr/66b39596950f8ecc94630a902fa860f9 to your computer and use it in GitHub Desktop.
jconsole via socks proxy
function jc_remote {
jmx_host=$1
jmx_port=${2:-5000}
proxy_port=${3:-8123}
echo "Connecting jconsole to $jmx_host:$jmx_port via SOCKS proxy using local port $proxy_port"
ssh -ND $proxy_port $jmx_host &
jconsole -J-DsocksProxyHost=localhost -J-DsocksProxyPort=${proxy_port} \
service:jmx:rmi:///jndi/rmi://localhost:${jmx_port}/jmxrmi
kill %1
#start remote java with:
#-Dcom.sun.management.jmxremote.port=5000
#-Dcom.sun.management.jmxremote.authenticate=false
#-Dcom.sun.management.jmxremote.ssl=false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment