Java Dynamic Management Kit 3.2 Programming Guide
[ Previous ][ Fast Back ]Chapter 20. Developing SNMP Managers With the Java Dynamic Management Kit [ Next ]

SNMP Manager Overview

The Java Dynamic Management Kit SNMP manager API enables you to develop applications to manage SNMP agents. The SNMP manager API can be used synchronously for simple applications or asynchronously in more demanding situations. There are four main components of the SNMP manager API:

SNMP Peer

The SNMP manager uses instances of the SnmpPeer class to represent remote agents. Each remote agent is represented by a single SnmpPeer object. An SnmpPeer can be instantiated with the IP address, the hostname and port, or the hostname of the remote agent. The SnmpPeer object holds the following information:

SNMP Parameters

The SnmpParameter class contains information on the SNMP read and write communities, and the SNMP version. This information is used by an SnmpSession object while exchanging packets with an SnmpPeer. An SnmpPeer can be configured explicitly to use a specific SnmpParameter object. Multiple SnmpPeer objects can share a single parameter object. Changing values for an SnmpParameter object affects all SnmpPeer objects that use that object.

When you change these parameters, the changes are applied to all active messages. Example 20-1 shows the instantiation and configuration of an SnmpPeer object representing a remote agent using port 8085 on host summer.

Example 20-1. Instantiating and Configuring an SnmpPeer Object
String hostname = String ("summer");
int port = 8085;

// Create a SnmpPeer object for representing remote agent
SnmpPeer agent= new SnmpPeer(hostname, port);
    
// Create parameters to associate to the remote agent.
// When creating the parameter object, you can specify the read and write
// community to be used when querying the agent.
SnmpParameters params= new SnmpParameters("public", "private");

// The newly created parameter object must be associated with the agent.
agent.setSnmpParam(params);

SNMP Session

The SNMP manager session is controlled by an instance of the SnmpSession class. An SnmpSession object creates and manages SNMP requests to multiple peers. The SnmpSession object can be instantiated with a default peer so that all requests created without specifying a peer use the default. The default peer can be set while the SnmpSession object is running.

Each SNMP manager session uses a dispatcher to service all of the requests it creates. It uses an SNMP socket which, unless configured otherwise, uses the default socket specified by the SnmpSocket object. The SNMP manager session can also be configured to use a separate socket exclusively.

The SnmpSession class provides methods to create requests. Individual requests perform a specific SNMP operation. When used asynchronously, the session maintains the list of all active requests and responses. Requests are retried if the peer does not respond within a specified time. The maximum retry limit is specified by the SnmpPeer objects. You can cancel any active requests at any time during a session.

Example 20-2 shows the instantiation and configuration of an SnmpSession using the SnmpPeer instantiated in Example 20-1 as the default peer.

Example 20-2. Instantiating and Configuring an SnmpSession
// Build the session.
SnmpSession session= new SnmpSession("Manager session");
      
// Use "agent" as the default peer
session.setDefaultPeer(agent);

SNMP Session Options

SNMP sessions can be configured for specific situations using methods provided in the SnmpOptions object. Setting these options affects all subsequent requests. Existing requests are also affected, depending on the nature of the option. The SNMP session options are:

Variable Bindings

The SnmpVarbindList contains a list of SnmpVar objects. Each SnmpVar object holds information for a MIB variable and consists of:

SNMP Request

Instances of the SnmpRequest class enable you to send requests, handle retries, time-outs, and process responses from an agent. An SnmpRequest is created using a specific SnmpSession and SnmpPeer. The SnmpPeer object determines the destination of the request and controls the characteristics of the messaging between manager and agent.

The SnmpRequest object creates a request that is used to perform one or more of the following SNMP operations:

Request States

A request becomes active when a user submits the request successfully. When any event happens that changes the state of the request to done, the request becomes inactive. At any time, one or more requests active in a session can be cancelled.


[ Previous ][ Home ][ Next ]
Developing SNMP Managers With the Java Dynamic Management Kit[ Up ]Operation of the SNMP Manager