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?
This command starts remote JMX agent as if -Dcom.sun.management.jmxremote command-line argument is set. See Monitoring and Management Using JMX Technology.
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