How to create a snapshot of the processor during production?

With VisualVM, I can connect to the local Java process, start / stop CPU profiling, and create a snapshot. I don’t even need to process the process using any special agents, etc.

Is it possible to do the same thing on a server without a head? I know that I can configure the process for debugging the debugger remotely, but I want to minimize the number and impact of changing the client environment. I just want to run the command in the profile for a while and generate a snapshot file that I can run scp for my workstation for analysis using VisualVM or equivalent.

Preferably, any program that I run for this should be freely distributed so that I can associate it with my Java application and have it in a client environment.

Ideally, as in VisualVM, I would like to be able to connect to a running system without rebooting.

The closest I have found so far is related to hprof :

  java -agentlib:hprof=cpu=samples,interval=20,depth=3 classname

but this requires a restart in order to start profiling, and the other to stop, because I don’t see a way to enable and disable the selection at runtime.

Is there a better way? If there is no ready-made solution, how to build it? This should be possible since VisualVM does this.

+4
source share
2 answers

, JMX. , , , .

, ,

-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=9876
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false

( , ), JVisualVM , " JMX" servername:9876 .

http://docs.oracle.com/javase/7/docs/technotes/guides/management/agent.html http://visualvm.java.net/jmx_connections.html


JVisualVM JVM, , JMX, .

, JVM JMX. JMX , JVisualVM . , .

API, JVM JMX JMX. , JMX JVisualVM .

, JMX. , . JVM, ThreadMXBean, .

+3

Source: https://habr.com/ru/post/1537013/


All Articles