JVM Monitoring: JMX or SNMP?
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 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.
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 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....
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 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.
So, Which Management Solution Should I Choose?
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:
- Find a standard MIB that 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 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.
Conclusion
All in all, I would say that choosing to monitor the JVM through SNMP is legitimate when:
- The JVMs you want to manage are deployed in a secure network (intranet-like). The JVM SNMP agent is an SNMP v2c agent, and SNMP v2 has basically no security.
- You already have at your disposal SNMP management tools or SNMP management consoles
- You already have an SNMP background knowledge, so that you will not have to learn everything about SNMP from scratch
- You are trying to correlate JVM Monitoring data through non Java management applications which already have an SNMP stack
- You are only interested in JVM data - not application data, and do not see any plans for this to change.
- What is defined in the JVM-MANAGEMENT-MIB suits your need and is enough for your purposes.
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
Category: Sun
Tags: j
JVM Monitoring: JMX or SNMP?的更多相关文章
- jvm添加jmx远程监控
调JVM监控的时候需要远程连接机器,所以服务器需要开放JMX协议,配置如下. 现在我的项目是jboot-jfinal项目,用的是undertow容器,在启动脚本里面加入 JAVA_OPTS=" ...
- Monitoring an IBM JVM with VisualVM
Monitoring an IBM JVM with VisualVM 分类: Java 2013-06-09 16:15 250人阅读 评论(0) 收藏 举报 JDK6 update 7 and o ...
- Java Management Extensions (JMX) Flume
Lesson: Overview of the JMX Technology (The Java™ Tutorials > Java Management Extensions (JMX)) h ...
- JMX简单入门
在一个系统中常常会有一些配置信息,比如服务的IP地址,端口号什么的,那么如何来来处理这些可配置项呢? 程序新手一般是写死在程序里,到要改变时就去改程序,然后再编译发布: 程序熟手则一般把这些信息写在一 ...
- JVM Management API
JVM本身提供了一组管理的API,通过该API,我们可以获取得到JVM内部主要运行信息,包括内存各代的数据.JVM当前所有线程及其栈相关信 息等等.各种JDK自带的剖析工具,包括jps.jstack. ...
- 深入理解JVM—性能监控工具
(转自:http://yhjhappy234.blog.163.com/blog/static/31632832201222691738865/) 我们知道,在JVM编译期和加载器,甚至运行期已经做了 ...
- 配置JVM内存 查看内存工具
一.配置JVM内存 1.配置JVM内存的參数有四个: -XmxJavaHeap最大值.默认值为物理内存的1/4.最佳设值应该视物理内存大小及计算机内其它内存开销而定. -XmsJavaHeap初始值, ...
- cacti监控jvm
jdk环境 java version "1.6.0_37" Java(TM) SE Runtime Environment (build 1.6.0_37-b06) Java Ho ...
- java heap space解决方法和JVM参数设置
在JVM中如果98%的时间是用于GC(Garbage Collection)且可用的 Heap size 不足2%的时候将抛出异常信息,java.lang.OutOfMemoryError: Java ...
随机推荐
- (SQL Analyzer services)定义链接维度
链接文档是在一个 Analysis Services 数据库中存在.但在相同版本和兼容级别的另一个 Analysis Services 数据库中重复使用的一种文档. 链接文档是只读的. 如果您想要修改 ...
- JDK版本过高,导致Eclipse报错
1.JDK版本如果比较高,而使用的eclipse版本比较低,导致在eclispe中不能识别而报错. 2.点击Attach Source添加rt.jar后,又出现如下错误 3.这样的错误就是由于ec ...
- 添加samba用户,并设置密码
5.3.3 添加samba用户,并设置密码; 我们用的方法是先添加用户,但添加的这些用户都是虚拟用户,因为这些用户是不能通过SHELL登录系统的;另外值得注意的是系统用户密码和Samba用户的密码是不 ...
- 关于Debug下的Log打印问题
在项目中为了调试经常会用到Log打印,比如打印当前方法__func__, 对象,地址等等,所以项目最后每次运行调试控制台满满的都是打印日志,到release发布的时候,显然不太合适,这里其实可以用一个 ...
- iOS 指纹解锁
目前常用的App支持指纹解锁的还不是很多,如果在你的项目中用一下是不是显得高大上呢? 废话不说多,干货- 1.在工程中添加LocalAuthentication.framework 2.在需要验证的c ...
- requirejs实践二 加载其它JavaScript与运行
上一篇中介绍了requirejs加载JavaScript文件,在这一篇中介绍加载JavaScript后执行代码 这次是test2.html文件, <!DOCTYPE html> <h ...
- mysql数据库导出时报错mysqldump: Got error: 145的解决方法
在给mysql数据库备份时,报错:mysqldump: Got error: 145: Table './jxzhtopenfire/ofoffline' is marked as crashed ...
- 每天一条linux命令——shutdown
shutdown命令用来系统关机命令.shutdown指令可以关闭所有程序,并依用户的需要,进行重新开机或关机的动作. 语法: shutdown(选项)(参数) 选项: -c:当执行“shutdown ...
- top工具
top 显示进程所占系统资源 能够实时显示系统中各个进程的资源占用状况,类似于Windows的任务管理器. top命令打印出了很多信息,包括系统负载(loadaverage).进程数(Tasks).c ...
- jQuery选择器(适合初学者哟....)
选择器是jQuery最基础的东西,本文中列举的选择器基本上囊括了所有的jQuery选择器,也许各位通过这篇文章能够加深对jQuery选择器的理解,它们本身用法就非常简单,我更希望的是它能够提升个人编写 ...