我们可以使用 JMX 进行警报/通知吗

发布于 2024-07-09 00:19:18 字数 242 浏览 5 评论 0原文

简而言之,以下是我试图实现的规范:

1) 必须针对应用程序中的某些事件发送一些警报。

2) 这些警报需要用户订阅。

3) 用户已设置自己的通知首选项(例如电子邮件和/或短信)。

到目前为止我还没有找到Java的开源解决方案。

JMX 通知是一个选项吗? 我对 JMX 的了解越多,我就越觉得它正在尝试实现与我的问题不同的东西。

任何帮助都会有用的。

Here are the specs that I'm trying to implement in a nutshell:

1) Some Alerts have to be sent on certain events in the application.

2) These Alerts have Users subscribe to them.

3) And the Users have set their own Notification preferences (e.g. Email and/or SMS).

I have not been able to find an open source solution in Java so far.

Is JMX Notifications an option? The more I read about JMX, the more I feel that it is trying to achieve something different that my problem.

Any help would be useful.

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

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

发布评论

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

评论(6

你的往事 2024-07-16 00:19:18

JMX可以是解决这个问题的一种机制,但它并不是完整的解决方案。

JMX 为您的程序提供设施和服务,以允许客户端访问监视数据并允许客户端对应用程序进行控制调用。

正如您提到的,JMX 的一方面是通知系统。 该系统提供的基础设施使您的程序可以轻松地向客户端发出警报和通知,并且现代 JVM 还提供免费的 JMX 服务器以允许客户端远程连接到您的应用程序并订阅这些事件。

但发出 JMX 警报是一回事,而对其采取行动则完全是另一回事。

您需要做的是在某个地方有一些 JMX 客户端“订阅”您的程序的 JMX 通知,然后该客户端可以通过发送电子邮件或其他方式对这些通知采取行动。

JMX 客户端可以是通过 TCP 与应用程序通信的远程客户端,也可以是程序内的内部 JMX 客户端,例如在线程中运行,并且它可以对通知进行操作。

因此,基本上,JMX 为您想要做的事情提供了管道和基础设施,但不会将警报转换为电子邮件的“最后一英里”。

正如 @fawce 提到的,有一些不同复杂程度的“通用”JMX 客户端可以对 JMX 数据进行操作,并且可以执行您想要的操作(我对它们不熟悉,所以我不能直接说),或者您可以编写代码您自己的系统来监视 JMX 数据。

JMX can be a mechanism to solve this problem, but it's not the complete solution.

JMX provides facilities and services to your programs to allow clients to access monitoring data as well as allowing clients to make control calls to the application.

As you mentioned, one aspect of JMX is the notification system. What this system provides is infrastructure to make it easy for your program to make alerts and notifications available to clients, and modern JVMs also provide a free JMX server to allow client to connect to your application remotely and subscribe to those events.

But its one thing to make a JMX alert, and it's another thing completely to act on it.

What you would need to do is have some JMX client, somewhere, "subscribe" to the JMX notifications of your programs, and then THAT client can act upon those notification by sending emails, or whatever.

The JMX client can be a remote client talking to your application via TCP, or it can be an internal JMX client within the program, running in a thread, say, and it can act on the notifications.

So, basically, JMX provides the plumbing and infrastructure for what you want to do, but doesn't take it "the last mile" to converting alerts in to emails.

As @fawce mentioned, there are some "generic" JMX clients of various sophistication that can act upon JMX data and may do what you want (I'm not familiar with them, so I can not say first hand), or you can code your own system to monitor the JMX data.

维持三分热 2024-07-16 00:19:18

有一篇文章包含在应用程序中使用 JMX 发出警报的示例代码: 使用 JMX 传送通知

一旦您使用本地监控,您需要在执行程序时设置这些属性:

-Dcom.sun.management.jmxremote.port=9999 
-Dcom.sun.management.jmxremote.authenticate=false 
-Dcom.sun.management.jmxremote.ssl=false

..以便您可以使用 jconsole 或其他具有 JMX 功能的工具从远程计算机进行连接。

JManage 是监控支持 JMX 的 Java 进程的众多程序之一,能够:

  • 绘制移动图表的网页
  • 当阈值更改时发出电子邮件
  • 远程控制

您可以轻松升级到更复杂的工具,例如 Nagios 或其他商业工具。 这些工具具有适合大型团队的工作流程、角色和其他功能 - 如果您刚开始使用 JMX 的 Java 端,这可能会分散您的注意力。

There is an article with sample code for using JMX in your app to raise alerts: Delivering notification with JMX.

Once you have that working with local monitoring, you need to set these properties when executing your program:

-Dcom.sun.management.jmxremote.port=9999 
-Dcom.sun.management.jmxremote.authenticate=false 
-Dcom.sun.management.jmxremote.ssl=false

.. so that you can connect from a remote machine using jconsole or other tool with JMX capabilities.

JManage is one of many programs to monitor JMX-enabled Java processes capable of:

  • plotting webpages of moving graphs
  • emitting e-mails when thresholds change
  • remote control

You can easily upgrade to something more complex, such as Nagios or another commercial tool. Those tools have workflows, roles and other features suitable for big teams - which might be a distraction if you just starting out with getting the Java side of JMX working.

忆伤 2024-07-16 00:19:18

如果您指的是 JMX,则有一个名为 monju 的 JBoss/Nagios 桥,它具有通用的 JMX 挂钩。

If you mean JMX, there is a JBoss/Nagios bridge called monju that has a generlized JMX hook.

魂牵梦绕锁你心扉 2024-07-16 00:19:18

我建议使用 JMX 通知和 SNMP,它们应该支持您的场景,2) 和 3) 被 SNMP 软件涵盖。

只要您可以使用某些 API 访问 SMS 网关,您也可以自己用 Java 进行编码。 只要您有权访问允许匿名访问的 SMTP 主机,使用 javax.mail 就很简单。 2) 的灵活发布-订阅机制可用于连接 1) 和 3)。

I would suggest using JMX notifications and SNMP which should support your scenario, 2) and 3) being covered by the SNMP software.

You could also code it in Java yourself as long as you have access to a SMS gateway with some API. Using javax.mail is straightforward as long as you have access to a SMTP host allowing anonymous access. A flexible publish-subscribe mechanism for 2) can be used to connect 1) and 3).

甜嗑 2024-07-16 00:19:18

Solarwinds 是一款商业企业监控工具,能够挂钩 JMX 进行监控。 它能够生成短信和电子邮件警报。

Solarwinds is a commercial enterprise monitoring tool that has the ability to hook into JMX for monitoring. It has the ability to generate SMS and Email alerts.

烛影斜 2024-07-16 00:19:18

您是指 JMS(而不是 JMX)吗? JMS 是一个消息传递 API,而 JMX 是一个监视/管理 API。
使用JMS作为后端是实现后端消息的好方法,它将负责解耦、负载平衡和持久性。 但是您仍然需要有一个组件来接收消息并将其发送给用户。

Do you mean JMS (instead of JMX)? JMS is an messaging API while JMX is a monitoring/administration API.
Using JMS as the back end is a good way to implement the back-end messages, it will take care of decoupaging, load balancing, and persistency. But you still have to have a component that receives the messages and send them on to the user.

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