使用 JMX 类来通知一段时间内的事件

发布于 2024-09-06 18:03:59 字数 379 浏览 5 评论 0原文

我一直在研究 JMX 来监视应用程序和系统指标(部分原因是 MBean 可以通过 JConsole 等各种工具访问)。 JMX 中包含的类似乎对于诸如指标超过阈值时的通知之类的事情很有用。但我不确定它们是否符合我想要在指定时间段内测量这些的方式。

例如,假设我想在平均 CPU 负载超过 95% 且持续时间超过 5 分钟时通知管理员。这可以用 GaugeMonitor 来完成吗?从文档来看,它似乎不太适合这个,我想知道是否应该使用必要的逻辑编写自己的 MBean。

一个更相关的示例是当用户在 5 分钟内登录时间超过 10 秒时。略有不同的是,最近 20 次登录平均需要 10 秒以上。另一种情况是进程在一小时内崩溃 4 次以上。或者请求队列超过15个持续5分钟。 JMX Monitor 类对这种事情有用吗?

I've been looking at JMX for monitoring application and system metrics (partially because MBeans can accessed by various tools such as JConsole). It would seem like the classes included with JMX would be useful for things like notification when metrics have exceeded thresholds. But I'm not sure they fit with the way I want to measure these over a specified time period.

For example, let's say I want to notify an admin when the average CPU load is over 95% for more than 5 minutes. Is that something can be done with a GaugeMonitor? From the docs, it doesn't seem quite suited for this, and I'm wondering if instead I should write my own MBean with the necessary logic.

A more relevant example is when the login times for users exceed 10s over a period of 5 mins. Slightly different would be the last 20 logins took more than 10s on average. Another case would be when a process crashes 4+ times in an hour. Or the request queue exceeds 15 for 5 mins. Are the JMX Monitor classes useful for this kind of thing?

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

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

发布评论

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

评论(1

好听的两个字的网名 2024-09-13 18:03:59

在我看来,监视器 mbean 类并不是特别有用,虽然您可能能够对它们进行足够的调整来满足您的需求,但听起来您有一些不同的需求。我建议您看一下 Esper 之类的流事件引擎。基本上,您将定期读取数据注入引擎,如果发生您定义的条件,您将获得一个回调,该回调可以轻松转换为 JMX 通知。

Esper 引擎非常高效,完全在调用者线程中运行(没有额外的线程),并且仅保留满足您注册要通知的条件所需的注入数据。

In my opinion, the monitor mbean classes are not particularly useful and while you might be able to tweak them enough to serve your needs, it sounds like you have some diverse requirements. I recommend you take a look at something like Esper, a streaming event engine. Basically, you will inject regular readings into the engine and if a condition that you define occurs, you will get a callback which can easily be converted to a JMX Notification.

The Esper engine is quite efficient, runs entirely in caller threads (no extra threads) and only retains the injected data it needs to satisfy the conditions you register to be notified of.

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