org.opennms.mock.snmp
Class MockSnmpAgent

java.lang.Object
  extended by org.snmp4j.agent.BaseAgent
      extended by org.opennms.mock.snmp.MockSnmpAgent
All Implemented Interfaces:
Runnable

public class MockSnmpAgent
extends org.snmp4j.agent.BaseAgent
implements Runnable

MockSnmpAgent class.

Version:
$Id: $
Author:
ranger

Field Summary
static boolean allowSetOnMissingOid
           
 
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
 
Constructor Summary
MockSnmpAgent(File confFile, org.springframework.core.io.Resource moFile)
           
MockSnmpAgent(File confFile, org.springframework.core.io.Resource moFile, String bindAddress)
          Constructor for MockSnmpAgent.
 
Method Summary
protected  void addCommunities(org.snmp4j.agent.mo.snmp.SnmpCommunityMIB communityMIB)
          
protected  void addNotificationTargets(org.snmp4j.agent.mo.snmp.SnmpTargetMIB targetMIB, org.snmp4j.agent.mo.snmp.SnmpNotificationMIB notificationMIB)
          
protected  void addUsmUser(org.snmp4j.security.USM usm)
          
protected  void addViews(org.snmp4j.agent.mo.snmp.VacmMIB vacm)
          
static MockSnmpAgent createAgentAndRun(org.springframework.core.io.Resource moFile, String bindAddress)
          createAgentAndRun
protected  List<org.snmp4j.agent.ManagedObject> createMockMOs()
          createMockMOs
protected  void initMessageDispatcher()
          
protected  void initTransportMappings()
          
 boolean isRunning()
          isRunning
 boolean isStopped()
          isStopped
static void main(String[] args)
          main
static AgentConfigData parseCli(String[] args)
          parseCli
protected  void registerManagedObjects()
          
protected  void registerSnmpMIBs()
          
 void run()
          run
 void shutDown()
          shutDown
 void shutDownAndWait()
          shutDownAndWait
 String toString()
          toString
protected  void unregisterManagedObjects()
          
protected  void unregisterSnmpMIBs()
          
 void updateCounter32Value(String oid, int val)
          updateCounter32Value
 void updateCounter64Value(String oid, long val)
          updateCounter64Value
 void updateIntValue(String oid, int val)
          updateIntValue
 void updateStringValue(String oid, String val)
          updateStringValue
 void updateValue(org.snmp4j.smi.OID oid, org.snmp4j.smi.Variable value)
          updateValue
 void updateValue(String oid, org.snmp4j.smi.Variable value)
          updateValue
 void updateValuesFromResource(org.springframework.core.io.Resource moFile)
          updateValuesFromResource
 
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, initSnmpSession, loadConfig, saveConfig, sendColdStartNotification, setAgent, setBootCounterFile, setConfigFile, setDefaultContext, setDefaultProxyForwarder, setEngineBoots, setSysDescr, setSysOID, setSysServices, setupDefaultProxyForwarder, stop, updateEngineBoots, updateSession
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

allowSetOnMissingOid

public static boolean allowSetOnMissingOid
Constructor Detail

MockSnmpAgent

public MockSnmpAgent(File confFile,
                     org.springframework.core.io.Resource moFile)

MockSnmpAgent

public MockSnmpAgent(File confFile,
                     org.springframework.core.io.Resource moFile,
                     String bindAddress)

Constructor for MockSnmpAgent.

Parameters:
bootFile - a File object.
confFile - a File object.
moFile - a Resource object.
bindAddress - a String object.
Throws:
IOException
Method Detail

createAgentAndRun

public static MockSnmpAgent createAgentAndRun(org.springframework.core.io.Resource moFile,
                                              String bindAddress)
                                       throws InterruptedException

createAgentAndRun

Parameters:
moFile - a Resource object.
bindAddress - a String object.
Returns:
a MockSnmpAgent object.
Throws:
InterruptedException - if any.

main

public static void main(String[] args)

main

Parameters:
args - an array of String objects.

parseCli

public static AgentConfigData parseCli(String[] args)

parseCli

Parameters:
args - an array of String objects.
Returns:
a AgentConfigData object.

initMessageDispatcher

protected void initMessageDispatcher()

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

shutDownAndWait

public void shutDownAndWait()
                     throws InterruptedException

shutDownAndWait

Throws:
InterruptedException - if any.

run

public void run()

run

Specified by:
run in interface Runnable
Overrides:
run in class org.snmp4j.agent.BaseAgent

shutDown

public void shutDown()

shutDown


isRunning

public boolean isRunning()

isRunning

Returns:
a boolean.

isStopped

public boolean isStopped()

isStopped

Returns:
a boolean.

addCommunities

protected void addCommunities(org.snmp4j.agent.mo.snmp.SnmpCommunityMIB communityMIB)

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

addViews

protected void addViews(org.snmp4j.agent.mo.snmp.VacmMIB vacm)

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

addNotificationTargets

protected void addNotificationTargets(org.snmp4j.agent.mo.snmp.SnmpTargetMIB targetMIB,
                                      org.snmp4j.agent.mo.snmp.SnmpNotificationMIB notificationMIB)

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

addUsmUser

protected void addUsmUser(org.snmp4j.security.USM usm)

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

initTransportMappings

protected void initTransportMappings()
                              throws IOException

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

registerSnmpMIBs

protected void registerSnmpMIBs()

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

unregisterSnmpMIBs

protected void unregisterSnmpMIBs()

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

registerManagedObjects

protected void registerManagedObjects()

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

unregisterManagedObjects

protected void unregisterManagedObjects()

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

createMockMOs

protected List<org.snmp4j.agent.ManagedObject> createMockMOs()

createMockMOs

Returns:
a List object.

updateValue

public void updateValue(org.snmp4j.smi.OID oid,
                        org.snmp4j.smi.Variable value)

updateValue

Parameters:
oid - a OID object.
value - a Variable object.

updateValue

public void updateValue(String oid,
                        org.snmp4j.smi.Variable value)

updateValue

Parameters:
oid - a String object.
value - a Variable object.

updateIntValue

public void updateIntValue(String oid,
                           int val)

updateIntValue

Parameters:
oid - a String object.
val - a int.

updateStringValue

public void updateStringValue(String oid,
                              String val)

updateStringValue

Parameters:
oid - a String object.
val - a String object.

updateCounter32Value

public void updateCounter32Value(String oid,
                                 int val)

updateCounter32Value

Parameters:
oid - a String object.
val - a int.

updateCounter64Value

public void updateCounter64Value(String oid,
                                 long val)

updateCounter64Value

Parameters:
oid - a String object.
val - a long.

updateValuesFromResource

public void updateValuesFromResource(org.springframework.core.io.Resource moFile)

updateValuesFromResource

Parameters:
moFile - a Resource object.

toString

public String toString()

toString

Overrides:
toString in class Object
Returns:
a String object.


Copyright © 2011. All Rights Reserved.