简体   繁体   English

visualvm可以通过JMX自动连接到远程进程吗?

[英]Can visualvm connect automatically via JMX to a remote process?

I have a Java process running on a remote machine, and the process sets up some mbeans. 我有一个在远程计算机上运行的Java进程,该进程设置了一些mbeans。 I also have jstatd running on that machine as the same user as the Java process. 我还在该机器上运行jstatd作为与Java进程相同的用户。 (The mbeans can be set up programmatically or using -Dcom.sun.management.jmxremote... etc, this doesn't appear to make a difference). (mbeans可以通过编程方式设置或使用-Dcom.sun.management.jmxremote...等,这似乎没有区别)。

VisualVM is able to make a jstatd connection to the process, which it discovers automatically, but this means I don't get access to mbeans or, for example, the CPU history chart. VisualVM能够与进程进行jstatd连接,它会自动发现,但这意味着我无法访问mbeans,或者例如CPU历史记录图表。 Alternatively I can create an explicit JMX connection, which gives me the usual range of useful tools, but I want for the application to be assigned a random JMX port when it starts, this config can't be static. 或者我可以创建一个显式的JMX连接,它给了我通常的有用工具,但是我希望应用程序在启动时被分配一个随机的JMX端口,这个配置不能是静态的。

Is there any way to get VisualVM to auto-connect to my process via JMX? 有没有办法让VisualVM通过JMX自动连接到我的进程? This would require it to auto-discover the JMX ports, but I would have thought jstatd could do that. 这将要求它自动发现JMX端口,但我原以为jstatd可以做到这一点。 Does anyone know of any plugins for visualvm to automate this? 有没有人知道visualvm的任何插件自动化这个?

Unfortunately there is no way to assign random JMX port to the remote application. 遗憾的是,无法将随机JMX端口分配给远程应用程序。 You can start your remote application with 您可以使用启动远程应用程序

-Dcom.sun.management.jmxremote.port=<fixed port>
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false

and VisualVM will be able to read this configuration via Jvmstat (provide by jstatd) and open JMX connection to your remote application automatically. VisualVM将能够通过Jvmstat (由jstatd提供)读取此配置,并自动打开与远程应用程序的JMX连接。 So you need to assign fixed port(s) to your remote application(s). 因此,您需要将固定端口分配给远程应用程序。 Once you have it, everything will work fine and VisualVM will automatically connect to your application via JMX (in fact it will combine data from both Jvmstat and JMX). 一旦你拥有它,一切都会正常工作,VisualVM将通过JMX自动连接到你的应用程序(实际上它将结合来自Jvmstat和JMX的数据)。

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

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