首页  

jmx信息获取     所属分类 jmx 浏览量 1504
java.lang.management.ManagementFactory
javax.management.Attribute
javax.management.AttributeList
javax.management.MBeanAttributeInfo
javax.management.MBeanInfo
javax.management.MBeanServer
javax.management.MBeanServerConnection
javax.management.ObjectInstance
javax.management.ObjectName
javax.management.openmbean.CompositeDataSupport


MBeanServer server = ManagementFactory.getPlatformMBeanServer();

// 获取所有bean实例
Set instances = server.queryMBeans(null, null);


ObjectName objectName = instance.getObjectName();
// 获取 bean 信息
MBeanInfo mbeanInfo = server.getMBeanInfo(objectName);
// 获取 bean 属性 信息
MBeanAttributeInfo[] attrs = mbeanInfo.getAttributes();
// 从 bean信息中获取所有属性名 
String[] attrNames =  getAttributeNames(attrs);
// 批量获取 bean 属性值
AttributeList alist = server.getAttributes(objectName, attrNames);

List attrList = alist.asList();

public class Attribute implements Serializable   
    private String name;
    private Object value= null;
    
完整代码 
JmxUtil getMBeanInfoMap

https://gitee.com/dyyx/hellocode/blob/master/project/devtool/src/main/java/dyyx/util/JmxUtil.java


全程获取 jmx 信息

String url = "service:jmx:rmi:///jndi/rmi://127.0.0.1:9996/jmxrmi";      
		JMXServiceURL serviceURL = new JMXServiceURL(url);  
		JMXConnector conn = JMXConnectorFactory.connect(serviceURL);  
		MBeanServerConnection mbconn = conn.getMBeanServerConnection();  	  
		Set mbeans = mbconn.queryMBeans(null, null);	


public interface MBeanServer extends MBeanServerConnection



 使用jmx监控jvm     
 jdk jcmd 使用 
 jcmd PerfCounter 说明 
 arthas使用   

 tomcat之JMXProxyServlet   
 prometheus使用jmx_exporter监控jvm    
 JMX配置及java客户端远程连接JMX端口   

上一篇     下一篇
秒杀系统设计思路

Shenandoah垃圾收集器

httpclient post json数据

JMX之Jolokia使用

java类加载知识点

java代码获取所有jvm进程