When using jcmd
to monitor java process, there is a command ManagementAgent.start
.
Checking man page / oracle document / google, didn't found any description.
The question is:
- What is it used for?
ManagementAgent.stop: Stop remote management agent.
ManagementAgent.start: Start remote management unit
ManagementAgent.start_local: Start local management agent.
You can get an example at below link.
https://self-learning-java-tutorial.blogspot.com/2018/08/jcmd-managementagentstop.html
The ManagementAgent
commands of jcmd will call methods of the jdk.internal.agent.Agent
class on the target JVM:
start
calls startRemoteManagementAgent()
,start_local
calls startLocalManagementAgent()
,stop
calls stopRemoteManagementAgent()
,status
calls getManagementAgentStatus()
.Basically, what the first two do is start a JMX connector server (each with different parameters) for the platform MBean server of the target JVM. The status
command is useful to get information about the running JMX agents.
Source code for start_local
: https://github.com/openjdk/jdk/blob/master/src/hotspot/share/services/diagnosticCommand.cpp#L736
This command starts remote JMX agent as if
-Dcom.sun.management.jmxremote
command-line argument is set. See Monitoring and Management Using JMX Technology.