JVM monitoring:jmx or SNMP? By Daniel on Feb 23, 2007
Since javaTM SE 5.0, the JRE provides a means to manage and monitor of the Java Virtual machine. It comes in Flavors:one are based on the Java Management Extension (JMXTM) and the other is a small SNMP agent T Hat builds upon the Management and monitoring API of the Java SE platform and exposes the same information through SNMP.
A legitimate question that often arises to newcomers to the JMX and SNMP technologies are:
which technology should I use to monitor my JVM? JMX, or SNMP?
In this blog I'll try to provide some guidance on this subject.
Monitoring the JVM through JMX
The JVM JMX Agent is composed of a jmx RMI Connector Server which exposes the content of a platform mbeanserver to remote Applications. When started, it registers all the platform Mxbeans that compose the JVM monitoring and Management APIs in the platform MBe AnServer, and expose them to remote JMX clients.
One such client is the popular JConsole graphical tool.
Follow this link to learn more about managing and monitoring the JVM through JMX.
Other links of interest can also being found in what is JMX? And looking for JMX overview, Examples, and more ....
Monitoring the JVM through SNMP
The JVM SNMP agent is a small snmpv2c agent which exposes a single MIB, the Jvm-management-mib. This agent isn't extensible, and can only expose what's defined in the that MIB.
Follow this link to learn how to start and configure the JVM SNMP agent.
In order to manage the JVM through SNMP, you'll need to use a SNMP management console, or an SMMP management API. The Java Dynamic Management Kit from Sun provides a SNMP Manager API in Java. There is also a lot of other free or commercial SNMP tools, shells, and command line software, such as e.g. Net-snmp.
A good place-to-start looking for them are here, or you could also Google it use your favorite internet search eng Ine.
Update: Dmitri Maximovitch has written a excellent article explaining how to use MRTG to monitor the JVM, Eitherthrough JMX or th Rough the JVM SNMP Agent.
So, which Management solution should I Choose?
Well, in what Java and the JVM are concerned, I would say it ' s far more interesting to invest in a solution based on JMX RA Ther than on a solution based in SNMP, for the following reasons:
The MIB that makes it possible to manage the JVM through SNMP is closed. The Jvm-management-mib only exposes the information defined to JSR 163-and none other. In particular, if you register your own MBeans in the platform Mbeanserver, they is not being exposed through that MIB. On the other hand, you'll be able to interact with them through a regular JMX connector, and JConsole would display them Nicely.
The JVM SNMP Agent is also closed. As I have already explained, it doesn ' t has a public API. If you wanted to expose your own information through SNMP, you would has to:
- Find A standard MIB this defines the information you want to expose, or write your own MIB
- Use a tool such as the Java Dynamic Management Kit to generate stubs for that MIB
- Provide the application logic to implement those stubs
- Start a new SNMP agent to expose your MIB.
All of the does require a certain amount of expertise in SNMP.
The power of expression of SNMP/SMI is limited. It is ideally suited to describe and monitor numeric gauges and counters (scalar or tabular), but describing complex data is much more awkward. Some things which could appear trivial in JMX, like for instance, returning a thread stack trace, can reach incredible Lev Els of complexity in SNMP. Describing complex configuration can also rapidly become nightmarish. The possibility of evolution for SNMP interfaces is thus limited:snmp are a very good protocol-but like any management t Echnologies, it has its strengths, weaknesses, and limitations.
Conclusion
All of the, I would say that choosing to monitor the JVM through SNMP are legitimate when:
- The JVMs want to manage is deployed in a secure network (intranet-like). The JVM SNMP agent is a SNMP v2c agent, and SNMP v2 has basically no security.
- You already has at your disposal SNMP management tools or SNMP management consoles
- You already has an SNMP background knowledge, so then you won't have a to learn everything on SNMP from scratch
- You is trying to correlate JVM monitoring data through non Java management applications which already has an SNMP stack
- You is only interested in JVM data-not application data, and does not see any plans for the change.
- What's defined in the JVM-MANAGEMENT-MIB suits your need and are enough for your purposes.
If that's the case, and you answered YES to all questions, then the JVM SNMP Agent were made for you!
Cheers, and stay tuned for more adventurous journeys in the Java, JMX, and SNMP world!
--Daniel
Category:sun
JVM monitoring:jmx or SNMP?