Wednesday, December 19, 2012

jvisualvm remote tomcat

http://www.codefactorycr.com/java-visualvm-to-profile-a-remote-server.html
:
Start jstatd:
Given JAVA_HOME=/usr/lib/jvm/java-6-sun/bin
 Write following config to /usr/lib/jvm/java-6-sun/bin/jstatd.all.policy
grant codebase "file:<JAVA_HOME>/lib/tools.jar" {
permission java.security.AllPermission;};

 > /usr/lib/jvm/java-6-sun/bin/jstatd.all.policy

Then execute jstatd as
./jstatd -J-Djava.security.policy=jstatd.all.policy &


Identify jstatd ports as given in above link and make necessary firewall modifications.

Result: We can see the remote jstatd process in local jvisualvm as a remote process under the host.(plz add the host)

http://stackoverflow.com/questions/3892084/can-visualvm-connect-automatically-via-jmx-to-a-remote-process
:
Open tomcat's startup.sh and add following lines before the call
exec "$PRGDIR"/"$EXECUTABLE" start "$@"

JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.port=60000 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"

 Now you can even see your server along with jstatd under the remote host.

For JConsole:
http://docs.oracle.com/javase/1.5.0/docs/guide/management/jconsole.html:
Just connect to <host>:60000 (port no. set in the jmx settings specified in JAVA_OPTS above) and it works.

Thanks,
Tapomay.

No comments:

Post a Comment