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:

      1. Find a standard MIB that defines the information you want to expose, or write your own MIB
      2. Use a tool such as the Java Dynamic Management Kit to generate stubs for that MIB
      3. Provide the application logic to implement those stubs
      4. 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:

  1. 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.
  2. You already have at your disposal SNMP management tools or SNMP management consoles
  3. You already have an SNMP background knowledge, so that you will not have to learn everything about SNMP from scratch
  4. You are trying to correlate JVM Monitoring data through non Java management applications which already have an SNMP stack
  5. You are only interested in JVM data - not application data, and do not see any plans for this to change.
  6. 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?的更多相关文章

  1. jvm添加jmx远程监控

    调JVM监控的时候需要远程连接机器,所以服务器需要开放JMX协议,配置如下. 现在我的项目是jboot-jfinal项目,用的是undertow容器,在启动脚本里面加入 JAVA_OPTS=" ...

  2. 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 ...

  3. Java Management Extensions (JMX) Flume

    Lesson: Overview of the JMX Technology (The Java™ Tutorials > Java Management Extensions (JMX)) h ...

  4. JMX简单入门

    在一个系统中常常会有一些配置信息,比如服务的IP地址,端口号什么的,那么如何来来处理这些可配置项呢? 程序新手一般是写死在程序里,到要改变时就去改程序,然后再编译发布: 程序熟手则一般把这些信息写在一 ...

  5. JVM Management API

    JVM本身提供了一组管理的API,通过该API,我们可以获取得到JVM内部主要运行信息,包括内存各代的数据.JVM当前所有线程及其栈相关信 息等等.各种JDK自带的剖析工具,包括jps.jstack. ...

  6. 深入理解JVM—性能监控工具

    (转自:http://yhjhappy234.blog.163.com/blog/static/31632832201222691738865/) 我们知道,在JVM编译期和加载器,甚至运行期已经做了 ...

  7. 配置JVM内存 查看内存工具

    一.配置JVM内存 1.配置JVM内存的參数有四个: -XmxJavaHeap最大值.默认值为物理内存的1/4.最佳设值应该视物理内存大小及计算机内其它内存开销而定. -XmsJavaHeap初始值, ...

  8. cacti监控jvm

    jdk环境 java version "1.6.0_37" Java(TM) SE Runtime Environment (build 1.6.0_37-b06) Java Ho ...

  9. java heap space解决方法和JVM参数设置

    在JVM中如果98%的时间是用于GC(Garbage Collection)且可用的 Heap size 不足2%的时候将抛出异常信息,java.lang.OutOfMemoryError: Java ...

随机推荐

  1. 基于mod_proxy+Apache 2.2.16+Tomcat 7的负载均衡与集群配置

    第一章. 背景简介 对于大多数企业应用,都希望能做到7*24小时不间断运行.要保持如此高的可用性并非易事,比较常见的做法是将系统部署到多台机器上,每台机器都对外提供同样的功能,这就是集群.系统变为集群 ...

  2. 使用AFNetworking进行图片上传

    转载自:http://blog.csdn.net/a645258072/article/details/51728806 项目中,我们经常会用到上传图片的功能,而目前的上传图片分为两种(我只知道两种, ...

  3. 网卡添加VLAN TAG

    #modprobe 8021q 用命令 lsmod | grep 8021q 来检查 以配置网卡eth0为例,添加vlan号:1002 ================================ ...

  4. bzoj1008: [HNOI2008]越狱

    思路:首先所有情况就是m^n,然后不可能发生越狱的情况就是第一个有m种选择,第二个要与第一个不同就是m-1种选择,第三个要与第二个不同也是m-1种选择,然后不可能发生越狱的情况数就是m*(m-1)^( ...

  5. Mac OS 安装 Port

    简介 MacPorts类似与apt-get以及yum等软件包管理工具,可以方便的进行安装与卸载软件的功能,同时可以自动安装软件包的依赖,非常方便,同类的还有brew等工具. 安装 下载MacPorts ...

  6. js禁止高频率连续点击思路

    1.类似react的数据流,点击之后立即设置值为空,当返回值后才可以点击 2.设置定时器,每次进入之前先清空掉定时器,然后开启定时器 <main> <div id="me& ...

  7. linux 下C语言编程库文件处理与Makefile编写

    做开发快3年了,在linux下编译安装软件算是家常便饭了.就拿gcc来说,都有不下10次了,可基本每次都会碰到些奇奇怪怪的问题.看来还是像vs.codeblocks这样的ide把人弄蠢了.便下定决心一 ...

  8. XML3_XML元素和节点的具体解释

    就像一个树状的目录.可以把第一行当作它扎根的“土地”.XML文件是由节点构成的.它的第一个节点为“根节点”.一个XML文件必须有且只能有一 个根节点,其他节点都必须是它的子节点.我们在FLASH里使用 ...

  9. Linux调整SWAP分区

    刪除原swap分區,重建swap,步驟如下:1,swapoff -a #停止交換分區2,fdisk /dev/sda #進入fdisk,刪除原swap分區,重新建立新分區(swap分區的系統ID是82 ...

  10. WF工作流与管理类应用系统工作流需求实现的一些误区

             如今实现各种应用系统大家都知道工作流是一个非常重要的环节,不同的业务系统的工作流需求是需要找相应的工作流产品去实现的,因为不同工作流产品的架构细节也许会成为某类需求实现的瓶颈. WF ...