3

I understand from Oracle's documentation of VisualGC (and everything I found from SO on the subject, this question for instance) that a jstatd server is required when using VisualGC to connect to a remote JVM.

My JVM is running in a docker container, and the only process running in that container is the JVM, I hope to keep it this way as is the best practice for containers.

Is there any way I can use VisualGC (my client is the VisualGC plugin for VisualVM) with a JVM running in docker?

AlBlue
  • 23,254
  • 14
  • 71
  • 91
gogstad
  • 3,607
  • 1
  • 29
  • 32

3 Answers3

2

Here is how to do this easily.

  1. Launch ejstatd in your remote host this way (executing from the ejstatd folder): mvn exec:java -Dexec.args="-pr 1099 -ph 1100 -pv 1101"
  2. Open those 3 ports on your remote host and make them available to your local machine: 1099, 1100 and 1101
  3. Identify the <lvmid> of your running Java application using jps from your local machine (replace <remotehost> with your remote host name): jps -m -l rmi://<remotehost>:1099
  4. You can now use visualgc by launching it this way (replacing <lvmid> and <remotehost> with the correct values): visualgc <lvmid>@<remotehost>:1099

Disclaimer: I'm the author of the open source ejstatd tool

Anthony O.
  • 22,041
  • 18
  • 107
  • 163
0

Just use jstatd in docker together with your application. I don't think it violates docker's best practices.

AlBlue
  • 23,254
  • 14
  • 71
  • 91
Tomas Hurka
  • 6,723
  • 29
  • 38
-1

The VisualGC and friends connect over JMX, usually via port 1099. So if you set up your Docker container to passthrough TCP requests from port 1099 inside the docker container to an accessible port outside, then you should be able to connect to that remotely.

AlBlue
  • 23,254
  • 14
  • 71
  • 91
  • 2
    This doesn't work. On the Visual GC tab, VisualVM just shows "Not supported for this JVM". – Keegan Jan 04 '19 at 14:05