Getting Started with the Java Dynamic Management Kit 4.2

The SNMP Toolkit

The Java Dynamic Management Kit provides a toolkit for integrating SNMP management into a JMX-based architecture. This includes:

For more information regarding the SNMP toolkit, refer to the Java Dynamic Management Kit 4.2 Tools Reference guide and the Java Dynamic Management Kit 4.2 Tutorial.

Developing An SNMP Agent

An SNMP agent is an application which responds to SNMP requests formulated as get and set operations on variables defined in a MIB. This behavior can be fully mapped onto the MBean server and MBean resources of a Java Dynamic Management agent, provided those MBeans specifically implement the MIB.

The SNMP protocol adaptor implements the both the SNMP v1 and v2 protocols. It responds to request in SNMP and translates that request into management operations on the specific MIB MBeans. The SNMP adaptor may also send traps, the equivalent of a JMX notification, in response to SNMP events or errors.

The SNMP protocol adaptor is able to manage an unlimited number of different MIBs. These MIBs may be loaded or unloaded dynamically, by registering and unregistering the corresponding MBeans. The adaptor will attempt to respond to an SNMP request by accessing all loaded MIBs. However, MIBs are only dynamic through the agent application, the SNMP protocol does not support requests for loading or unloading MIBs.

One advantage of the dual JMX-SNMP agent is that MIBs may be loaded dynamically in response to network conditions, or even in response to SNMP requests. Other Java Dynamic Management applications may also access the MIB through its MBean interface. For example, the value of a MIB variable might be computed in another application and written by a call to the MBean setter.

The SNMP protocol adaptor also sends inform requests from an SNMP agent to an SNMP manager. The SNMP manager will then send an inform response back to the SNMP agent.

SNMP MIB Compiler - mibgen

The mibgen tool takes as input a set of SNMP MIBs and generates standard MBeans that you can customize. MIBs can be expressed using either SNMP v1 or SNMP v2 syntax.

A MIB is like a management interface: it defines what is exposed, but it doesn't define how to compute the exposed value. Therefore, MBeans generated by mibgen need to be customized to provide the definitive implementation. The MIB is implemented through Java objects, meaning it has access to all Java runtime libraries and all features of the dynamic agent where it will be instantiated.

The mibgen compiler parses an SNMP MIB and generates the following:

The resulting classes should be made accessible in the agent application. When the single MBean representing the whole MIB is registered in the MBean server, all the associated groups are automatically instantiated and registered as well.

The mibgen compiler supports all data structure of the v1 and v2 protocols, including:

The Java Dynamic Management Kit also provides an example program, showing how an agent may act as an SNMP proxy to access MIBs in subagents. This allows SNMP managers to access hierarchies of agents through a single proxy agent. In this way, some MIBs may be implemented by native devices and others may be implemented in JMX agents, yet this heterogeneous architecture is completely transparent to the manager issuing a request.

SNMP Manager API

The SNMP manager API simplifies the development of Java applications for managing SNMP agents. Its classes represent SNMP manager concepts such as sessions, parameters, and peers through Java objects. Using this API, you can develop an application which can issue requests to SNMP agents.

For example, you could instrument and SNMP resource using the SNMP manager API. You would define a management interface that corresponds to your resource's MIB: variables are easily mapped as MBean attributes. In response to calls on the attribute getters and setters, your MBean would construct and issue SNMP request to the SNMP agent which represents the resource.

The SNMP manager API supports requests in either the SNMP v1 or v2 protocol, including inform requests for communicating between SNMP managers. The manager API is used to access any compliant SNMP agent including those developed using the Java Dynamic Management Kit.