简体   繁体   English

如何在服务器中找到JMX端口?

[英]How to find the JMX port in a server?

I am sure I can figure it out if I can see the JAVA OPTS parameters. 如果我能看到JAVA OPTS参数,我相信我能搞清楚。 I want to monitor a hornetq server using Jconsole, so I need the port number. 我想使用Jconsole监视一个hornetq服务器,所以我需要端口号。

I remember using some command like java grep etc when I connected to it a while back. 我记得在我连接它的时候使用了一些像java grep等命令。

If you know the process number you can use netstat to find what ports the program is listening on with something like 如果您知道进程号,则可以使用netstat查找程序正在侦听的端口

$ netstat -apn | grep <proc num>

The conventional port for JMX listeners is 1099. JMX监听器的传统端口是1099。

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");

You can also manually set the port from the JVM commandline settings, eg: 您还可以从JVM命令行设置手动设置端口,例如:

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

You can programmatically access the JVM arguments like so : 您可以以编程方式访问JVM参数,如下所示

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM