Reputation: 312
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 -
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
Upvotes: 2
Views: 3319
Reputation: 98284
You need to run jstatd
on a remote host in order to use jstat
.
Having RMI Registry running is not enough. The Registry is just for registering various RMI services. -Dcom.sun.management.jmxremote
option starts jmxrmi
service (which works for VisualVM), but jstat looks for JStatRemoteHost
service.
Once you've started jstatd
, use jstat -options process_id@servername
command to monitor the remote VM.
Upvotes: 4