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

发布于 2024-09-26 20:36:27 字数 429 浏览 0 评论 0原文

我有一个在远程计算机上运行的 Java 进程,该进程设置了一些 mbean。我还在该机器上以与 Java 进程相同的用户身份运行 jstatd。 (mbean 可以通过编程方式或使用 -Dcom.sun.management.jmxremote... 等进行设置,这似乎没有什么区别)。

VisualVM 能够与它自动发现的进程建立 jstatd 连接,但这意味着我无法访问 mbean 或 CPU 历史图表等。或者,我可以创建一个显式 JMX 连接,这为我提供了常用的有用工具,但我希望应用程序在启动时分配一个随机 JMX 端口,此配置不能是静态的。

有什么方法可以让 VisualVM 通过 JMX 自动连接到我的进程吗?这需要它自动发现 JMX 端口,但我认为 jstatd 可以做到这一点。有谁知道有任何 VisualVM 插件可以自动执行此操作吗?

I have a Java process running on a remote machine, and the process sets up some mbeans. I also have jstatd running on that machine as the same user as the Java process. (The mbeans can be set up programmatically or using -Dcom.sun.management.jmxremote... etc, this doesn't appear to make a difference).

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. 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.

Is there any way to get VisualVM to auto-connect to my process via JMX? This would require it to auto-discover the JMX ports, but I would have thought jstatd could do that. Does anyone know of any plugins for visualvm to automate this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

音盲 2024-10-03 20:36:27

不幸的是,无法将随机 JMX 端口分配给远程应用程序。您可以使用以下命令启动远程应用程序

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

,VisualVM 将能够通过 Jvmstat< 读取此配置/a> (由 jstatd 提供)并自动打开与远程应用程序的 JMX 连接。因此,您需要为远程应用程序分配固定端口。一旦你拥有它,一切都会正常工作,VisualVM 将通过 JMX 自动连接到你的应用程序(事实上,它将结合来自 Jvmstat 和 JMX)。

Unfortunately there is no way to assign random JMX port to the remote application. 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. 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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文