java.lang.Object
org.snmp4j.agent.AgentConfigManager
- All Implemented Interfaces:
Runnable
,VariableProvider
The
AgentConfigManager
is the main component of a SNMP4J-Agent.
It puts together agent configuration and agent components like command
processor, message dispatcher, managed objects and server, and standard MIB modules like
USM, VACM, etc.- Since:
- 1.2
- Version:
- 3.0
- Author:
- Frank Fock
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
TheAgentConfigManager.AgentState
provides information about the state of this SNMP agent.static class
-
Field Summary
Modifier and TypeFieldDescriptionprotected CommandProcessor
protected List
<AgentStateListener<AgentConfigManager>> protected SnmpCommunityMIB
protected MOInputFactory
protected org.snmp4j.mp.CounterSupport
protected org.snmp4j.smi.OctetString
protected Collection
<DHKickstartParameters> protected org.snmp4j.MessageDispatcher
protected org.snmp4j.cfg.EngineBootsProvider
protected org.snmp4j.smi.OctetString
protected SnmpFrameworkMIB
protected MOFactory
protected org.snmp4j.smi.UnsignedInteger32
protected org.snmp4j.smi.UnsignedInteger32
protected org.snmp4j.smi.UnsignedInteger32
protected NotificationLogMib
protected SnmpNotificationMIB
protected NotificationOriginator
protected int
protected MOPersistenceProvider
protected ProxyForwarder
protected SnmpProxyMIB
protected AgentState
protected org.snmp4j.security.SecurityModels
protected org.snmp4j.security.SecurityProtocols
protected MOServer[]
protected org.snmp4j.Session
protected Snmp4jConfigMib
protected Snmp4jLogMib
protected Snmp4jProxyMib
protected SnmpMpdMib
protected SnmpUsmDhObjectsMib
protected SNMPv2MIB
protected org.snmp4j.smi.OctetString
protected org.snmp4j.smi.OID
protected org.snmp4j.smi.Integer32
protected MOTableSizeLimit
<MOTableRow> protected SnmpTargetMIB
protected SnmpTlsTmMib
protected org.snmp4j.security.USM
protected UsmMIB
protected VACM
protected VacmMIB
protected org.snmp4j.util.WorkerPool
-
Constructor Summary
ConstructorDescriptionAgentConfigManager
(org.snmp4j.smi.OctetString agentsOwnEngineID, org.snmp4j.MessageDispatcher messageDispatcher, VACM vacm, MOServer[] moServers, org.snmp4j.util.WorkerPool workerPool, MOInputFactory configurationFactory, MOPersistenceProvider persistenceProvider, org.snmp4j.cfg.EngineBootsProvider engineBootsProvider) Creates a SNMP agent configuration which can be run by callingrun()
later.AgentConfigManager
(org.snmp4j.smi.OctetString agentsOwnEngineID, org.snmp4j.MessageDispatcher messageDispatcher, VACM vacm, MOServer[] moServers, org.snmp4j.util.WorkerPool workerPool, MOInputFactory configurationFactory, MOPersistenceProvider persistenceProvider, org.snmp4j.cfg.EngineBootsProvider engineBootsProvider, MOFactory moFactory) Creates a SNMP agent configuration which can be run by callingrun()
later.AgentConfigManager
(org.snmp4j.smi.OctetString agentsOwnEngineID, org.snmp4j.MessageDispatcher messageDispatcher, VACM vacm, MOServer[] moServers, org.snmp4j.util.WorkerPool workerPool, MOInputFactory configurationFactory, MOPersistenceProvider persistenceProvider, org.snmp4j.cfg.EngineBootsProvider engineBootsProvider, MOFactory moFactory, Collection<DHKickstartParameters> diffieHellmanKickstartParameters) Creates a SNMP agent configuration which can be run by callingrun()
later. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAgentStateListener
(AgentStateListener<AgentConfigManager> agentStateListener) void
Configures components and managed objects using thegetConfigurationFactory()
.boolean
Continues processing of SNMP requests by coupling message dispatcher and agent.protected CommandProcessor
createCommandProcessor
(org.snmp4j.smi.OctetString engineID) Creates the command processor.protected org.snmp4j.mp.CounterSupport
protected NotificationOriginator
protected ProxyForwarder
Creates and registers the default proxy forwarder application (ProxyForwarderImpl
).protected org.snmp4j.Session
createSnmpSession
(org.snmp4j.MessageDispatcher dispatcher) Creates the SNMP session to be used for this agent.protected org.snmp4j.security.TSM
Creates the TSM used by this agent configuration.protected org.snmp4j.security.USM
Creates the USM used by this agent configuration.protected void
protected void
Fire notifications after agent start, i.e.Returns the notification originator of the agent.Gets the factory that generates aMOInput
instance to load initial or reset configuration into the agent.protected org.snmp4j.smi.OctetString
getContext
(MOGroup mibGroup, org.snmp4j.smi.OctetString defaultContext) This method can be overwritten by a subagent to specify the contexts each MIB module (group) will be registered to.org.snmp4j.mp.CounterSupport
org.snmp4j.smi.OctetString
Returns the default context - which is the context that is used by the base agent to register its MIB objects.protected Collection
<DHKickstartParameters> Overwrite this method to provide Diffie Hellman kick start parameters.Returns the NOTIFICATION-LOG-MIB implementation used by this config manager.Returns the notification originator of this agent configuration.int
Returns the currently active import mode for theMOPersistenceProvider
.Gets the persistence provider which stores and restores non-volatile (i.e., persistent) MIB data.org.snmp4j.security.SecurityModels
org.snmp4j.security.SecurityProtocols
Returns the SNMP4J-CONFIG-MIB implementation used by this config manager.Returns the SNMP4J-LOG-MIB implementation used by this config manager.Returns the SNMP4J-CONFIG-MIB implementation used by this config manager.Returns the SNMP-COMMUNITY-MIB implementation used by this config manager.Returns the SNMPv2-MPD-MIB implementation used by this config manager.Returns the SNMP-NOTIFICATION-MIB implementation used by this config manager.Returns the SNMP-TARGET-MIB implementation used by this config manager.Returns the SNMPv2-MIB implementation used by this config manager.int
getState()
Returns the state of the agent.protected org.snmp4j.security.SecurityProtocols
Gets the set of security protocols supported by this agent configuration (only called ifinitialize()
ifsetContext(SecurityModels, SecurityProtocols, CounterSupport)
did not set a non-nullSecurityProtocols
instance before.org.snmp4j.smi.OctetString
Returns the sysDescr.0 value for this agent which can be modified by altering its value.org.snmp4j.smi.OID
Gets the system OID which can be modified by altering its value.org.snmp4j.smi.Integer32
Gets the system services ID which can be modified by altering its value.Gets the sysUpTime.0 instance for the default context.org.snmp4j.security.USM
getUsm()
getVACM()
Returns the VACM used by this agent config manager.org.snmp4j.smi.Variable
getVariable
(String name) Gets the variable with the specified name, which might be either a textual name or an instance OID.void
Initialize the agent by creating counter support, SNMP session, engine ID, command processor, worker pool, security models (initSecurityModels(EngineBootsProvider)
), message dispatcher with message processing models (initMessageDispatcherWithMPs(MessageDispatcher)
, mandatory MIBs (initMandatoryMIBs()
), link MIBs with each other, link counter listeners (linkCounterListener()
), and initialize optional MIBs (initOptionalMIBs()
.protected void
protected void
initMessageDispatcherWithMPs
(org.snmp4j.MessageDispatcher mp) protected void
initNotificationLogMIB
(VACM vacm, SnmpNotificationMIB notifyMIB) protected void
protected void
protected void
initSecurityModels
(org.snmp4j.cfg.EngineBootsProvider engineBootsProvider) void
initSnmp4jConfigMIB
(MOPersistenceProvider[] persistenceProvider) void
void
initSnmp4jProxyMIB
(org.snmp4j.smi.OctetString context) protected void
protected void
launch()
Launch the agent by registering and lauching (i.e., set to listen mode) transport mappings.protected void
protected static void
launchTransportMappings
(Collection<? extends org.snmp4j.TransportMapping<?>> transportMappings) Puts a list of transport mappings into listen mode.protected void
protected void
registerMIBs
(org.snmp4j.smi.OctetString context) Register the initialized MIB modules in the specified context of the agent.void
Registers a shutdown hookThread
at theRuntime
instance.protected void
boolean
removeAgentStateListener
(AgentStateListener<AgentConfigManager> agentStateListener) boolean
Restore a previously persistently saved state - if available.void
run()
Initializes, configures, restores agent state, and then launches the SNMP agent depending on its current run state.boolean
Save the state of the agent persistently - if necessary persistent storage is available.void
setConfigurationFactory
(MOInputFactory configuration) Sets the configuration factory that generates aMOInput
instance to load initial or reset configuration into the agent.void
setContext
(org.snmp4j.security.SecurityModels securityModels, org.snmp4j.security.SecurityProtocols securityProtocols, org.snmp4j.mp.CounterSupport counterSupport) Sets context objects needed for common security services that are derived from static instances by default.void
setCounterSupport
(org.snmp4j.mp.CounterSupport counterSupport) void
setNotificationOriginator
(NotificationOriginator notificationOriginator) Sets the notification originator of this agent configuration.void
setPersistenceImportMode
(int importMode) Sets the import mode for theMOPersistenceProvider
.void
setPersistenceProvider
(MOPersistenceProvider persistenceProvider) Sets the persistence provider which stores and restores non-volatile (i.e., persistent) MIB data.void
setTableSizeLimit
(int sizeLimit) Sets the table size limit for the tables in this agent.void
setTableSizeLimits
(Properties sizeLimits) Sets the table size limits for the tables in this agent.void
void
setupSnmpUsmDhObjectsMib
(Collection<DHKickstartParameters> dhKickstartParameters) void
shutdown()
Shutdown the agent by closing the internal SNMP session - including the transport mappings provided through the configuredMessageDispatcher
and then store the agent state to persistent storage (if available).protected static void
stopTransportMappings
(Collection<? extends org.snmp4j.TransportMapping<?>> transportMappings) Closes a list of transport mappings.void
Suspends processing of SNMP requests.protected void
unregisterMIBs
(org.snmp4j.smi.OctetString context) Unregister the initialized MIB modules from the default context of the agent.protected void
Wait until all pending modifications (external via SNMP request or internal by LockRequest) to any of the servers are done.
-
Field Details
-
agent
-
workerPool
protected org.snmp4j.util.WorkerPool workerPool -
vacm
-
usm
protected org.snmp4j.security.USM usm -
servers
-
session
protected org.snmp4j.Session session -
dispatcher
protected org.snmp4j.MessageDispatcher dispatcher -
engineID
protected org.snmp4j.smi.OctetString engineID -
proxyForwarder
-
notificationOriginator
-
configuration
-
persistenceProvider
-
persistenceImportMode
protected int persistenceImportMode -
engineBootsProvider
protected org.snmp4j.cfg.EngineBootsProvider engineBootsProvider -
counterSupport
protected org.snmp4j.mp.CounterSupport counterSupport -
securityProtocols
protected org.snmp4j.security.SecurityProtocols securityProtocols -
securityModels
protected org.snmp4j.security.SecurityModels securityModels -
snmpv2MIB
-
snmpMpdMib
-
targetMIB
-
communityMIB
-
notificationMIB
-
frameworkMIB
-
usmMIB
-
vacmMIB
-
tlsTmMib
-
proxyMIB
-
snmpUsmDhObjectsMib
-
snmp4jLogMIB
-
snmp4jConfigMIB
-
snmp4jProxyMIB
-
notificationLogMIB
-
notificationLogDefaultLimit
protected org.snmp4j.smi.UnsignedInteger32 notificationLogDefaultLimit -
notificaitonLogGlobalLimit
protected org.snmp4j.smi.UnsignedInteger32 notificaitonLogGlobalLimit -
notificaitonLogGlobalAge
protected org.snmp4j.smi.UnsignedInteger32 notificaitonLogGlobalAge -
moFactory
-
sysDescr
protected org.snmp4j.smi.OctetString sysDescr -
sysOID
protected org.snmp4j.smi.OID sysOID -
sysServices
protected org.snmp4j.smi.Integer32 sysServices -
defaultContext
protected org.snmp4j.smi.OctetString defaultContext -
runState
-
tableSizeLimit
-
diffieHellmanKickstartParameters
-
agentStateListeners
-
-
Constructor Details
-
AgentConfigManager
public AgentConfigManager(org.snmp4j.smi.OctetString agentsOwnEngineID, org.snmp4j.MessageDispatcher messageDispatcher, VACM vacm, MOServer[] moServers, org.snmp4j.util.WorkerPool workerPool, MOInputFactory configurationFactory, MOPersistenceProvider persistenceProvider, org.snmp4j.cfg.EngineBootsProvider engineBootsProvider) Creates a SNMP agent configuration which can be run by callingrun()
later.- Parameters:
agentsOwnEngineID
- the authoritative engine ID of the agent.messageDispatcher
- the MessageDispatcher to use. The message dispatcher must be configured outside, i.e. transport mappings have to be added before this constructor is being called.vacm
- a view access control model. Typically, this parameter is set tonull
to use the default VACM associated with theVacmMIB
.moServers
- the managed object server(s) that serve the managed objects available to this agent.workerPool
- theWorkerPool
to be used to process incoming request.configurationFactory
- aMOInputFactory
that creates aMOInput
stream with containing serialized ManagedObject information with the agent's configuration ornull
otherwise.persistenceProvider
- the primaryMOPersistenceProvider
to be used to load and store persistent MOs.engineBootsProvider
- the provider of engine boots counter.
-
AgentConfigManager
public AgentConfigManager(org.snmp4j.smi.OctetString agentsOwnEngineID, org.snmp4j.MessageDispatcher messageDispatcher, VACM vacm, MOServer[] moServers, org.snmp4j.util.WorkerPool workerPool, MOInputFactory configurationFactory, MOPersistenceProvider persistenceProvider, org.snmp4j.cfg.EngineBootsProvider engineBootsProvider, MOFactory moFactory) Creates a SNMP agent configuration which can be run by callingrun()
later.- Parameters:
agentsOwnEngineID
- the authoritative engine ID of the agent.messageDispatcher
- the MessageDispatcher to use. The message dispatcher must be configured outside, i.e. transport mappings have to be added before this constructor is being called.vacm
- a view access control model. Typically, this parameter is set tonull
to use the default VACM associated with theVacmMIB
.moServers
- the managed object server(s) that serve the managed objects available to this agent.workerPool
- theWorkerPool
to be used to process incoming request.configurationFactory
- aMOInputFactory
that creates aMOInput
stream with containing serialized ManagedObject information with the agent's configuration ornull
otherwise.persistenceProvider
- the primaryMOPersistenceProvider
to be used to load and store persistent MOs.engineBootsProvider
- the provider of engine boots counter.moFactory
- theMOFactory
to be used to createManagedObject
s created by this config manager. Ifnull
theDefaultMOFactory
will be used.- Since:
- 1.4
-
AgentConfigManager
public AgentConfigManager(org.snmp4j.smi.OctetString agentsOwnEngineID, org.snmp4j.MessageDispatcher messageDispatcher, VACM vacm, MOServer[] moServers, org.snmp4j.util.WorkerPool workerPool, MOInputFactory configurationFactory, MOPersistenceProvider persistenceProvider, org.snmp4j.cfg.EngineBootsProvider engineBootsProvider, MOFactory moFactory, Collection<DHKickstartParameters> diffieHellmanKickstartParameters) Creates a SNMP agent configuration which can be run by callingrun()
later.- Parameters:
agentsOwnEngineID
- the authoritative engine ID of the agent.messageDispatcher
- the MessageDispatcher to use. The message dispatcher must be configured outside, i.e. transport mappings have to be added before this constructor is being called.vacm
- a view access control model. Typically, this parameter is set tonull
to use the default VACM associated with theVacmMIB
.moServers
- the managed object server(s) that serve the managed objects available to this agent.workerPool
- theWorkerPool
to be used to process incoming request.configurationFactory
- aMOInputFactory
that creates aMOInput
stream with containing serialized ManagedObject information with the agent's configuration ornull
otherwise.persistenceProvider
- the primaryMOPersistenceProvider
to be used to load and store persistent MOs.engineBootsProvider
- the provider of engine boots counter.moFactory
- theMOFactory
to be used to createManagedObject
s created by this config manager. Ifnull
theDefaultMOFactory
will be used.diffieHellmanKickstartParameters
- an optional list of Diffie Hellman kickstart parameters to initialize the USM authentication and privacy keys.- Since:
- 3.0
-
-
Method Details
-
setContext
public void setContext(org.snmp4j.security.SecurityModels securityModels, org.snmp4j.security.SecurityProtocols securityProtocols, org.snmp4j.mp.CounterSupport counterSupport) Sets context objects needed for common security services that are derived from static instances by default. By setting this to a different set of instances of these objects for each agent, several agents controlled by differentAgentConfigManager
instances can coexist within the same Java process. Thus, using this method is required before callingrun()
for concurrent execution ofrun()
, i.e. in a multi-threaded multi-agent architecture.- Parameters:
securityModels
- the security models supported by this agent.securityProtocols
- the security protocols supported by this agent.counterSupport
- theCounterSupport
instance that records and returns all event counters of this agent.- Since:
- 3.5.0
-
run
public void run()Initializes, configures, restores agent state, and then launches the SNMP agent depending on its current run state. For example, ifinitialize()
has not yet been called it will be called before the agent is being configured in the next step.See also
initialize()
,configure()
,restoreState()
, andlaunch()
. -
addAgentStateListener
-
removeAgentStateListener
-
fireAgentStateChange
protected void fireAgentStateChange() -
getState
public int getState()Returns the state of the agent.- Returns:
- a integer constant from
AgentState.STATE_CREATED
thruAgentState.STATE_RUNNING
.
-
getVACM
Returns the VACM used by this agent config manager.- Returns:
- the VACM instance of this agent.
- Since:
- 1.4
-
getSNMPv2MIB
Returns the SNMPv2-MIB implementation used by this config manager.- Returns:
- the SNMPv2MIB instance of this agent.
- Since:
- 1.4
-
getSnmpMpdMib
Returns the SNMPv2-MPD-MIB implementation used by this config manager.- Returns:
- the SnmpMpdMib instance of this agent.
- Since:
- 2.6
-
getSnmpTargetMIB
Returns the SNMP-TARGET-MIB implementation used by this config manager.- Returns:
- the SnmpTargetMIB instance of this agent.
- Since:
- 1.4
-
getSnmpNotificationMIB
Returns the SNMP-NOTIFICATION-MIB implementation used by this config manager.- Returns:
- the SnmpNotificationMIB instance of this agent.
- Since:
- 1.4
-
getSnmpCommunityMIB
Returns the SNMP-COMMUNITY-MIB implementation used by this config manager.- Returns:
- the SnmpCommunityMIB instance of this agent.
- Since:
- 1.4
-
getNotificationLogMIB
Returns the NOTIFICATION-LOG-MIB implementation used by this config manager.- Returns:
- the NotificationLogMib instance of this agent.
- Since:
- 1.4.2
-
getSnmp4jLogMIB
Returns the SNMP4J-LOG-MIB implementation used by this config manager.- Returns:
- the Snmp4jLogMib instance of this agent.
- Since:
- 1.4.2
-
getSnmp4jConfigMIB
Returns the SNMP4J-CONFIG-MIB implementation used by this config manager.- Returns:
- the Snmp4jConfigMib instance of this agent.
- Since:
- 1.4.2
-
getSnmp4jProxyMIB
Returns the SNMP4J-CONFIG-MIB implementation used by this config manager.- Returns:
- the Snmp4jConfigMib instance of this agent.
- Since:
- 2.0
-
launch
protected void launch()Launch the agent by registering and lauching (i.e., set to listen mode) transport mappings. -
fireLaunchNotifications
protected void fireLaunchNotifications()Fire notifications after agent start, i.e. sending a coldStart trap. -
continueProcessing
public boolean continueProcessing()Continues processing of SNMP requests by coupling message dispatcher and agent. To succeed, the current state of the agent must beAgentState.STATE_SUSPENDED
.- Returns:
true
if the running state could be restored,false
otherwise.
-
suspendProcessing
public void suspendProcessing()Suspends processing of SNMP requests. This call decouples message dispatcher and agent. All transport mappings remain unchanged and thus all ports remain opened. -
shutdown
public void shutdown()Shutdown the agent by closing the internal SNMP session - including the transport mappings provided through the configuredMessageDispatcher
and then store the agent state to persistent storage (if available). -
waitUntilPendingModificationsDone
protected void waitUntilPendingModificationsDone()Wait until all pending modifications (external via SNMP request or internal by LockRequest) to any of the servers are done.- Since:
- 3.7.0
-
registerShutdownHook
public void registerShutdownHook()Registers a shutdown hookThread
at theRuntime
instance. -
initSnmp4jLogMIB
public void initSnmp4jLogMIB() -
initSnmp4jConfigMIB
-
initSnmp4jProxyMIB
public void initSnmp4jProxyMIB(org.snmp4j.smi.OctetString context) -
getCommandProcessor
-
getVacmMIB
-
getUsm
public org.snmp4j.security.USM getUsm() -
getUsmMIB
-
getSecurityProtocols
public org.snmp4j.security.SecurityProtocols getSecurityProtocols() -
getSecurityModels
public org.snmp4j.security.SecurityModels getSecurityModels() -
initNotificationLogMIB
-
initSecurityContext
protected void initSecurityContext() -
initSecurityModels
protected void initSecurityModels(org.snmp4j.cfg.EngineBootsProvider engineBootsProvider) -
initMessageDispatcherWithMPs
protected void initMessageDispatcherWithMPs(org.snmp4j.MessageDispatcher mp) -
registerTransportMappings
protected void registerTransportMappings() -
launchTransportMappings
- Throws:
IOException
-
launchTransportMappings
protected static void launchTransportMappings(Collection<? extends org.snmp4j.TransportMapping<?>> transportMappings) throws IOException Puts a list of transport mappings into listen mode.- Parameters:
transportMappings
- a list ofTransportMapping
instances.- Throws:
IOException
- if a transport cannot listen to incoming messages.
-
stopTransportMappings
protected static void stopTransportMappings(Collection<? extends org.snmp4j.TransportMapping<?>> transportMappings) throws IOException Closes a list of transport mappings.- Parameters:
transportMappings
- a list ofTransportMapping
instances.- Throws:
IOException
- if a transport cannot be closed.
-
saveState
public boolean saveState()Save the state of the agent persistently - if necessary persistent storage is available.- Returns:
true
if state has been saved successfully,false
is returned if an error occurred or nopersistenceProvider
is set. The error details can be found in therunState
object.
-
restoreState
public boolean restoreState()Restore a previously persistently saved state - if available.- Returns:
true
if the agent state could be restored successfully,false
otherwise.
-
configure
public void configure()Configures components and managed objects using thegetConfigurationFactory()
. If the factory isnull
then nothing will be done. In any case, the agent state is advanced toAgentState.STATE_CONFIGURED
if no error occurred. -
initMandatoryMIBs
protected void initMandatoryMIBs() -
linkCounterListener
protected void linkCounterListener() -
getSupportedSecurityProtocols
protected org.snmp4j.security.SecurityProtocols getSupportedSecurityProtocols()Gets the set of security protocols supported by this agent configuration (only called ifinitialize()
ifsetContext(SecurityModels, SecurityProtocols, CounterSupport)
did not set a non-nullSecurityProtocols
instance before.- Returns:
SecurityProtocols.getInstance()
by default after initialization bySecurityProtocols.addDefaultProtocols()
.
-
createUSM
protected org.snmp4j.security.USM createUSM()Creates the USM used by this agent configuration.- Returns:
- an USM initialized by the engine boots from the
engineBootsProvider
andengineID
.
-
createTSM
protected org.snmp4j.security.TSM createTSM()Creates the TSM used by this agent configuration.- Returns:
- an USM initialized by the engine boots from the
engineBootsProvider
andengineID
.
-
getSysServices
public org.snmp4j.smi.Integer32 getSysServices()Gets the system services ID which can be modified by altering its value.- Returns:
- 72 by default.
-
getSysOID
public org.snmp4j.smi.OID getSysOID()Gets the system OID which can be modified by altering its value.- Returns:
- an OID - by default the SNMP4J root OID is returned.
-
getSysDescr
public org.snmp4j.smi.OctetString getSysDescr()Returns the sysDescr.0 value for this agent which can be modified by altering its value.- Returns:
- an OctetString describing the node of the form SNMP4J-Agent version [SNMP4J-version] - <os.name> - <os.arch> - <os.version>.
-
getSysUpTime
Gets the sysUpTime.0 instance for the default context.- Returns:
- a
SysUpTime
instance.
-
getNotificationOriginator
Returns the notification originator of this agent configuration. To get the (multi-threaded)NotificationOriginator
of the agent, usegetAgentNotificationOriginator()
instead.- Returns:
- a
NotificationOriginator
instance.
-
getAgentNotificationOriginator
Returns the notification originator of the agent. Use this method to get aNotificationOriginator
for sending your notifications.- Returns:
- the
NotificationOriginator
instance. - Since:
- 1.4
-
setNotificationOriginator
Sets the notification originator of this agent configuration.- Parameters:
notificationOriginator
- aNotificationOriginator
instance.
-
getCounterSupport
public org.snmp4j.mp.CounterSupport getCounterSupport() -
setCounterSupport
public void setCounterSupport(org.snmp4j.mp.CounterSupport counterSupport) -
getConfigurationFactory
Gets the factory that generates aMOInput
instance to load initial or reset configuration into the agent.- Returns:
- a configuration provider factory or
null
if no configuration is set. - Since:
- 3.5.5
-
setConfigurationFactory
Sets the configuration factory that generates aMOInput
instance to load initial or reset configuration into the agent. Configuration is a read-only source for MIB data whereas agetPersistenceProvider()
provides the mechanism to store and restore MIB data persistently.- Parameters:
configuration
- a configuration provider factory.- Since:
- 3.5.5
-
getPersistenceProvider
Gets the persistence provider which stores and restores non-volatile (i.e., persistent) MIB data.- Returns:
- a
MOPersistenceProvider
instance. - Since:
- 3.5.5
-
setPersistenceProvider
Sets the persistence provider which stores and restores non-volatile (i.e., persistent) MIB data.- Parameters:
persistenceProvider
- aMOPersistenceProvider
instance.- Since:
- 3.5.5
-
initialize
public void initialize()Initialize the agent by creating counter support, SNMP session, engine ID, command processor, worker pool, security models (initSecurityModels(EngineBootsProvider)
), message dispatcher with message processing models (initMessageDispatcherWithMPs(MessageDispatcher)
, mandatory MIBs (initMandatoryMIBs()
), link MIBs with each other, link counter listeners (linkCounterListener()
), and initialize optional MIBs (initOptionalMIBs()
. Advance state toAgentState.STATE_INITIALIZED
. -
createCounterSupport
protected org.snmp4j.mp.CounterSupport createCounterSupport() -
setTableSizeLimits
Sets the table size limits for the tables in this agent. If this method is called while the agent's registration is being changed, aConcurrentModificationException
might be thrown.- Parameters:
sizeLimits
- a set of properties as defined byMOTableSizeLimit
.- Since:
- 1.4
-
setTableSizeLimit
public void setTableSizeLimit(int sizeLimit) Sets the table size limit for the tables in this agent. If this method is called while the agent's registration is being changed, aConcurrentModificationException
might be thrown.- Parameters:
sizeLimit
- the maximum size (numer of rows) of tables allowed for this agent.- Since:
- 1.4
-
initOptionalMIBs
protected void initOptionalMIBs() -
initSnmpUsmDhObjectsMib
protected void initSnmpUsmDhObjectsMib() -
getDhKickstartParameters
Overwrite this method to provide Diffie Hellman kick start parameters.- Returns:
- an empty list of
DHKickstartParameters
by default. - Since:
- 3.0
-
getDefaultContext
public org.snmp4j.smi.OctetString getDefaultContext()Returns the default context - which is the context that is used by the base agent to register its MIB objects. By default it isnull
which causes the objects to be registered virtually for all contexts. In that case, subagents for example my not register their own objects under the same subtree(s) in any context. To allow subagents to register their own instances of those MIB modules, an emptyOctetString
should be used as default context instead.- Returns:
null
or anOctetString
(normally the empty string) denoting the context used for registering default MIBs.
-
getContext
protected org.snmp4j.smi.OctetString getContext(MOGroup mibGroup, org.snmp4j.smi.OctetString defaultContext) This method can be overwritten by a subagent to specify the contexts each MIB module (group) will be registered to.- Parameters:
mibGroup
- a group ofManagedObject
s (i.e., a MIB module).defaultContext
- the context to be used by default (i.e., thenull
context)- Returns:
- the context for which the module should be registered.
-
registerMIBs
protected void registerMIBs(org.snmp4j.smi.OctetString context) throws DuplicateRegistrationException Register the initialized MIB modules in the specified context of the agent.- Parameters:
context
- the context to register the internal MIB modules. This should benull
by default.- Throws:
DuplicateRegistrationException
- if some of the MIB modules registration regions conflict with already registered regions.
-
unregisterMIBs
protected void unregisterMIBs(org.snmp4j.smi.OctetString context) Unregister the initialized MIB modules from the default context of the agent.- Parameters:
context
- the context where the MIB modules have been previously registered.
-
setupProxyForwarder
public void setupProxyForwarder() -
setupSnmpUsmDhObjectsMib
-
createNotificationOriginator
-
createProxyForwarder
Creates and registers the default proxy forwarder application (ProxyForwarderImpl
).- Parameters:
agent
- the command processor that uses the proxy forwarder.- Returns:
- a ProxyForwarder instance.
-
createCommandProcessor
Creates the command processor.- Parameters:
engineID
- the engine ID of the agent.- Returns:
- a new CommandProcessor instance.
-
createSnmpSession
protected org.snmp4j.Session createSnmpSession(org.snmp4j.MessageDispatcher dispatcher) Creates the SNMP session to be used for this agent.- Parameters:
dispatcher
- the message dispatcher to be associated with the session.- Returns:
- a SNMP session (a
Snmp
instance by default).
-
setPersistenceImportMode
public void setPersistenceImportMode(int importMode) Sets the import mode for theMOPersistenceProvider
.- Parameters:
importMode
- one of the import modes defined byImportMode
.- Since:
- 1.4
-
getPersistenceImportMode
public int getPersistenceImportMode()Returns the currently active import mode for theMOPersistenceProvider
.- Returns:
- one of the import modes defined by
ImportMode
. - Since:
- 1.4
-
getVariable
Description copied from interface:VariableProvider
Gets the variable with the specified name, which might be either a textual name or an instance OID.- Specified by:
getVariable
in interfaceVariableProvider
- Parameters:
name
- the name or OID of the variable to return.- Returns:
- a Variable instance or
null
if such a variable with the specified name or OID does not exists.
-