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

时间:2021-11-08 16:58:05

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.

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

2) These Alerts have Users subscribe to them.

2)这些警报让用户订阅它们。

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

3)并且用户已经设置了他们自己的通知偏好(例如,电子邮件和/或SMS)。

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

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

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.

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

Any help would be useful.

任何帮助都会有用。

5 个解决方案

#1


12  

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

JMX可以是解决此问题的机制,但它不是完整的解决方案。

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.

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

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.

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

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

但是制作JMX警报是一回事,完全采取行动是另一回事。

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.

您需要做的是在某个地方安装一些JMX客户端,“订阅”您的程序的JMX通知,然后客户端可以通过发送电子邮件等处理这些通知。

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.

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

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.

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

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.

作为@fawce提到的,有各种复杂,可以在JMX数据采取行动,可能会做你想要的一些“通用” JMX客户端(我不熟悉,所以我不能说第一手),或者你可以编写您自己的系统来监控JMX数据。

#2


0  

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

如果你的意思是JMX,有一个名为monju的JBoss / Nagios网桥,它有一个通用的JMX钩子。

#3


0  

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

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

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

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

#4


0  

here is a good article with sample code for using jms in your app to raise alerts link text. once you have that working with local monitoring you need to set the -Dom.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. a nice simple program to monitor jmx enabled java which can plot webpages of moving graphs and email out alerts when thresholds change is link text. it will also let you remote control your apps via the webpages. nice and simple. of course if you are using jmx you can easily swap up to use something more complex such as nagios or some expensive commercial tool. the key points about those tools is that they have workflow and rotas and stuff to manage a big team of people wanting to look after lots of things (databases, servers, java, etc) - which may be too much complexity if you just starting out with getting the java side of jmx working.

这是一篇很好的文章,其中包含在您的应用中使用jms来提升警报链接文本的示例代码。一旦你使用本地监控,你需要设置-Dom.sun.management.jmxremote.port = 9999 -Dcom.sun.management.jmxremote.authenticate = false -Dcom.sun.management.jmxremote.ssl = false so您可以从远程计算机连接。一个很好的简单程序来监控启用jmx的java,它可以绘制移动图表的网页,并在阈值更改时通过电子邮件发送警报是链接文本。它还可以让您通过网页远程控制您的应用程序。好又简单。当然,如果你使用jmx,你可以很容易地交换使用更复杂的东西,如nagios或一些昂贵的商业工具。关于这些工具的关键点在于它们具有工作流和工作量以及管理想要照顾大量事物(数据库,服务器,Java等)的大团队的东西 - 如果你刚刚开始这可能太复杂了与获得jmx的Java端工作。

#5


-1  

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.

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

#1


12  

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

JMX可以是解决此问题的机制,但它不是完整的解决方案。

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.

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

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.

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

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

但是制作JMX警报是一回事,完全采取行动是另一回事。

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.

您需要做的是在某个地方安装一些JMX客户端,“订阅”您的程序的JMX通知,然后客户端可以通过发送电子邮件等处理这些通知。

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.

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

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.

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

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.

作为@fawce提到的,有各种复杂,可以在JMX数据采取行动,可能会做你想要的一些“通用” JMX客户端(我不熟悉,所以我不能说第一手),或者你可以编写您自己的系统来监控JMX数据。

#2


0  

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

如果你的意思是JMX,有一个名为monju的JBoss / Nagios网桥,它有一个通用的JMX钩子。

#3


0  

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

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

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

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

#4


0  

here is a good article with sample code for using jms in your app to raise alerts link text. once you have that working with local monitoring you need to set the -Dom.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. a nice simple program to monitor jmx enabled java which can plot webpages of moving graphs and email out alerts when thresholds change is link text. it will also let you remote control your apps via the webpages. nice and simple. of course if you are using jmx you can easily swap up to use something more complex such as nagios or some expensive commercial tool. the key points about those tools is that they have workflow and rotas and stuff to manage a big team of people wanting to look after lots of things (databases, servers, java, etc) - which may be too much complexity if you just starting out with getting the java side of jmx working.

这是一篇很好的文章,其中包含在您的应用中使用jms来提升警报链接文本的示例代码。一旦你使用本地监控,你需要设置-Dom.sun.management.jmxremote.port = 9999 -Dcom.sun.management.jmxremote.authenticate = false -Dcom.sun.management.jmxremote.ssl = false so您可以从远程计算机连接。一个很好的简单程序来监控启用jmx的java,它可以绘制移动图表的网页,并在阈值更改时通过电子邮件发送警报是链接文本。它还可以让您通过网页远程控制您的应用程序。好又简单。当然,如果你使用jmx,你可以很容易地交换使用更复杂的东西,如nagios或一些昂贵的商业工具。关于这些工具的关键点在于它们具有工作流和工作量以及管理想要照顾大量事物(数据库,服务器,Java等)的大团队的东西 - 如果你刚刚开始这可能太复杂了与获得jmx的Java端工作。

#5


-1  

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.

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