I have connected VisualVM via JMX to an AIX server to profile my Java process. But the "Profiler" tab is missing I just get Overview, Monitor and Threads.
Have I missed any configuration? When opening a local Java process I see the "Profiler" tab. Or isn't it possible to profile a remote application?
Which version of VisualVM do you use? "Profiler" tab is not available for remote applications, but you should be able to use "Sampler" tab, which uses JMX connection to do CPU sampling of your remote application.
I'm afraid that's not possible.
From the JVisualVm documentation:
Note. Java VisualVM can retrieve monitoring information on remote applications but it cannot profile remote applications.
You might want to refer to this for remote profiling: Is there a remote profiler for Java? (that uses JMX preferably)
Related
Memory Analysers (Instrumentation and Monitoring tools) like VisualVM and jProfiler connect to Java Application's JVM though JMX extensions (though there might be other means to connect - like jstatd etc, i have seen JMX is quite common)
My Understanding About JMX:
By default JMX must expose its default port(not sure if there is a default port number) so that Memory Analysers can connect. So, I assume that when more than one java apps are running with default JMX config, on the same machine, there must be a JMX port conflict.
But I have never noticed that. I have seen java apps running happily with default configs and Mem Analysers could happily connect with each of these java apps at the same time. So my understanding about JMX ports is not entirely correct. Could some one say how more than one java app is able to expose JMX functionality with default configurations at the same time on the same machine. (???? is a random port used by JMX for each java application????)
Tools like VisualVM use JMX together with Dynamic Attach mechanism to monitor local Java Virtual Machines.
First, the tool connects to a local JVM via Attach
API.
Then it executes (also via Attach API) a command to start Management Agent (JMX server) in the target JVM.
The target JVM starts Management Agent on some free port and sets the opened port value in the Agent properties.
The tool uses Attach API again to read Agent properties, and thus discovers the port the Agent listens to.
Then it establishes the JMX connection to the Management Agent on this port.
Obviously, different local JVMs start Management Server on different ports, but VisualVM discovers the port number via Dynamic Attach.
I have an app that consumes so much memory, I would like to profile it, but I'm unable to start the app and pass the argument -agentpath; after I add this argument it waits for the profiler to connect, and so the GAE application doesn't startup. I get this message
Profiler Agent: Waiting for connection on port 5140 (Protocol version: 15)
I'm using maven to start up GAE application.
Sample command to start up:
java -agentpath:C:/visualvm_139/profiler/lib/deployed/jdk16/windows-amd64/profilerinterface.dll=C:\visualvm_139\profiler\lib,5140 -javaagent:C:\Users\User\.m2\repository\com\google\appengine\appengine-java-sdk\1.9.59\appengine-java-sdk\appengine-java-sdk-1.9.59\lib\agent\appengine-agent.jar -Dappengine.fullscan.seconds=5 -classpath C:\Users\User\.m2\repository\com\google\appengine\appengine-java-sdk\1.9.59\appengine-java-sdk\appengine-java-sdk-1.9.59\lib\appengine-tools-api.jar com.google.appengine.tools.development.DevAppServerMain -p 8888 C:\Users\User\eclipse\workspace\App\
An alternative solution would be using;
-Xdebug
-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=y
which would block the app until a debug client is attached on port 8000.
If you are having trouble using VisualVM with App Engine, you can try another approach, such as using Stackdriver to monitor different aspects of your Java VM, such as memory usage.
This link has all the useful information on how to set up a Stackdriver agent and use its monitoring functions to determine where the memory leaks come from.
If you don't need to profile startup of your application (from the description it looks like you don't), just start your application normally (without -agentpath). Start VisualVM, open your application and go to Profiler tab.
if you need to profile startup of your application use Startup profiler. It will tell you, what you should do.
I have my web application running on java 8, which i need to connect through jconsole . I am able to connect jconsole without any change(i am not sure
if i did any change in the past) but my collegue is not able to connect through jconsole
We both are running java application separately on our windows machine with separate jconsole on same box.
So my question in general is do we need to do any configuration/setting to monitor java application/process from jconsole on same machine or remote machine?
VisualVM/VisualGC provides quite a lot of useful GC-related metrics in real-time, but I want a command-line tool that can connect to a remote application via jstatd and record in CSV or XML ideally exactly the same metrics as VisualGC provides. It shouldn't be a problem to write my own, but from the first look I cannot find what protocol visualvm/jstatd use.
As I understand VisualGC is not open source: https://stackoverflow.com/questions/11096466/where-is-the-source-code-repository-for-visualgc, but are there any alternative open source tools? Are there any clues how about the protocol used?
I managed to connect to jstatd via RMI (default port 1099, JStatRemoteHost is the rmi-name), can attach to a particular VM - but http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/sun/jvmstat/monitor/remote/RemoteVm.java#RemoteVm is rather a very low-level interface with jstatd.
I've checked out the VisualVM source code from https://svn.java.net/svn/visualvm~svn/trunk
and just started looking at the 5mb codebase, however it doesn't use neither RemoteHost nor RemoteVm RMI-classes.
Thanks.
First I looked at the source code of VisualVM (~5mb), created a command-line tool that registers JvmstatModelProvider on JvmstatModelFactory, gets an Application, creates JvmJvmstatModel and extracts all MonitoredValues - it connects to a remote application via jstatd and prints changed values in format timeMillis,name,value
1369270235646,sun.gc.generation.2.space.0.capacity,16777216
1369270236666,sun.os.hrt.ticks,2511500491
1369270237581,sun.gc.generation.0.space.0.used,641408
1369270237582,sun.os.hrt.ticks,2512502544
One hour later I found the right command-line tool for my task https://code.google.com/p/hatter-source-code/wiki/hotstat, that doesn't use jstatd - but fine, I can still run it remotely via ssh.
I've had a Spring 3.x application running on Solaris (5.10) in a VMWare VM for quite a while. My application registers some mbeans. I've been able to connect remotely to the VM from VisualVM and view data in the "Monitor" tab, and I've been able to see and manipulate my application mbeans in the MBeans tab.
My server was recently moved to another VMWare VM, although the host name and IP address didn't change. We got it all working, I thought, until I noticed some odd behavior when I tried to connect to the VM from VisualVM on my desktop. When I first tried it, I thought it was working fine, but when I looked closer I noticed that there was no "Monitor" tab, and when I looked at the MBeans tab, it didn't have any of my application mbeans.
I can run a local WebLogic instance, and I don't see these issues when I connect locally with VisualVM.
It doesn't seem like it would be a firewall problem. The connection succeeded. In the "Overview" tab I can see all the basic property settings.
Why would my remote connection have "degraded" functionality?
It looks like your remote is connected to the wrong MBeanServer, which is to say, rather than connecting to the WebLogic Domain Runtime Server, you are connecting to the JVM's platform MBeanServer. I'm not certain, but I think you should be able to connect to any of the three MBeanServers running in the WebLogic instance, as outlined here.
There is also an option to register your Weblogic Domain MBeans in the platform MBeanServer.