如何创建由 jmx 公开并通过 jconsole 访问的性能计数器?

发布于 2024-09-10 01:44:20 字数 123 浏览 1 评论 0原文

如何创建由 jmx 公开并通过 jconsole 访问的性能计数器?

假设每当我实例化一个特定对象时,我都会增加一个计数器。我想公开计数器值,以便可以在 jconsole 中查看该值。

我该怎么做呢?

How to create performance counters that are exposed by jmx and accessed via jconsole?

Say whenever I instantiate a particular object, I increment a counter. I want to expose the counter value so I can view the value in jconsole.

How would I go about doing this?

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

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

发布评论

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

评论(1

陌路终见情 2024-09-17 01:44:20

有几个步骤:

  • 定义一个公开计数器的 MBean 接口。
  • 创建该接口的实现
  • 使用 ManagementFactory.getPlatformMBeanServer().registerMBean(...) 向平台 MBean 服务器注册实现
  • 从 jconsole 访问 MBean

有详细信息,请参阅 JMX 教程

There's a few steps:

  • Define an MBean interface that exposes your counter.
  • Create an implementation of that interface
  • Register the implementation with the platform MBean server using ManagementFactory.getPlatformMBeanServer().registerMBean(...)
  • Access the MBean from jconsole

There are details in the JMX tutorial.

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