Created
August 5, 2011 21:57
-
-
Save jeromatron/1128625 to your computer and use it in GitHub Desktop.
jmx/jconsole shell function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# jmx/jconsole tunneling shell function - add to .profile | |
# | |
# usage: jmx [keypair] [remote host] [remote port] | |
# example: jmx /keys/keypair.pem [email protected] 8080 | |
function jmx() { | |
keypair=$1 | |
remote_host=$2 | |
remote_port=$3 | |
proxy_port=10999 | |
ssh -i $keypair -f -D$proxy_port $remote_host 'while true; do sleep 1; done' | |
ssh_pid=`ps ax | grep "ssh -i $keypair -f -D$proxy_port $remote_host" | awk '{print $1}'` | |
jconsole -J-DsocksProxyHost=localhost -J-DsocksProxyPort=$proxy_port service:jmx:rmi:///jndi/rmi://0.0.0.0:$remote_port/jmxrmi | |
kill $ssh_pid | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment