Reputation: 535
I am new to Java and I'm facing a problem in connecting a Remote Host to the JVisualVM
.
I've searched the Internet and followed all the steps mentioned there but still am not able to resolve the issue. The steps I followed are:
I started the jstatd on the remote server by first creating a jstatd.all.policy
file in the $JAVA_HOME/bin
. The file contained: grant codebase "file:${java.home}/../lib/tools.jar" { permission java.security.AllPermission;};
I started the Jstatd
as jstatd -J-Djava.security.policy=jstatd.all.policy
I started the Java application on the remote host as :
java -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9000 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false application_name
I then started as instance of the JVisualVM
on my local machine and as I added the remote host, it got connected but i wasn't able to see any of the Java processes.
Can anyone please help me with this.
Thanks.
Upvotes: 23
Views: 41833
Reputation: 29266
Start jstatd in nohup on the server which needs to be monitored and connect VisualVM
to the jstatd port, following below steps:
Step 1 : Create start-jstatd.sh
and copy the below content:
nohup jstatd -p 1099 -J-Djava.security.policy=<(echo 'grant codebase "file:${java.home}/../lib/tools.jar" {permission java.security.AllPermission;};') &
Step 2: Give executable permission to the file:
$ chmod a+rwx start-jstatd.sh
Step 3: Start jstatd:
$ sh start-jstatd.sh
Step 4: Add Remote Host in VisualVM
:
Step 5: Add JMX Connection to the Remote Host, as shown in the below image and Click OK button:
Upvotes: 2
Reputation: 24297
Here are the steps to do this:
mvn exec:java -Djava.rmi.server.hostname=<remote_host_name> -Dexec.args="-pr 1099 -ph 1100 -pv 1101"
(used for "jstatd" type connection) (only specify -Djava.rmi.server.hostname
if the hostname of your remote host does not match with the one you are seeing from your local network)-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port=1102 -Dcom.sun.management.jmxremote.rmi.port=1102 -Djava.rmi.server.hostname=<remote_host_name>
(used for "JMX" type connection) (same remark as the previous point for -Djava.rmi.server.hostname
)1099
, 1100
, 1101
and 1102
1099
, you can change this in the "Advanced Settings")<remote_host_name>:1102
" in "Connection" input, and check "Do not require SSL connection"Disclaimer: I'm the author of the open source ejstatd tool.
Upvotes: 5
Reputation: 131
You need to start jstatd with the additional option that points to the server's external IP or hostname:
statd -J-Djava.security.policy=jstatd.all.policy -J-Djava.rmi.server.hostname=my_server_ip/hostname
Answer based on: https://java.net/projects/visualvm/lists/users/archive/2010-03/message/8
Upvotes: 12
Reputation: 3304
I encountered similar problems when connecting to Glassfish application server. See solutions that worked for me as they can be same for You:
-Djava.rmi.server.hostname=*Remote_Server_External_IP_Address*
If Firewall block is an issue then I recommend trying XMing with SSH tunnel (which is simple to set). Here is instruction, if You encounter problems setting it:
Remote use of VisualVM with Xming (my blog)
Biggest advantage of using XMing is that it will work almost always when SSH is enabled. You just have to place VisualVM files on the remote host and run it from command line. XWindow will show VisualVM Window on Your local computer.
There is a chance that it is VisualVM issue - try using some other tool just to verify what is wrong. I recommend JConsole. It works similar to VisualVM and I also described details on my blog
Upvotes: 18
Reputation: 4236
To connect to a remote VM you have to start that remote VM with specific options:
java
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=9000
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
class
After the VM is started, go to your VisualVM and do the following:
More details on the Java Monitoring and Management Platform can be found here.
Upvotes: 7