kevinarpe
kevinarpe

Reputation: 21309

How to detect if JMX agent is running, and using which port?

If Java system property com.sun.management.jmxremote is defined at JVM start-up, the JMX agent will be started on port defined in system property com.sun.management.jmxremote.port.

However, there are also techniques to launch the JMX agent / listener at run-time. (See: Monitoring and Management Using JMX Technology , Section: Mimicking Out-of-the-Box Management Using the JMX Remote API)

Is there a reliable way to detect if the JMX agent is running, and can I find the port at run-time?

Related: What happens if run-time code starts two JMX agents on different ports?

Why do I ask? I want to auto-magically start the JMX agent on an ephemeral port if not already started.

Upvotes: 2

Views: 4934

Answers (1)

AutomatedMike
AutomatedMike

Reputation: 1512

There is no way to discover jmx connector servers that I have found. However if you do start two jmx connectors then you have two ports through which you can access the PlatformMBeanServer. This shouldn't cause any harm.

Upvotes: 1

Related Questions