snmpAdaptor4j is an adaptor for Java Management eXtensions (JMX) providing a simple access to MBeans via the SNMP protocol. Thus, this adapter you allow to connect most monitoring tools (like Nagios and Cacti) to your Java applications.

For each MBean, an XML mapping file allows to establish the relationships between attributes and the MIB of the SNMP adapter. No additional code is necessary to integrate the MBeans in the SNMP protocol.

This adapter can work in a multi-applications environment (such as application servers).


Download here, the last version.

Unzip the downloaded file and retrieve the following files for put it in the classpath of your project:

  • /lib/snmpAdaptor4j-jmx-1.1.jar
  • /lib/joesnmp-0.3.4.jar
  • /lib/log4j-1.2.16.jar

Alternatively, if you use Maven, you can add the following dependency in the POM file of your project:


Building of the mapping files

For each MBean of your project, create the mapping file in the same package as the MBean. For example:

<?xml version="1.0" encoding="utf-8"?>

    <attribute name="attributA" type="integer32" node="1" writable="true"/>
    <attribute name="attributB" type="counter64" node="2" writable="false"/>
    <attribute name="attributC" type="gauge32" node="3" writable="false"/>


Here, we map only MBean attributes by indicating the SNMP data type and the node constituting the OID (Object IDentifier). The mapping of MBean instances, is generally put in the configuration file (see next chapter).

Building of the configuration file

Create the configuration file (one by application) like this:

<?xml version="1.0" encoding="utf-8"?>

  <daemon address="" port="161" version="2">

  <roots default=""/>

    <mbean name="fr.mydomain.myAppli:type=MyClass,name=objA" oid="1.1"/>
    <mbean name="fr.mydomain.myAppli:type=MyClass,name=objB" oid="1.2"/>


Here, we define the OID for each instance of MBeans. The OID of an attribute, is built as follows:

${root}.${mbean oid}.${attribute node}.0

For example, the attributB OID of first MBean will be

Registration and start of adaptor

Insert the following code to install the adapter inside JMX:

URL url = getClass().getResource("/snmp.xml");
SnmpAdaptor adaptor = new SnmpAdaptor(url, true);
ObjectName name = new ObjectName("net.sf.snmpadaptor4j:adaptor=SnmpAdaptor");
ManagementFactory.getPlatformMBeanServer().registerMBean(adaptor, name);

snmp.xml is the configuration file previously built.

Update the information about your system:

adaptor.getSystemInfo().setSysDescr("This is a java application");
adaptor.getSystemInfo().setSysLocation("Web server at Montpellier (France)");

Start the adaptor:


NOTE: The object returned by GetSystemInfo() is a MBean. It is possible to register it in JMX.


Install the Net-SNMP commands and type:

snmpwalk -v2c -Os -c public .1

You should see the attribute values of your MBean.


Contact the project manager | ©2012 by snmpAdaptor4j