Package org.snmp4j.agent.agentx.master
Class AgentXMasterAgent
java.lang.Object
org.snmp4j.agent.AgentConfigManager
org.snmp4j.agent.agentx.master.AgentXMasterAgent
- All Implemented Interfaces:
Runnable,EventListener,org.snmp4j.agent.mo.util.VariableProvider,org.snmp4j.transport.TransportStateListener
public class AgentXMasterAgent
extends org.snmp4j.agent.AgentConfigManager
implements org.snmp4j.transport.TransportStateListener
The
AgentXMasterAgent is the base agent class for
AgentX master agents. It extends the AgentConfigManager class
provided by SNMP4J-Agent.
To implement a master agent, simply extend this class instead of
AgentConfigManager as you would do for a non-AgentX agent.
- Version:
- 3.0.0
- Author:
- Frank Fock
-
Nested Class Summary
Nested classes/interfaces inherited from class org.snmp4j.agent.AgentConfigManager
org.snmp4j.agent.AgentConfigManager.AgentState, org.snmp4j.agent.AgentConfigManager.ErrorDescriptor -
Field Summary
Fields inherited from class org.snmp4j.agent.AgentConfigManager
agent, agentStateListeners, communityMIB, configuration, counterSupport, defaultContext, diffieHellmanKickstartParameters, dispatcher, engineBootsProvider, engineID, frameworkMIB, moFactory, notificaitonLogGlobalAge, notificaitonLogGlobalLimit, notificationLogDefaultLimit, notificationLogMIB, notificationMIB, notificationOriginator, persistenceImportMode, persistenceProvider, proxyForwarder, proxyMIB, runState, securityModels, securityProtocols, servers, session, snmp4jConfigMIB, snmp4jLogMIB, snmp4jProxyMIB, snmpMpdMib, snmpUsmDhObjectsMib, snmpv2MIB, sysDescr, sysOID, sysServices, tableSizeLimit, targetMIB, tlsTmMib, usm, usmMIB, vacm, vacmMIB, workerPool -
Constructor Summary
ConstructorsConstructorDescriptionAgentXMasterAgent(File bootCounterFile, File configFile) Creates a simple AgentX master agent using a boot counter file and config file for persistent storage.AgentXMasterAgent(org.snmp4j.smi.OctetString agentsOwnEngineID, org.snmp4j.MessageDispatcher messageDispatcher, org.snmp4j.agent.security.VACM vacm, org.snmp4j.agent.MOServer[] moServers, org.snmp4j.util.WorkerPool workerPool, org.snmp4j.agent.io.MOInputFactory configurationFactory, org.snmp4j.agent.io.MOPersistenceProvider persistenceProvider, org.snmp4j.cfg.EngineBootsProvider engineBootsProvider) Creates a SNMP agent configuration which can be run by callingAgentConfigManager.run()later. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAgentXTransportMapping(org.snmp4j.TransportMapping<?> transport) Adds a transport mapping for AgentX communication.voidconnectionStateChanged(org.snmp4j.transport.TransportStateEvent change) protected org.snmp4j.agent.CommandProcessorcreateCommandProcessor(org.snmp4j.smi.OctetString engineID) Creates the command processor.Gets a reference to the AGENTX-MIB implementation of this master agent.Gets the command processor.org.snmp4j.smi.OctetStringGets the local engine ID.static shortGets the upper limit for AgentX Get Bulk repetitions field send on behalf of all master agents of this JVM.booleanIndicates whether only subagents from the local host or from any host are allowed to connect to this master agent (default is any host).protected voidLaunch (or relaunch) AgentX transport mappings.protected voidregisterMIBs(org.snmp4j.smi.OctetString context) voidremoveAgentXTransportMapping(org.snmp4j.TransportMapping<?> transport) Removes a transport mapping for AgentX communication.voidsetLocalEngineID(org.snmp4j.smi.OctetString localEngineID) Sets the local engine ID.voidsetLocalhostSubagentsOnly(boolean localhostSubagentsOnly) Sets the local host only connection filter flag.static voidsetMaxGetBulkRepetitions(short maxRepetitions) Sets the maximum repetitions value used by this master agent for its AgentX Get Bulk requests to subagents.voidshutdown()Shutdown communication be stopping all AgentX transport mappings.protected voidunregisterMIBs(org.snmp4j.smi.OctetString context) Methods inherited from class org.snmp4j.agent.AgentConfigManager
addAgentStateListener, configure, continueProcessing, createCounterSupport, createNotificationOriginator, createProxyForwarder, createSnmpSession, createTSM, createUSM, fireAgentStateChange, fireLaunchNotifications, getAgentNotificationOriginator, getConfigurationFactory, getContext, getCounterSupport, getDefaultContext, getDhKickstartParameters, getNotificationLogMIB, getNotificationOriginator, getPersistenceImportMode, getPersistenceProvider, getSecurityModels, getSecurityProtocols, getSnmp4jConfigMIB, getSnmp4jLogMIB, getSnmp4jProxyMIB, getSnmpCommunityMIB, getSnmpMpdMib, getSnmpNotificationMIB, getSnmpTargetMIB, getSNMPv2MIB, getState, getSupportedSecurityProtocols, getSysDescr, getSysOID, getSysServices, getSysUpTime, getUsm, getUsmMIB, getVACM, getVacmMIB, getVariable, initialize, initMandatoryMIBs, initMessageDispatcherWithMPs, initNotificationLogMIB, initOptionalMIBs, initSecurityContext, initSecurityModels, initSnmp4jConfigMIB, initSnmp4jLogMIB, initSnmp4jProxyMIB, initSnmpUsmDhObjectsMib, launch, launchTransportMappings, linkCounterListener, registerShutdownHook, registerTransportMappings, removeAgentStateListener, restoreState, run, saveState, setConfigurationFactory, setContext, setCounterSupport, setNotificationOriginator, setPersistenceImportMode, setPersistenceProvider, setTableSizeLimit, setTableSizeLimits, setupProxyForwarder, setupSnmpUsmDhObjectsMib, stopTransportMappings, suspendProcessing, waitUntilPendingModificationsDone
-
Constructor Details
-
AgentXMasterAgent
public AgentXMasterAgent(org.snmp4j.smi.OctetString agentsOwnEngineID, org.snmp4j.MessageDispatcher messageDispatcher, org.snmp4j.agent.security.VACM vacm, org.snmp4j.agent.MOServer[] moServers, org.snmp4j.util.WorkerPool workerPool, org.snmp4j.agent.io.MOInputFactory configurationFactory, org.snmp4j.agent.io.MOPersistenceProvider persistenceProvider, org.snmp4j.cfg.EngineBootsProvider engineBootsProvider) Creates a SNMP agent configuration which can be run by callingAgentConfigManager.run()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 server 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.
-
AgentXMasterAgent
Creates a simple AgentX master agent using a boot counter file and config file for persistent storage.- Parameters:
bootCounterFile- a file that stores the boot counter.configFile- a file that stores persistent MIB data.
-
-
Method Details
-
createCommandProcessor
protected org.snmp4j.agent.CommandProcessor createCommandProcessor(org.snmp4j.smi.OctetString engineID) Creates the command processor.- Overrides:
createCommandProcessorin classorg.snmp4j.agent.AgentConfigManager- Parameters:
engineID- the engine ID of the agent.- Returns:
- a new CommandProcessor instance.
-
addAgentXTransportMapping
public void addAgentXTransportMapping(org.snmp4j.TransportMapping<?> transport) Adds a transport mapping for AgentX communication.- Parameters:
transport- aTransportMapping.
-
removeAgentXTransportMapping
public void removeAgentXTransportMapping(org.snmp4j.TransportMapping<?> transport) Removes a transport mapping for AgentX communication.- Parameters:
transport- aTransportMapping.
-
getMaxGetBulkRepetitions
public static short getMaxGetBulkRepetitions()Gets the upper limit for AgentX Get Bulk repetitions field send on behalf of all master agents of this JVM.- Returns:
- the upper limit for the maximum repetitions field for AgentX Get Bulk requests.
- See Also:
-
getAgentXMIB
Gets a reference to the AGENTX-MIB implementation of this master agent.- Returns:
- a
AgentXMibreference.
-
getCommandProcessor
Gets the command processor.- Overrides:
getCommandProcessorin classorg.snmp4j.agent.AgentConfigManager- Returns:
- the internal
AgentXCommandProcessor.
-
getLocalEngineID
public org.snmp4j.smi.OctetString getLocalEngineID()Gets the local engine ID.- Returns:
- the engine ID of the master agent.
-
isLocalhostSubagentsOnly
public boolean isLocalhostSubagentsOnly()Indicates whether only subagents from the local host or from any host are allowed to connect to this master agent (default is any host).- Returns:
trueif only connections from the local host are allowed andfalseif connections from any host are allowed.
-
setMaxGetBulkRepetitions
public static void setMaxGetBulkRepetitions(short maxRepetitions) Sets the maximum repetitions value used by this master agent for its AgentX Get Bulk requests to subagents. The default is the maximum short value. The SNMP GETBULK request already defines a maximum repetitions value that is always the upper limit also for AgentX Get Bulk requests on its behalf.The NET-SNMP AgentX sub-agent has a bug in its AgentX Get Bulk processing that causes endless loops in the sub-agent when the max-repetitions value is greater than one. Since this bug is in NET-SNMP since v4.2 and still present in version 5.4, it is likely, that you will need to set this value to one, if your master agent should ever communicate with a NET-SNMP sub-agent.
- Parameters:
maxRepetitions- the upper limit of the maximum repetitions for AgentX Get Bulk sub-requests.
-
setLocalEngineID
public void setLocalEngineID(org.snmp4j.smi.OctetString localEngineID) Sets the local engine ID. This method must not be called afterAgentConfigManager.initialize()has been called for the first time.- Parameters:
localEngineID- the (authoritative) engine ID of the master agent.
-
setLocalhostSubagentsOnly
public void setLocalhostSubagentsOnly(boolean localhostSubagentsOnly) Sets the local host only connection filter flag.- Parameters:
localhostSubagentsOnly-trueif only connections from the local host are allowed andfalseif connections from any host are allowed.
-
connectionStateChanged
public void connectionStateChanged(org.snmp4j.transport.TransportStateEvent change) - Specified by:
connectionStateChangedin interfaceorg.snmp4j.transport.TransportStateListener
-
registerMIBs
protected void registerMIBs(org.snmp4j.smi.OctetString context) throws org.snmp4j.agent.DuplicateRegistrationException - Overrides:
registerMIBsin classorg.snmp4j.agent.AgentConfigManager- Throws:
org.snmp4j.agent.DuplicateRegistrationException
-
unregisterMIBs
protected void unregisterMIBs(org.snmp4j.smi.OctetString context) - Overrides:
unregisterMIBsin classorg.snmp4j.agent.AgentConfigManager
-
launchTransportMappings
Launch (or relaunch) AgentX transport mappings.- Overrides:
launchTransportMappingsin classorg.snmp4j.agent.AgentConfigManager- Throws:
IOException- if the necessary ports could not be opened or bound.
-
shutdown
public void shutdown()Shutdown communication be stopping all AgentX transport mappings.- Overrides:
shutdownin classorg.snmp4j.agent.AgentConfigManager
-