From the Jstat Documentation , jstat can be connected to a local as well as remote JVM. The URI can be formed as
[protocol:][//]lvmid[@hostname[:port]/servername]
I have a JVM running on one of the servers (CentOS) with JMX enabled -
xyz 23878 1 0 Jun01 ? 04:37:00 java -Xms1g -Xmx1g -XX:NewSize=512m -Xloggc:../9301/logs/gc.log -verbose:gc -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=../9301/logs/oom.log **-Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=19301 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.local.only=false** -jar ../0.1.14/xyz-0.1.14.jar -serviceName <name> -dataCenter <name> servicePort 9301
I am able to connect to the JVM, from my local machine, using JVisualVM which uses a 2 step process -
- Prompts to add the remote machine via jstatd connection on default port 1099 -> I am able to do so and server gets added proving RMI Registry is available
- After Adding the server, you can add a JMX connection to the JVM on the exposed port -> Success as JMX is exposed by my program on port 19301 and I am able to view the details
I am, however, not able to use jstat for the same purpose though.
Running jstat -gc process_id@servername gives me the below exception -
RMI Registry not available at <servername>:1099
Connection refused to host: <servername>; nested exception is:
java.net.ConnectException: Connection refused
Checked various sources over the net and they talk about having the jstatd running which I believe is running as VisualVM was able to add the machine.
Ques: How should I frame the [vmid] part in the jstat command to connect