org.ow2.jasmine.interfaces.snmp
Class SNMPAgent

java.lang.Object
  extended by org.snmp4j.agent.BaseAgent
      extended by org.ow2.jasmine.interfaces.snmp.SNMPAgent
All Implemented Interfaces:
Runnable

public class SNMPAgent
extends org.snmp4j.agent.BaseAgent

JASMINe SNMP agent class.

This class provides basic SNMP features and allows to register MIB objects in order to supply information through SNMP protocol.
All external interfaces dedicated to SNMP must use this class as a base for all its communications.

This class must only be manipulated via its unique instance.

Author:
Laurent RUAUD

Field Summary
 
Fields inherited from class org.snmp4j.agent.BaseAgent
agent, agentState, bootCounterFile, configFileURI, defaultContext, defaultPersistenceProvider, defaultProxyForwarder, dispatcher, mpv3, notificationOriginator, server, session, snmp4jConfigMIB, snmp4jLogMIB, snmpCommunityMIB, snmpFrameworkMIB, snmpNotificationMIB, snmpProxyMIB, snmpTargetMIB, snmpv2MIB, STATE_CREATED, STATE_INIT_FINISHED, STATE_INIT_STARTED, STATE_RUNNING, STATE_STOPPED, sysDescr, sysOID, sysServices, transportMappings, usm, usmMIB, vacmMIB
 
Method Summary
protected  void addCommunities(org.snmp4j.agent.mo.snmp.SnmpCommunityMIB communityMIB)
          Adds community to security name mappings needed for SNMPv1 and SNMPv2c.
protected  void addNotificationTargets(org.snmp4j.agent.mo.snmp.SnmpTargetMIB targetMIB, org.snmp4j.agent.mo.snmp.SnmpNotificationMIB notificationMIB)
          Adds initial notification targets and filters.
 void addTrapDestination(String trapDestination)
          Adds a new destination for SNMP traps.
Destinations must be formatted as followed: ipaddress/port (127.0.0.1/162).
protected  void addUsmUser(org.snmp4j.security.USM usm)
          Adds all the necessary initial users to the USM.
protected  void addViews(org.snmp4j.agent.mo.snmp.VacmMIB vacm)
          Adds initial VACM configuration.
static SNMPAgent getInstance()
          Gets the only instance available.
protected  void initTransportMappings()
          Initializes the transport mappings (ports) to be used by the agent.
 void notify(org.snmp4j.smi.OctetString context, org.snmp4j.smi.OID notificationID, org.snmp4j.smi.VariableBinding[] vbs)
          Sends a notification through SNMP.
protected  void registerManagedObjects()
          Register additional managed objects at the agent's server.
 void registerMIB(org.snmp4j.agent.MOGroup mib)
          Registers an MIB based on the specified manager.
 void setRequestSource(String source)
          Defines the source to listen to GET and SET request.
Source must be formatted as followed: ipaddress/port (127.0.0.1/161).
 void start()
          Starts the agent.
 void stop()
          Stops the agent.
protected  void unregisterManagedObjects()
          Unregister additional managed objects from the agent's server.
 void unregisterMIB(org.snmp4j.agent.MOGroup mib)
          Registers an MIB based on the specified manager.
 
Methods inherited from class org.snmp4j.agent.BaseAgent
addShutdownHook, finishInit, getAgent, getAgentState, getBootCounterFile, getConfigFile, getContext, getDefaultContext, getDefaultProxyForwarder, getEngineBoots, getMPv3, getNotificationOriginator, getServer, getSession, getSnmp4jConfigMIB, getSnmp4jLogMIB, getSnmpCommunityMIB, getSnmpFrameworkMIB, getSnmpNotificationMIB, getSnmpProxyMIB, getSnmpTargetMIB, getSnmpv2MIB, getSysDescr, getSysOID, getSysServices, getUsm, getUsmMIB, getVacmMIB, init, initConfigMIB, initMessageDispatcher, initSnmpSession, loadConfig, registerSnmpMIBs, run, saveConfig, sendColdStartNotification, setAgent, setBootCounterFile, setConfigFile, setDefaultContext, setDefaultProxyForwarder, setEngineBoots, setSysDescr, setSysOID, setSysServices, setupDefaultProxyForwarder, unregisterSnmpMIBs, updateEngineBoots, updateSession
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static SNMPAgent getInstance()
Gets the only instance available.

