问题背景:最近在做应用监控系统,使用jolokia+prometheus+grafana,其中jolokia负责获取JMX端点信息。
一、通过java.lang.management.ManagementFactory
类获取
java.lang.management.ManagementFactory
的成员变量是各种MXBean,我们可以直接获取起ObjectName,如下图:
/**
* String representation of the
* <tt>ObjectName</tt> for the {@link ClassLoadingMXBean}.
*/
public final static String CLASS_LOADING_MXBEAN_NAME =
"java.lang:type=ClassLoading";
/**
* String representation of the
* <tt>ObjectName</tt> for the {@link CompilationMXBean}.
*/
public final static String COMPILATION_MXBEAN_NAME =
"java.lang:type=Compilation";
/**
* String representation of the
* <tt>ObjectName</tt> for the {@link MemoryMXBean}.
*/
public final static String MEMORY_MXBEAN_NAME =
"java.lang:type=Memory";
/**
* String representation of the
* <tt>ObjectName</tt> for the {@link OperatingSystemMXBean}.
*/
public final static String OPERATING_SYSTEM_MXBEAN_NAME =
"java.lang:type=OperatingSystem";
/**
* String representation of the
* <tt>ObjectName</tt> for the {@link RuntimeMXBean}.
*/
public final static String RUNTIME_MXBEAN_NAME =
"java.lang:type=Runtime";
/**
* String representation of the
* <tt>ObjectName</tt> for the {@link ThreadMXBean}.
*/
public final static String THREAD_MXBEAN_NAME =<