Remote profilling java application

2020-06-18 03:54发布

问题:

I'd like to ask how I can profile REMOTELY a java application. For debugging I can say which port the JVM must listen etc since the machine I'm trying to access is behind an ssh gateway so I manually create an SSH tunnel but I've been googling about the same thing but when profiling and I couldn't seem to find. Basically I'm looking for the equivalent of this command:

java -agentlib:jdwp=transport=dt_socket,server=y,address=8000 -jar /bla/bla 

but for profiling so that I can remotely attach a profiler.

回答1:

Disclaimer: My company develops JProfiler

With JProfiler, the VM parameter is like this:

-agentpath:/path/to/libjprofilerti.so=port=8849

"/path/to/libjprofilerti.so" is the path to the native agent library, on Linux x86, for a 32-bit JVM it would be [JProfiler installation directory]/bin/linux-x86/libjprofilerti.so. With the port parameter, you can tell the agent to listen on a specific port. You can set this to the port of your SSH tunnel.

You can easily generate this VM parameter by invoking Session->Integration Wizards->New Remote Integration in JProfiler's main menu:

On your local machine, you create a new session of type "Attach to profiled JVM" and choose the local port of your SSH tunnel (10022 in the screen shot):