Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CPU and profiling not supported for remote jvisualvm session

When monitoring a remote app (using jstatd) I can neither profile nor monitor CPU consumption. Heap monitoring (provided I do not use G1) works. jvisualvm provides the message "Not supported for this JVM." in the CPU graph window.

Is there anything missing in my setup? Google showed very few results.

The local environment (Mac OS X 10.6):

java version "1.6.0_15"
Java(TM) SE Runtime Environment (build 1.6.0_15-b03-219)
Java HotSpot(TM) 64-Bit Server VM (build 14.1-b02-90, mixed mode)

The remote environment (Linux version 2.6.16.27-0.9-smp (gcc version 4.1.0 (SUSE Linux))):

java version "1.6.0_16" Java(TM) SE
Runtime Environment (build
1.6.0_16-b01) Java HotSpot(TM) 64-Bit Server VM (build 14.2-b01, mixed mode)

Local monitoring works as advertised.

like image 526
yawn Avatar asked Nov 18 '09 13:11

yawn


People also ask

How do I run Jvisualvm on Windows?

On a Windows system, start VisualVM by double-clicking jvisualvm.exe. You can also select VisualVM from the Start menu (if Windchill shortcuts are installed). On other systems, start VisualVM by invoking the jvisualvm script.

How does remote process connect to VisualVM?

Connecting to a Remote Host To add a remote host, right-click the Remote node in the Applications window, choose Add Remote Host and type the host name or IP address in the Add Remote Host dialog box. (You can also specify a display name that will be used to refer to the host when listed under the Remote node.)

What is Profiler in VisualVM?

The Profiler tab of an application enables you to start and stop the profiling session of a local application. Profiling results are displayed in the Profiler tab. You can use the toolbar to refresh the profiling results, invoke garbage collection and save the profiling data.

How do I monitor remote JVM using VisualVM?

There are two ways to connect a remote JVM application to VisualVM: Either using jstatd or Java Management Extensions (JMX). The jstatd program is an RMI server that bundled with the JDK and monitors JVM and provides an interface to allow remote monitoring tools to attach to JVM running on the localhost.


2 Answers

Remote profiling of code and allocation isn't supported by Visual VM. This sucks, however if you want to enable the CPU graph you can do this by enabling JMX with

-Dcom.sun.management.jmxremote=true
-Dcom.sun.management.jmxremote.port=12345

You may need to add some authentication settings too based on your network. The JMX settings will give you the CPU usage, and thread state, as well as doing a remote jstack.

A list of features for the remote version can be found here: Visual VM features

EDIT Get the latest version of visual vm 1.2.1 and download the VisaulVM-Sampler. This will read from a JMX connection to show the profiling information.

like image 193
reccles Avatar answered Sep 26 '22 10:09

reccles


Connecting the eclipse java program.

Step 1: ensure your Eclipse -> Preferences -> Java -> Installed JREs is pointing to the same jdk where you have started the visualvm.

Step 2: Ensure Right click -> Run configuration has the following

-Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=16001

Step 3: Importantly follow the below suggestion.

https://visualvm.java.net/troubleshooting.html#jpswin2

Description: An error dialog saying that local applications cannot be monitored is shown immediately after VisualVM startup. Locally running Java applications are displayed as (pid ###).

Resolution: This can happen on Windows systems if the username contains capitalized letters. In this case, username is UserName but the jvmstat directory created by JDK is %TMP%\hsperfdata_username. To workaround the problem, exit all Java applications, delete the %TMP%\hsperfdata_username directory and create new %TMP%\hsperfdata_UserName directory.

Also try JVMMonitor is decent plugin for eclipse stand alone program monitoring.

like image 41
Kanagavelu Sugumar Avatar answered Sep 23 '22 10:09

Kanagavelu Sugumar