标签:
Since JavaTM SE 5.0, the JRE provides a means to manage and monitor the Java Virtual Machine. It comes in two flavors: one is based on the Java Management Extension (JMXTM), the other is a small SNMP agent that 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 is:
Which technology should I use to monitor my JVM? JMX, or SNMP?
In this blog I will try to provide some guidance on this subject.
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 API in the platform MBeanServer, 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 be found in What is JMX? and Looking for JMX Overview, Examples, and More....
The JVM SNMP Agent is a small SNMPv2c agent which exposes a single MIB, the JVM-MANAGEMENT-MIB. This agent is not extensible, and can only expose what is defined in 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 will need to use an SNMP management console, or an SMMP management API. The Java Dynamic Management Kit from Sun provides an SNMP Manager API in Java. There are 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 is here, or you could also google it use your favorite internet search engine.
Update:Dmitri Maximovitch has written an excellent article explaining how to use MRTG to monitor the JVM, eitherthrough JMX or through the JVM SNMP Agent.
Well, in what Java and the JVM is concerned, I would say it‘s far more interesting to invest in a solution based on JMX rather than on a solution based on 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 by JSR 163 - and none other. In particular, if you register your own MBeans in the platform MBeanServer, they will not be exposed through that MIB. On the other hand, you will be able to interact with them through a regular JMX connector, and JConsole will display them nicely.
The JVM SNMP Agent is also closed. As I have already explained, it doesn‘t have a public API. If you wanted to expose your own information through SNMP you would have to:
All of this 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 levels of complexity in SNMP. Describing complex configuration can also rapidly become nightmarish. The possibility of evolution for SNMP interfaces is thus limited: SNMP is a very good protocol - but like any management technologies, it has its strengths, weaknesses, and limitations.
All in all, I would say that choosing to monitor the JVM through SNMP is legitimate when:
If that is the case, and you answered YES to all questions, then the JVM SNMP Agent was made for you!
Cheers, and stay tuned for more adventurous journeys in the Java, JMX, and SNMP world!
-- daniel
标签:
原文地址:http://www.cnblogs.com/destim/p/5719679.html