如何获取String类型的ObjectName及其属性

问题背景:最近在做应用监控系统,使用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 =<
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值