Returns:
the unique instance.

start

public void start()
Starts the agent. This registers trap destinations and starts listening on request source.


stop

public void stop()
Stops the agent. This unregisters trap destinations and stops listening on request source. This also unregisters all managed objects and MIBs.

Overrides:
stop in class org.snmp4j.agent.BaseAgent

setRequestSource

public void setRequestSource(String source)
Defines the source to listen to GET and SET request.
Source must be formatted as followed: ipaddress/port (127.0.0.1/161).

Parameters:
requestSource - source to listen to GET and SET request

addTrapDestination

public void addTrapDestination(String trapDestination)
Adds a new destination for SNMP traps.
Destinations must be formatted as followed: ipaddress/port (127.0.0.1/162).

Parameters:
requestSource - the destination to add.

notify

public void notify(org.snmp4j.smi.OctetString context,
                   org.snmp4j.smi.OID notificationID,
                   org.snmp4j.smi.VariableBinding[] vbs)
Sends a notification through SNMP.

Parameters:
context - the context name of the context on whose behalf this notification has been generated.
notificationID - the object ID that uniquely identifies this notification.
vbs - an array of VariableBinding instances representing the payload of the notification.

registerMIB

public void registerMIB(org.snmp4j.agent.MOGroup mib)
Registers an MIB based on the specified manager.

Parameters:
manager - the manager the MIB will be based on.

unregisterMIB

public void unregisterMIB(org.snmp4j.agent.MOGroup mib)
Registers an MIB based on the specified manager.

Parameters:
manager - the manager the MIB will be based on.

registerManagedObjects

protected void registerManagedObjects()
Register additional managed objects at the agent's server.

Specified by:
registerManagedObjects in class org.snmp4j.agent.BaseAgent

unregisterManagedObjects

protected void unregisterManagedObjects()
Unregister additional managed objects from the agent's server.

Specified by:
unregisterManagedObjects in class org.snmp4j.agent.BaseAgent

addCommunities

protected void addCommunities(org.snmp4j.agent.mo.snmp.SnmpCommunityMIB communityMIB)
Adds community to security name mappings needed for SNMPv1 and SNMPv2c.

Specified by:
addCommunities in class org.snmp4j.agent.BaseAgent
Parameters:
communityMIB - the SnmpCommunityMIB holding coexistence configuration for community based security models.

addNotificationTargets

protected void addNotificationTargets(org.snmp4j.agent.mo.snmp.SnmpTargetMIB targetMIB,
                                      org.snmp4j.agent.mo.snmp.SnmpNotificationMIB notificationMIB)
Adds initial notification targets and filters.

Specified by:
addNotificationTargets in class org.snmp4j.agent.BaseAgent
Parameters:
targetMIB - the SnmpTargetMIB holding the target configuration.
notificationMIB - the SnmpNotificationMIB holding the notification (filter) configuration.

addUsmUser

protected void addUsmUser(org.snmp4j.security.USM usm)
Adds all the necessary initial users to the USM.

Specified by:
addUsmUser in class org.snmp4j.agent.BaseAgent
Parameters:
usm - the USM instance used by this agent.

addViews

protected void addViews(org.snmp4j.agent.mo.snmp.VacmMIB vacm)
Adds initial VACM configuration.

Specified by:
addViews in class org.snmp4j.agent.BaseAgent
Parameters:
vacmMIB - the VacmMIB holding the agent's view configuration.

initTransportMappings

protected void initTransportMappings()
                              throws IOException
Initializes the transport mappings (ports) to be used by the agent.

Overrides:
initTransportMappings in class org.snmp4j.agent.BaseAgent
Throws:
IOException


Copyright © 2013 OW2 Consortium. All Rights Reserved.