Counter Monitors
As mentioned in the first part of this chapter, a counter monitor is used to observe an MBean attribute that is:
Greater than or equal to zero
Continually increasing (i.e., never decreasing)
One of the Java integer types (
byte,short,int, orlong) or one of the corresponding JDK wrapper classes (Byte,Short,Int, orLong)
In this section, we will look at the agent code that shows how to use
a counter monitor. When using a counter monitor, the first thing to
do is to create a new instance of the
CounterMonitor class:
CounterMonitor monitor = new CounterMonitor( );
After that, the following attributes of the monitor must be set:
ObservedObjectObservedAttributeNotify(must be set totrueif a notification is to be sent)ThresholdGranularityPeriodOffset(optional)DifferenceMode(optional)Modulus(optional)
We discussed some of these attributes earlier in this chapter. If the
Offset attribute is set, each time the derived
gauge exceeds the threshold value, the current value of the MBean
attribute is incremented by the value of Offset
until the MBean attribute value is greater than the derived gauge (to
prevent multiple notifications should the derived gauge spike well
beyond the current MBean attribute value). When the counter monitor
determines that a notification should be sent to all interested
listeners, a single notification is sent, regardless of how many
multiples of the threshold value the derived gauge is calculated to
be.
In other words, if the previous ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access