Java Reference
In-Depth Information
In the previous two chapters, we covered two important agent services: the rela-
tion service and the M-let service. This chapter continues coverage of agent ser-
vices by examining the remaining two services: monitoring services and the
timer service. Monitoring services are a valuable resource when you want to be
informed of a state or behavioral change in a managed resource. The standard
JMX
monitors can observe MBean attributes and emit notifications when neces-
sary to inform other objects or processes of a change.
JMX
-compliant agents pro-
vide three types of monitors, built as MBeans, which can monitor
String
and
numeric MBean attributes.
In addition to the monitoring services, compliant agents provide a timer ser-
vice. The
JMX
timer service allows users to send user-defined notifications at a
given time, or at given intervals.
A robust management environment needs to be able to monitor itself and
communicate with interested observers about its health, behavior, and important
statistics. Using these last two agent services will increase the usefulness of your
JMX
environments. This chapter discusses all three
JMX
monitoring MBeans
and the timer service. We'll examine their classes and purpose, and present some
examples. Up first are the monitoring services.
12.1 Monitoring MBean attributes with JMX
JMX
-compliant agents provide a set of Standard MBeans that together are con-
sidered the
JMX
monitoring services. Because these monitors are implemented
as MBeans, users can instantiate and change them at runtime as needed. The
monitored targets of these monitoring MBeans are other MBean attributes.
Monitoring MBeans watch MBean attributes for predefined events and send
notifications based on their own configuration. You can use these monitors to
keep informed about state changes, workflow completions, or error messages.
For example, you can monitor something as critical as an MBean managing a
real-time application's state, or as simple as a log file being rolled over.
JMX
mon-
itors watch MBean attributes (the
observed value
) at user-configurable intervals
(the
granularity period
). Each monitor creates a value called a
derived gauge
based
on its observations of the observed MBean attribute, which it uses to determine
whether to send and what type of notifications to send to its listeners.
Table 12.1 describes the three monitor types along with their main classes.
You can see from the monitor classnames that we will be examining classes in a
new package,
javax.management.monitor
. Based on the remaining information in
table 12.1, you probably have more questions. However, before we move on to