VisualVM shows "Not supported for this JVM"
Asked Answered
S

2

6

I am trying to profile a remote JVM with VisualVM 1.4. I am running macOS High Sierra 10.13.6 locally, with the following OpenJDK version:

java -version
openjdk version "1.8.0_181"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_181-b13)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.181-b13, mixed mode)

The server runs Debian Stretch with the following OpenJDK:

java -version
openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-8u181-b13-2~deb9u1-b13)
OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)

When I monitor a JVM process locally, I see all these tabs and the profiling works just fine.

enter image description here

However, if I do that remotely, I see something like this:

enter image description here

Note the CPU window that says "Not supported for this JVM" and the reduced tabs, not including "Profiler". However, as you can see, I do see some data.

I am connecting via jstatd. On the server, following this article, I am running

jstatd -J-Djava.security.policy=/home/brandwatch/jstatd.all.policy -J-Djava.rmi.server.hostname=10.2.156.160 -Djava.rmi.server.logCalltrue

Answers like this indicate that this might be due to different JVM versions, however, mine appear to be the same, despite one of them running on MacOS and one of them on Debian.

Spadefish answered 13/3, 2019 at 13:24 Comment(0)
I
2

Missing CPU usage information has nothing to do with with different JDK versions. You don't see CPU usage data because jvmstat (exported via jstatd) does not provide such information. If you want to see CPU usage, you need to use JMX connection. JMX will also allow you to do CPU and Memory sampling. Profiling is supported for local applications only.

Iolanthe answered 14/3, 2019 at 6:25 Comment(2)
Thank you, this is also what I had sort of figured out after some time. I can confirm, CPU usage works with JMX, Profiling still doesn't.Spadefish
Sys property -Dcom.sun.management.jmxremote enables local JMX.Blenheim
S
2

Because, as Tomas Hurka's answer correctly indicates, remote profiling does not work with VisualVM, I have used a little hack to still make it work: I have installed VisualVM on the remote server and accessed it via X-forwarding. That way, VisualVM can access the process locally an thus profile it.

  1. ssh into the server with the -X flag

    ssh -C -X <user>@<host>

  2. download [VisualVM 1.4][8]

    wget https://github.com/visualvm/visualvm.src/releases/download/1.4/visualvm_14.zip

  3. unzip the archive

    unzip visualvm_14.zip

  4. run VisualVM

    ./visualvm_14/bin/visualvm

After a few seconds you should see a VisualVM window pop up. It's not very fast (just because x-forwarding is not), but for my use case it was alright.

Another way of achieving this might be using VNC, but I haven't tried that. The downside would be that you have to install all the desktop packages, which one might not want on a server.

Spadefish answered 14/3, 2019 at 16:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.