Using JMX classes to notify on events over time
I've been looking at JMX for monitoring application and system metrics (partially because MBeans can accessed by various too开发者_Go百科ls 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?
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.
精彩评论