首页  

JMX配置及java客户端远程连接JMX端口     所属分类 jmx 浏览量 1400
-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=9998


-Dcom.sun.management.jmxremote 
-Dcom.sun.management.jmxremote.authenticate=false 
-Dcom.sun.management.jmxremote.ssl=false 
-Dcom.sun.management.jmxremote.port=9998



import java.util.Date;

// java -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=9998   HelloServer
public class HelloServer {
	public static void main(String[] args) throws Exception {	
		while(true){		
			System.out.println("my hello server,"+new Date());
			Thread.sleep(1000);		
		}	
	}
}

启动 Helloerver
java -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=9998   HelloServer

客户端远程连接 JMX 端口 读取数据
注意连接url !!!

service:jmx:rmi:///jndi/rmi://127.0.0.1:9996/jmxrmi




JmxRemoteTest.java 


import java.util.Set;
import javax.management.MBeanServerConnection;
import javax.management.ObjectInstance;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;

public class JmxRemoteTest {
		
	public static void main(final String[] args) throws Exception{
	    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);	
		for(ObjectInstance item:mbeans){
			System.out.println(item);
		}
	}
}

上一篇     下一篇
postman中form-data x-www-form-urlencoded raw binary的区别

elasticsearch term 和 match

kafka1.1.0无法消费问题

AQS要点整理

自定义类加载器例子

java类加载器要点整理