Class AgentConfigManager
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
Nested ClassesModifier and TypeClassDescriptionclassTheAgentConfigManager.AgentStateprovides information about the state of this SNMP agent.static classTheErrorDescriptordescribes an error that occurred while this agent tried to advance from one run state to another, for example while launching its transport mappings. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CommandProcessorTheCommandProcessorthat processes the incoming SNMP requests of this agent.protected List<AgentStateListener<AgentConfigManager>> The listeners that are informed about run state changes of this agent.protected AgentAuditPolicyA protected, transient, and volatile variable representing the audit policy associated with an agent.protected SnmpCommunityMIBThe SNMP-COMMUNITY-MIB implementation of this agent.protected MOInputFactoryThe factory that provides theMOInputwith the initial configuration of this agent ornullif no initial configuration is available.protected org.snmp4j.mp.CounterSupportThe counter support that records and provides the event counters of this agent.protected org.snmp4j.smi.OctetStringThe default context of this agent, which is the empty context by default.protected Collection<DHKickstartParameters> The Diffie-Hellman kickstart parameters of this agent ornullif there are none.protected org.snmp4j.MessageDispatcherThe message dispatcher that dispatches incoming and outgoing SNMP messages.protected org.snmp4j.cfg.EngineBootsProviderThe provider of the engine boots counter of this agent.protected org.snmp4j.smi.OctetStringThe authoritative engine ID of this agent.protected SnmpFrameworkMIBThe SNMP-FRAMEWORK-MIB implementation of this agent.protected MOFactoryThe factory used to create the managed objects of the MIB modules of this agent.protected org.snmp4j.smi.UnsignedInteger32The maximum age of a logged notification in minutes where zero means no age limit.protected org.snmp4j.smi.UnsignedInteger32The maximum number of notifications held by all notification logs together.protected org.snmp4j.smi.UnsignedInteger32The maximum number of notifications held by the default notification log.protected NotificationLogMibThe NOTIFICATION-LOG-MIB implementation of this agent ornullif not supported.protected SnmpNotificationMIBThe SNMP-NOTIFICATION-MIB implementation of this agent.protected NotificationOriginatorThe notification originator that sends the notifications (traps and informs) of this agent.protected intTheImportModeused when the persistent configuration is restored.protected MOPersistenceProviderThe primary persistence provider used to load and store the persistent managed objects of this agent.protected ProxyForwarderThe proxy forwarder application of this agent ornullif proxy forwarding is not supported by this agent.protected SnmpProxyMIBThe SNMP-PROXY-MIB implementation of this agent ornullif not supported.protected AgentStateThe current run state of this agent.protected org.snmp4j.security.SecurityModelsThe security models supported by this agent.protected org.snmp4j.security.SecurityProtocolsThe security protocols (authentication and privacy protocols) supported by this agent.protected MOServer[]The managed object servers that provide the managed objects of this agent.protected org.snmp4j.SessionThe SNMP session used to send notifications and to forward proxied requests.protected Snmp4jConfigMibThe SNMP4J-CONFIG-MIB implementation of this agent ornullif not supported.protected Snmp4jLogMibThe SNMP4J-LOG-MIB implementation of this agent ornullif not supported.protected Snmp4jProxyMibThe SNMP4J-PROXY-MIB implementation of this agent ornullif not supported.protected SnmpMpdMibThe SNMP-MPD-MIB implementation of this agent.protected SnmpUsmDhObjectsMibThe SNMP-USM-DH-OBJECTS-MIB implementation of this agent ornullif Diffie-Hellman key exchange is not supported.protected SNMPv2MIBThe SNMPv2-MIB implementation of this agent.protected org.snmp4j.smi.OctetStringThe value of thesysDescrobject of this agent.protected org.snmp4j.smi.OIDThe value of thesysObjectIDobject of this agent.protected org.snmp4j.smi.Integer32The value of thesysServicesobject of this agent.protected MOTableSizeLimit<MOTableRow> The table size limit applied to the tables of this agent ornullif the table sizes are not limited.protected SnmpTargetMIBThe SNMP-TARGET-MIB implementation of this agent.protected SnmpTlsTmMibThe SNMP-TLS-TM-MIB implementation of this agent.protected org.snmp4j.security.USMThe User Based Security Model (USM) of this agent.protected UsmMIBThe SNMP-USER-BASED-SM-MIB implementation of this agent.protected VACMThe view access control model of this agent ornullif thevacmMIBis used as access control model.protected VacmMIBThe SNMP-VIEW-BASED-ACM-MIB implementation of this agent.protected org.snmp4j.util.WorkerPoolTheWorkerPoolthat provides the threads used to process incoming requests. -
Constructor Summary
ConstructorsConstructorDescriptionAgentConfigManager(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 an 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 an 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 an 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, AgentAuditPolicy auditPolicy) Creates an SNMP agent configuration which can be run by callingrun()later. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAgentStateListener(AgentStateListener<AgentConfigManager> agentStateListener) Adds a listener that is informed whenever the run state of this agent changes.voidConfigures components and managed objects using thegetConfigurationFactory().booleanContinues processing of SNMP requests by coupling message dispatcher and agent.protected CommandProcessorcreateCommandProcessor(org.snmp4j.smi.OctetString engineID) Creates the command processor.protected org.snmp4j.mp.CounterSupportCreates the counter support of this agent.protected NotificationOriginatorCreates the notification originator of this agent.protected ProxyForwarderCreates and registers the default proxy forwarder application (ProxyForwarderImpl).protected org.snmp4j.SessioncreateSnmpSession(org.snmp4j.MessageDispatcher dispatcher) Creates the SNMP session to be used for this agent.protected org.snmp4j.security.TSMCreates the TSM used by this agent configuration.protected org.snmp4j.security.USMDeprecated.protected org.snmp4j.security.USMcreateUSM(org.snmp4j.cfg.EngineBootsProvider engineBootsProvider, org.snmp4j.smi.OctetString engineID) Creates the USM used by this agent configuration.protected voidInforms all registeredAgentStateListeners about the current run state of this agent.protected voidFire notifications after agent start, i.e., sending a coldStart trap.Returns the notification originator of the agent.Gets the audit policy that is applied by this agent.Gets the command processor that processes the SNMP requests of this agent.Gets the factory that generates aMOInputinstance to load initial or reset configuration into the agent.protected org.snmp4j.smi.OctetStringgetContext(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.CounterSupportGets the counter support that records the event counters of this agent.org.snmp4j.smi.OctetStringReturns 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.org.snmp4j.MessageDispatcherRetrieves the current instance of the MessageDispatcher.Returns the NOTIFICATION-LOG-MIB implementation used by this config manager.Returns the notification originator of this agent configuration.intReturns 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.SecurityModelsGets the security models supported by this agent.org.snmp4j.security.SecurityProtocolsGets the security protocols supported by this agent.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.intgetState()Returns the state of the agent.protected org.snmp4j.security.SecurityProtocolsGets the set of security protocols supported by this agent configuration (only called ifinitialize()ifsetContext(SecurityModels, SecurityProtocols, CounterSupport)did not set a non-nullSecurityProtocolsinstance before.org.snmp4j.smi.OctetStringReturns the sysDescr.0 value for this agent which can be modified by altering its value.org.snmp4j.smi.OIDGets the system OID which can be modified by altering its value.org.snmp4j.smi.Integer32Gets the system services ID which can be modified by altering its value.Gets the sysUpTime.0 instance for the default context.org.snmp4j.security.USMgetUsm()Gets the User Based Security Model (USM) of this agent.Gets the SNMP-USER-BASED-SM-MIB implementation of this agent.getVACM()Returns the VACM used by this agent config manager.Gets the SNMP-VIEW-BASED-ACM-MIB implementation of this agent.org.snmp4j.smi.VariablegetVariable(String name) Gets the variable with the specified name, which might be either a textual name or an instance OID.voidInitialize 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 voidCreates the instances of the mandatory MIB modules of this agent (SNMPv2-MIB, SNMP-MPD-MIB, SNMP-TARGET-MIB, SNMP-NOTIFICATION-MIB, SNMP-VIEW-BASED-ACM-MIB, SNMP-USER-BASED-SM-MIB, SNMP-COMMUNITY-MIB, and SNMP-TLS-TM-MIB).protected voidinitMessageDispatcherWithMPs(org.snmp4j.MessageDispatcher mp) Adds the message processing models for SNMPv1, SNMPv2c, and SNMPv3 to the supplied message dispatcher.protected voidinitNotificationLogMIB(VACM vacm, SnmpNotificationMIB notifyMIB) Creates the NOTIFICATION-LOG-MIB instance of this agent, creates its default log, and registers the log as notification log listener at theNotificationOriginatorof this agent.protected voidCreates the instances of the optional MIB modules of this agent (SNMP4J-LOG-MIB, SNMP4J-CONFIG-MIB, NOTIFICATION-LOG-MIB, SNMP4J-PROXY-MIB, and SNMP-USM-DH-OBJECTS-MIB).protected voidInitializes the security models and security protocols of this agent with the static default instances, if they have not been set before bysetContext(SecurityModels, SecurityProtocols, CounterSupport).protected voidinitSecurityModels(org.snmp4j.cfg.EngineBootsProvider engineBootsProvider) Creates the USM and the TSM security models of this agent, adds them to the supportedSecurityModels, and creates the SNMP-FRAMEWORK-MIB instance of this agent.voidinitSnmp4jConfigMIB(MOPersistenceProvider[] persistenceProvider) Creates the SNMP4J-CONFIG-MIB instance of this agent and associates it with the persistence providers that can be selected through that MIB module.voidCreates the SNMP4J-LOG-MIB instance of this agent.voidinitSnmp4jProxyMIB(org.snmp4j.smi.OctetString context) Creates the SNMP4J-PROXY-MIB instance of this agent for the specified context.protected voidCreates the SNMP-USM-DH-OBJECTS-MIB instance of this agent using the Diffie-Hellman kickstart parameters returned bygetDhKickstartParameters().protected voidlaunch()Launch the agent by registering and launching (i.e., set to listen mode) transport mappings.protected voidPuts all transport mappings of theMessageDispatcherof this agent into listen mode.protected voidlaunchTransportMappings(Collection<? extends org.snmp4j.TransportMapping<?>> transportMappings) Puts a list of transport mappings into listen mode.protected voidRegisters the MIB modules of this agent that provide counter objects as counter listeners at the command processor, the message dispatcher, the USM, the message processing models, and the TLS transport mappings of this agent.protected voidregisterMIBs(org.snmp4j.smi.OctetString context) Register the initialized MIB modules in the specified context of the agent.voidRegisters a shutdown hookThreadat theRuntimeinstance.protected voidRegisters theMessageDispatcherof this agent as transport listener at all transport mappings of that dispatcher and sets the TLS security callback for TLS/DTLS transports.booleanremoveAgentStateListener(AgentStateListener<AgentConfigManager> agentStateListener) Removes a previously added agent state listener.booleanRestore a previously persistently saved state - if available.voidrun()Initializes, configures, restores agent state, and then launches the SNMP agent depending on its current run state.booleanSave the state of the agent persistently - if necessary persistent storage is available.voidsetAuditPolicy(AgentAuditPolicy auditPolicy) Sets the audit policy to be applied by this agent.voidsetConfigurationFactory(MOInputFactory configuration) Sets the configuration factory that generates aMOInputinstance to load initial or reset configuration into the agent.voidsetContext(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.voidsetCounterSupport(org.snmp4j.mp.CounterSupport counterSupport) Sets the counter support that records the event counters of this agent.voidsetNotificationOriginator(NotificationOriginator notificationOriginator) Sets the notification originator of this agent configuration.voidsetPersistenceImportMode(int importMode) Sets the import mode for theMOPersistenceProvider.voidsetPersistenceProvider(MOPersistenceProvider persistenceProvider) Sets the persistence provider which stores and restores non-volatile (i.e., persistent) MIB data.voidsetTableSizeLimit(int sizeLimit) Sets the table size limit for the tables in this agent.voidsetTableSizeLimits(Properties sizeLimits) Sets the table size limits for the tables in this agent.voidCreates and registers the proxy forwarder of this agent by callingcreateProxyForwarder(CommandProcessor).voidsetupSnmpUsmDhObjectsMib(Collection<DHKickstartParameters> dhKickstartParameters) Creates the SNMP-USM-DH-OBJECTS-MIB instance of this agent with the supplied Diffie-Hellman kickstart parameters.voidshutdown()Shutdown the agent by closing the internal SNMP session - including the transport mappings provided through the configuredMessageDispatcherand then store the agent state to persistent storage (if available).protected voidstopTransportMappings(Collection<? extends org.snmp4j.TransportMapping<?>> transportMappings) Closes a list of transport mappings.voidSuspends processing of SNMP requests.protected voidunregisterMIBs(org.snmp4j.smi.OctetString context) Unregister the initialized MIB modules from the default context of the agent.protected voidWait until all pending modifications (external via SNMP request or internal by LockRequest) to any of the servers are done.
-
Field Details
-
agent
TheCommandProcessorthat processes the incoming SNMP requests of this agent. -
workerPool
protected org.snmp4j.util.WorkerPool workerPoolTheWorkerPoolthat provides the threads used to process incoming requests. -
vacm
-
usm
protected org.snmp4j.security.USM usmThe User Based Security Model (USM) of this agent. -
servers
The managed object servers that provide the managed objects of this agent. -
session
protected org.snmp4j.Session sessionThe SNMP session used to send notifications and to forward proxied requests. -
dispatcher
protected org.snmp4j.MessageDispatcher dispatcherThe message dispatcher that dispatches incoming and outgoing SNMP messages. -
engineID
protected org.snmp4j.smi.OctetString engineIDThe authoritative engine ID of this agent. -
proxyForwarder
The proxy forwarder application of this agent ornullif proxy forwarding is not supported by this agent. -
notificationOriginator
The notification originator that sends the notifications (traps and informs) of this agent. -
configuration
The factory that provides theMOInputwith the initial configuration of this agent ornullif no initial configuration is available. -
persistenceProvider
The primary persistence provider used to load and store the persistent managed objects of this agent. -
persistenceImportMode
protected int persistenceImportModeTheImportModeused when the persistent configuration is restored. -
engineBootsProvider
protected org.snmp4j.cfg.EngineBootsProvider engineBootsProviderThe provider of the engine boots counter of this agent. -
counterSupport
protected org.snmp4j.mp.CounterSupport counterSupportThe counter support that records and provides the event counters of this agent. -
securityProtocols
protected org.snmp4j.security.SecurityProtocols securityProtocolsThe security protocols (authentication and privacy protocols) supported by this agent. -
securityModels
protected org.snmp4j.security.SecurityModels securityModelsThe security models supported by this agent. -
snmpv2MIB
The SNMPv2-MIB implementation of this agent. -
snmpMpdMib
The SNMP-MPD-MIB implementation of this agent. -
targetMIB
The SNMP-TARGET-MIB implementation of this agent. -
communityMIB
The SNMP-COMMUNITY-MIB implementation of this agent. -
notificationMIB
The SNMP-NOTIFICATION-MIB implementation of this agent. -
frameworkMIB
The SNMP-FRAMEWORK-MIB implementation of this agent. -
usmMIB
The SNMP-USER-BASED-SM-MIB implementation of this agent. -
vacmMIB
The SNMP-VIEW-BASED-ACM-MIB implementation of this agent. -
tlsTmMib
The SNMP-TLS-TM-MIB implementation of this agent. -
proxyMIB
The SNMP-PROXY-MIB implementation of this agent ornullif not supported. -
snmpUsmDhObjectsMib
The SNMP-USM-DH-OBJECTS-MIB implementation of this agent ornullif Diffie-Hellman key exchange is not supported. -
snmp4jLogMIB
The SNMP4J-LOG-MIB implementation of this agent ornullif not supported. -
snmp4jConfigMIB
The SNMP4J-CONFIG-MIB implementation of this agent ornullif not supported. -
snmp4jProxyMIB
The SNMP4J-PROXY-MIB implementation of this agent ornullif not supported. -
notificationLogMIB
The NOTIFICATION-LOG-MIB implementation of this agent ornullif not supported. -
notificationLogDefaultLimit
protected org.snmp4j.smi.UnsignedInteger32 notificationLogDefaultLimitThe maximum number of notifications held by the default notification log. -
notificaitonLogGlobalLimit
protected org.snmp4j.smi.UnsignedInteger32 notificaitonLogGlobalLimitThe maximum number of notifications held by all notification logs together. -
notificaitonLogGlobalAge
protected org.snmp4j.smi.UnsignedInteger32 notificaitonLogGlobalAgeThe maximum age of a logged notification in minutes where zero means no age limit. -
moFactory
The factory used to create the managed objects of the MIB modules of this agent. -
sysDescr
protected org.snmp4j.smi.OctetString sysDescrThe value of thesysDescrobject of this agent. -
sysOID
protected org.snmp4j.smi.OID sysOIDThe value of thesysObjectIDobject of this agent. -
sysServices
protected org.snmp4j.smi.Integer32 sysServicesThe value of thesysServicesobject of this agent. -
defaultContext
protected org.snmp4j.smi.OctetString defaultContextThe default context of this agent, which is the empty context by default. -
runState
The current run state of this agent. -
tableSizeLimit
The table size limit applied to the tables of this agent ornullif the table sizes are not limited. -
diffieHellmanKickstartParameters
The Diffie-Hellman kickstart parameters of this agent ornullif there are none. -
agentStateListeners
The listeners that are informed about run state changes of this agent. -
auditPolicy
A protected, transient, and volatile variable representing the audit policy associated with an agent. This variable is used to manage and enforce audit-related policies for monitoring and recording activities or events within the system.The use of the
transientkeyword indicates that this variable will not be serialized when the containing object is serialized. Thevolatilemodifier ensures that the value of this variable is always read from and written to the main memory, rather than being cached.The variable is declared as
protected, meaning it is accessible within the same class, within subclasses, and within other classes in the same package.
-
-
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 an 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 tonullto use the default VACM associated with theVacmMIB.moServers- the managed object server(s) that serve the managed objects available to this agent.workerPool- theWorkerPoolto be used to process incoming request.configurationFactory- aMOInputFactorythat creates aMOInputstream with containing serialized ManagedObject information with the agent's configuration ornullotherwise.persistenceProvider- the primaryMOPersistenceProviderto 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 an 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 tonullto use the default VACM associated with theVacmMIB.moServers- the managed object server(s) that serve the managed objects available to this agent.workerPool- theWorkerPoolto be used to process incoming request.configurationFactory- aMOInputFactorythat creates aMOInputstream with containing serialized ManagedObject information with the agent's configuration ornullotherwise.persistenceProvider- the primaryMOPersistenceProviderto be used to load and store persistent MOs.engineBootsProvider- the provider of engine boots counter.moFactory- theMOFactoryto be used to createManagedObjects created by this config manager. IfnulltheDefaultMOFactorywill 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 an 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 tonullto use the default VACM associated with theVacmMIB.moServers- the managed object server(s) that serve the managed objects available to this agent.workerPool- theWorkerPoolto be used to process incoming request.configurationFactory- aMOInputFactorythat creates aMOInputstream with containing serialized ManagedObject information with the agent's configuration ornullotherwise.persistenceProvider- the primaryMOPersistenceProviderto be used to load and store persistent MOs.engineBootsProvider- the provider of engine boots counter.moFactory- theMOFactoryto be used to createManagedObjects created by this config manager. IfnulltheDefaultMOFactorywill be used.diffieHellmanKickstartParameters- an optional list of Diffie-Hellman kickstart parameters to initialize the USM authentication and privacy keys.- Since:
- 3.0
-
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, AgentAuditPolicy auditPolicy) Creates an 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 tonullto use the default VACM associated with theVacmMIB.moServers- the managed object server(s) that serve the managed objects available to this agent.workerPool- theWorkerPoolto be used to process incoming request.configurationFactory- aMOInputFactorythat creates aMOInputstream with containing serialized ManagedObject information with the agent's configuration ornullotherwise.persistenceProvider- the primaryMOPersistenceProviderto be used to load and store persistent MOs.engineBootsProvider- the provider of engine boots counter.moFactory- theMOFactoryto be used to createManagedObjects created by this config manager. IfnulltheDefaultMOFactorywill be used.diffieHellmanKickstartParameters- an optional list of Diffie-Hellman kickstart parameters to initialize the USM authentication and privacy keys.auditPolicy- theAgentAuditPolicyto be used to audit SNMP requests. Whennullthe auditing is disabled.- Since:
- 3.12.0
-
-
Method Details
-
getAuditPolicy
Gets the audit policy that is applied by this agent.- Returns:
- the
AgentAuditPolicyof this agent ornullif no audit policy is being applied.
-
setAuditPolicy
Sets the audit policy to be applied by this agent.- Parameters:
auditPolicy- theAgentAuditPolicyto be applied ornullto not apply any audit policy.
-
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 differentAgentConfigManagerinstances can coexist within the same Java process. Thus, using this method is required before callingrun()for concurrent execution ofrun(), i.e. in a multithreaded multi-agent architecture.- Parameters:
securityModels- the security models supported by this agent.securityProtocols- the security protocols supported by this agent.counterSupport- theCounterSupportinstance 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
Adds a listener that is informed whenever the run state of this agent changes.- Parameters:
agentStateListener- theAgentStateListenerto add.
-
removeAgentStateListener
Removes a previously added agent state listener.- Parameters:
agentStateListener- theAgentStateListenerto remove.- Returns:
trueif the listener has been removed,falseif it was not registered.
-
fireAgentStateChange
protected void fireAgentStateChange()Informs all registeredAgentStateListeners about the current run state of this agent. -
getState
public int getState()Returns the state of the agent.- Returns:
- a integer constant from
AgentState.STATE_CREATEDthruAgentState.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 launching (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:
trueif the running state could be restored,falseotherwise.
-
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 configuredMessageDispatcherand 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 hookThreadat theRuntimeinstance. -
initSnmp4jLogMIB
public void initSnmp4jLogMIB()Creates the SNMP4J-LOG-MIB instance of this agent. -
initSnmp4jConfigMIB
Creates the SNMP4J-CONFIG-MIB instance of this agent and associates it with the persistence providers that can be selected through that MIB module.- Parameters:
persistenceProvider- the secondary persistence providers to be made available in addition to the primaryMOPersistenceProviderof this agent, ornullif there are none.
-
initSnmp4jProxyMIB
public void initSnmp4jProxyMIB(org.snmp4j.smi.OctetString context) Creates the SNMP4J-PROXY-MIB instance of this agent for the specified context.- Parameters:
context- the context whoseMOServeris used by the proxy MIB to look up the managed objects to be proxied.
-
getCommandProcessor
Gets the command processor that processes the SNMP requests of this agent.- Returns:
- the
CommandProcessorof this agent.
-
getVacmMIB
-
getUsm
public org.snmp4j.security.USM getUsm()Gets the User Based Security Model (USM) of this agent.- Returns:
- the
USMof this agent ornullif this agent has not yet been initialized.
-
getUsmMIB
-
getSecurityProtocols
public org.snmp4j.security.SecurityProtocols getSecurityProtocols()Gets the security protocols supported by this agent.- Returns:
- the
SecurityProtocolsof this agent ornullif the security context has not yet been initialized.
-
getSecurityModels
public org.snmp4j.security.SecurityModels getSecurityModels()Gets the security models supported by this agent.- Returns:
- the
SecurityModelsof this agent ornullif the security context has not yet been initialized.
-
initNotificationLogMIB
Creates the NOTIFICATION-LOG-MIB instance of this agent, creates its default log, and registers the log as notification log listener at theNotificationOriginatorof this agent.- Parameters:
vacm- the view access control model used to check access to the logged notifications.notifyMIB- the SNMP-NOTIFICATION-MIB instance that defines the notifications to be logged.
-
initSecurityContext
protected void initSecurityContext()Initializes the security models and security protocols of this agent with the static default instances, if they have not been set before bysetContext(SecurityModels, SecurityProtocols, CounterSupport). -
initSecurityModels
protected void initSecurityModels(org.snmp4j.cfg.EngineBootsProvider engineBootsProvider) Creates the USM and the TSM security models of this agent, adds them to the supportedSecurityModels, and creates the SNMP-FRAMEWORK-MIB instance of this agent.- Parameters:
engineBootsProvider- theEngineBootsProviderthat provides the engine boots counter of the USM.
-
initMessageDispatcherWithMPs
protected void initMessageDispatcherWithMPs(org.snmp4j.MessageDispatcher mp) Adds the message processing models for SNMPv1, SNMPv2c, and SNMPv3 to the supplied message dispatcher.- Parameters:
mp- theMessageDispatcherthe message processing models are added to.
-
registerTransportMappings
protected void registerTransportMappings()Registers theMessageDispatcherof this agent as transport listener at all transport mappings of that dispatcher and sets the TLS security callback for TLS/DTLS transports. -
launchTransportMappings
Puts all transport mappings of theMessageDispatcherof this agent into listen mode.- Throws:
IOException- if a transport cannot listen to incoming messages.
-
launchTransportMappings
protected void launchTransportMappings(Collection<? extends org.snmp4j.TransportMapping<?>> transportMappings) throws IOException Puts a list of transport mappings into listen mode.- Parameters:
transportMappings- a list ofTransportMappinginstances.- Throws:
IOException- if a transport cannot listen to incoming messages.
-
stopTransportMappings
protected void stopTransportMappings(Collection<? extends org.snmp4j.TransportMapping<?>> transportMappings) throws IOException Closes a list of transport mappings.- Parameters:
transportMappings- a list ofTransportMappinginstances.- Throws:
IOException- if transport cannot be closed.
-
saveState
public boolean saveState()Save the state of the agent persistently - if necessary persistent storage is available.- Returns:
trueif state has been saved successfully,falseis returned if an error occurred or nopersistenceProvideris set. The error details can be found in therunStateobject.
-
restoreState
public boolean restoreState()Restore a previously persistently saved state - if available.- Returns:
trueif the agent state could be restored successfully,falseotherwise.
-
configure
public void configure()Configures components and managed objects using thegetConfigurationFactory(). If the factory isnullthen nothing will be done. In any case, the agent state is advanced toAgentState.STATE_CONFIGUREDif no error occurred. -
initMandatoryMIBs
protected void initMandatoryMIBs()Creates the instances of the mandatory MIB modules of this agent (SNMPv2-MIB, SNMP-MPD-MIB, SNMP-TARGET-MIB, SNMP-NOTIFICATION-MIB, SNMP-VIEW-BASED-ACM-MIB, SNMP-USER-BASED-SM-MIB, SNMP-COMMUNITY-MIB, and SNMP-TLS-TM-MIB). -
linkCounterListener
protected void linkCounterListener()Registers the MIB modules of this agent that provide counter objects as counter listeners at the command processor, the message dispatcher, the USM, the message processing models, and the TLS transport mappings of this agent. Already registered listeners are removed before, so this method can be called more than once. -
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-nullSecurityProtocolsinstance before.- Returns:
SecurityProtocols.getInstance()by default after initialization bySecurityProtocols.addDefaultProtocols().
-
createUSM
protected org.snmp4j.security.USM createUSM(org.snmp4j.cfg.EngineBootsProvider engineBootsProvider, org.snmp4j.smi.OctetString engineID) Creates the USM used by this agent configuration.- Parameters:
engineBootsProvider- theEngineBootsProviderthat provides the engine boots counter of the created USM.engineID- the local engine ID of the created USM.- Returns:
- an USM initialized by the engine boots from the
engineBootsProviderandengineID.
-
createUSM
protected org.snmp4j.security.USM createUSM()Deprecated.usecreateUSM(EngineBootsProvider, OctetString)instead.Creates an USM used by this agent configuration.- Returns:
- the USM instance.
-
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
engineBootsProviderandengineID.
-
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
SysUpTimeinstance.
-
getNotificationOriginator
Returns the notification originator of this agent configuration. To get the (multi-threaded)NotificationOriginatorof the agent, usegetAgentNotificationOriginator()instead.- Returns:
- a
NotificationOriginatorinstance.
-
getAgentNotificationOriginator
Returns the notification originator of the agent. Use this method to get aNotificationOriginatorfor sending your notifications.- Returns:
- the
NotificationOriginatorinstance. - Since:
- 1.4
-
setNotificationOriginator
Sets the notification originator of this agent configuration.- Parameters:
notificationOriginator- aNotificationOriginatorinstance.
-
getCounterSupport
public org.snmp4j.mp.CounterSupport getCounterSupport()Gets the counter support that records the event counters of this agent.- Returns:
- the
CounterSupportof this agent ornullif the counter support has not yet been initialized.
-
setCounterSupport
public void setCounterSupport(org.snmp4j.mp.CounterSupport counterSupport) Sets the counter support that records the event counters of this agent. To be effective, this method has to be called beforeinitialize().- Parameters:
counterSupport- theCounterSupportto be used by this agent.
-
getConfigurationFactory
Gets the factory that generates aMOInputinstance to load initial or reset configuration into the agent.- Returns:
- a configuration provider factory or
nullif no configuration is set. - Since:
- 3.5.5
-
setConfigurationFactory
Sets the configuration factory that generates aMOInputinstance 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
MOPersistenceProviderinstance. - Since:
- 3.5.5
-
setPersistenceProvider
Sets the persistence provider which stores and restores non-volatile (i.e., persistent) MIB data.- Parameters:
persistenceProvider- aMOPersistenceProviderinstance.- 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()Creates the counter support of this agent. Overwrite this method to use a differentCounterSupportimplementation.- Returns:
- a new
CounterSupportinstance by default.
-
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, aConcurrentModificationExceptionmight 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, aConcurrentModificationExceptionmight be thrown.- Parameters:
sizeLimit- the maximum size (numer of rows) of tables allowed for this agent.- Since:
- 1.4
-
initOptionalMIBs
protected void initOptionalMIBs()Creates the instances of the optional MIB modules of this agent (SNMP4J-LOG-MIB, SNMP4J-CONFIG-MIB, NOTIFICATION-LOG-MIB, SNMP4J-PROXY-MIB, and SNMP-USM-DH-OBJECTS-MIB). -
initSnmpUsmDhObjectsMib
protected void initSnmpUsmDhObjectsMib()Creates the SNMP-USM-DH-OBJECTS-MIB instance of this agent using the Diffie-Hellman kickstart parameters returned bygetDhKickstartParameters(). -
getDhKickstartParameters
Overwrite this method to provide Diffie Hellman kick start parameters.- Returns:
- an empty list of
DHKickstartParametersby 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 isnullwhich 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 emptyOctetStringshould be used as default context instead.- Returns:
nullor 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 ofManagedObjects (i.e., a MIB module).defaultContext- the context to be used by default (i.e., thenullcontext)- 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 benullby 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()Creates and registers the proxy forwarder of this agent by callingcreateProxyForwarder(CommandProcessor). -
setupSnmpUsmDhObjectsMib
Creates the SNMP-USM-DH-OBJECTS-MIB instance of this agent with the supplied Diffie-Hellman kickstart parameters.- Parameters:
dhKickstartParameters- theDHKickstartParametersto be used to kickstart the USM users of this agent.
-
createNotificationOriginator
Creates the notification originator of this agent. Overwrite this method to use a differentNotificationOriginatorimplementation.- Returns:
- a new
NotificationOriginatorImplinstance by default.
-
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
Snmpinstance 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:VariableProviderGets the variable with the specified name, which might be either a textual name or an instance OID.- Specified by:
getVariablein interfaceVariableProvider- Parameters:
name- the name or OID of the variable to return.- Returns:
- a Variable instance or
nullif such a variable with the specified name or OID does not exists.
-
getMessageDispatcher
public org.snmp4j.MessageDispatcher getMessageDispatcher()Retrieves the current instance of the MessageDispatcher.- Returns:
- the instance of MessageDispatcher associated with this class
- Since:
- 3.9.0
-
createUSM(EngineBootsProvider, OctetString)instead.