How to find the JMX port in a server?

一曲冷凌霜 提交于 2019-12-03 10:54:23

问题


I am sure I can figure it out if I can see the JAVA OPTS parameters. I want to monitor a hornetq server using Jconsole, so I need the port number.

I remember using some command like java grep etc when I connected to it a while back.


回答1:


If you know the process number you can use netstat to find what ports the program is listening on with something like

$ netstat -apn | grep <proc num>

The conventional port for JMX listeners is 1099.




回答2:


I know it's an old post. You can also get the details from System:

String jmx1 = System.getProperty("com.sun.management.jmxremote");
String jmx2 = System.getProperty("com.sun.management.jmxremote.port");
String jmx3 = System.getProperty("com.sun.management.jmxremote.authenticate");
String jmx4 = System.getProperty("com.sun.management.jmxremote.ssl");
String jmx5 = System.getProperty("java.rmi.server.hostname");



回答3:


You can also manually set the port from the JVM commandline settings, e.g:

-Dcom.sun.management.jmxremote=true
-Dcom.sun.management.jmxremote.port=1616
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false



回答4:


You can programmatically access the JVM arguments like so:

import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
...       
RuntimeMXBean RuntimemxBean = ManagementFactory.getRuntimeMXBean();
List<String> arguments = RuntimemxBean.getInputArguments();


来源:https://stackoverflow.com/questions/7531211/how-to-find-the-jmx-port-in-a-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!