- java.lang.Object
-
- org.snmp4j.agent.BaseAgent
-
- All Implemented Interfaces:
Runnable
Deprecated.UseAgentConfigManager
instead. SeeSampleAgent
for sample code on how to useAgentConfigManager
. This class will be removed in SNMP4J-Agent 3.1.
@Deprecated public abstract class BaseAgent extends Object implements Runnable
TheBaseAgent
abstract class defines a framework for writing SNMP agents using the SNMP4J-Agent API. To implement your own SNMP agent, extend this class and implement the abstract methods defined by BaseAgent. The hook methods do not need any specific implementation. They only provide a defined mechanism to customize your agent.- Version:
- 1.0
- Author:
- Frank Fock
-
-
Field Summary
Fields Modifier and Type Field Description protected CommandProcessor
agent
Deprecated.protected int
agentState
Deprecated.protected org.snmp4j.cfg.EngineBootsCounterFile
bootCounterFile
Deprecated.protected String
configFileURI
Deprecated.protected org.snmp4j.smi.OctetString
defaultContext
Deprecated.protected DefaultMOPersistenceProvider
defaultPersistenceProvider
Deprecated.protected ProxyForwarder
defaultProxyForwarder
Deprecated.protected org.snmp4j.MessageDispatcherImpl
dispatcher
Deprecated.protected org.snmp4j.mp.MPv3
mpv3
Deprecated.protected NotificationOriginator
notificationOriginator
Deprecated.protected DefaultMOServer
server
Deprecated.protected org.snmp4j.Snmp
session
Deprecated.protected Snmp4jConfigMib
snmp4jConfigMIB
Deprecated.protected Snmp4jLogMib
snmp4jLogMIB
Deprecated.protected SnmpCommunityMIB
snmpCommunityMIB
Deprecated.protected SnmpFrameworkMIB
snmpFrameworkMIB
Deprecated.protected SnmpMpdMib
snmpMpdMib
Deprecated.protected SnmpNotificationMIB
snmpNotificationMIB
Deprecated.protected SnmpProxyMIB
snmpProxyMIB
Deprecated.protected SnmpTargetMIB
snmpTargetMIB
Deprecated.protected SNMPv2MIB
snmpv2MIB
Deprecated.static int
STATE_CREATED
Deprecated.static int
STATE_INIT_FINISHED
Deprecated.static int
STATE_INIT_STARTED
Deprecated.static int
STATE_RUNNING
Deprecated.static int
STATE_STOPPED
Deprecated.protected org.snmp4j.smi.OctetString
sysDescr
Deprecated.protected org.snmp4j.smi.OID
sysOID
Deprecated.protected org.snmp4j.smi.Integer32
sysServices
Deprecated.protected org.snmp4j.TransportMapping<? extends org.snmp4j.smi.Address>[]
transportMappings
Deprecated.protected org.snmp4j.security.USM
usm
Deprecated.protected UsmMIB
usmMIB
Deprecated.protected VacmMIB
vacmMIB
Deprecated.
-
Constructor Summary
Constructors Modifier Constructor Description protected
BaseAgent(File bootCounterFile, File configFile, CommandProcessor commandProcessor)
Deprecated.Creates a base agent with boot-counter, config file, and a CommandProcessor for processing SNMP requests.protected
BaseAgent(String configURI)
Deprecated.Creates a base agent with aDefaultMOServer
asMOServer
.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected abstract void
addCommunities(SnmpCommunityMIB communityMIB)
Deprecated.Adds community to security name mappings needed for SNMPv1 and SNMPv2c.protected abstract void
addNotificationTargets(SnmpTargetMIB targetMIB, SnmpNotificationMIB notificationMIB)
Deprecated.Adds initial notification targets and filters.protected void
addShutdownHook()
Deprecated.Adds a shutdown hook that saves the internal config into the config file when a SIGTERM (Ctrl-C) is terminating the agent.protected abstract void
addUsmUser(org.snmp4j.security.USM usm)
Deprecated.Adds all the necessary initial users to the USM.protected abstract void
addViews(VacmMIB vacmMIB)
Deprecated.Adds initial VACM configuration.protected void
finishInit()
Deprecated.Finishes initialization of the agent by connecting server and command processor, setting up USM, VACM, notification targets, and finally sending a coldStart notification to configured targets.CommandProcessor
getAgent()
Deprecated.int
getAgentState()
Deprecated.Returns the agent's state.File
getBootCounterFile()
Deprecated.File
getConfigFile()
Deprecated.protected org.snmp4j.smi.OctetString
getContext(MOGroup mibGroup)
Deprecated.This method can be overwritten by a subagent to specify the contexts each MIB module (group) will be registered to.org.snmp4j.smi.OctetString
getDefaultContext()
Deprecated.Returns the default context - which is the context that is used by the base agent to register its MIB objects.ProxyForwarder
getDefaultProxyForwarder()
Deprecated.protected int
getEngineBoots()
Deprecated.Reads the engine boots counter from the corresponding input stream (file).org.snmp4j.mp.MPv3
getMPv3()
Deprecated.NotificationOriginator
getNotificationOriginator()
Deprecated.DefaultMOServer
getServer()
Deprecated.org.snmp4j.Snmp
getSession()
Deprecated.Snmp4jConfigMib
getSnmp4jConfigMIB()
Deprecated.Snmp4jLogMib
getSnmp4jLogMIB()
Deprecated.SnmpCommunityMIB
getSnmpCommunityMIB()
Deprecated.SnmpFrameworkMIB
getSnmpFrameworkMIB()
Deprecated.SnmpMpdMib
getSnmpMpdMib()
Deprecated.SnmpNotificationMIB
getSnmpNotificationMIB()
Deprecated.SnmpProxyMIB
getSnmpProxyMIB()
Deprecated.SnmpTargetMIB
getSnmpTargetMIB()
Deprecated.SNMPv2MIB
getSnmpv2MIB()
Deprecated.org.snmp4j.smi.OctetString
getSysDescr()
Deprecated.org.snmp4j.smi.OID
getSysOID()
Deprecated.org.snmp4j.smi.Integer32
getSysServices()
Deprecated.org.snmp4j.security.USM
getUsm()
Deprecated.UsmMIB
getUsmMIB()
Deprecated.VacmMIB
getVacmMIB()
Deprecated.void
init()
Deprecated.Initialize transport mappings, message dispatcher, basic MIB modules, proxy forwarder, VACM and USM security, and custom MIB modules and objects provided by sub-classes.protected void
initConfigMIB()
Deprecated.protected void
initMessageDispatcher()
Deprecated.Initializes the message dispatcher (MessageDispatcherImpl
) with the transport mappings.protected void
initSnmpSession()
Deprecated.protected void
initTransportMappings()
Deprecated.Initializes the transport mappings (ports) to be used by the agent.void
loadConfig(int importMode)
Deprecated.Loads the configuration using the specified import mode from the set config file.protected abstract void
registerManagedObjects()
Deprecated.Register additional managed objects at the agent's server.protected void
registerSnmpMIBs()
Deprecated.Register the basic MIB modules at the agent'sMOServer
.void
run()
Deprecated.Starts the agent by let it listen on the configured SNMP agent ports (transpot mappings).void
saveConfig()
Deprecated.Save the current (serializable) managed object configuration into the config file.protected void
sendColdStartNotification()
Deprecated.void
setAgent(CommandProcessor agent)
Deprecated.void
setBootCounterFile(File bootCounterFile)
Deprecated.void
setConfigFile(File configFile)
Deprecated.void
setDefaultContext(org.snmp4j.smi.OctetString defaultContext)
Deprecated.Sets the default context for this base agent.void
setDefaultProxyForwarder(ProxyForwarder defaultProxyForwarder)
Deprecated.void
setSysDescr(org.snmp4j.smi.OctetString sysDescr)
Deprecated.void
setSysOID(org.snmp4j.smi.OID sysOID)
Deprecated.void
setSysServices(org.snmp4j.smi.Integer32 sysServices)
Deprecated.protected void
setupDefaultProxyForwarder()
Deprecated.Creates and registers the default proxy forwarder application (ProxyForwarderImpl
).void
stop()
Deprecated.Stops the agent by closing the SNMP session and associated transport mappings.protected abstract void
unregisterManagedObjects()
Deprecated.Unregister additional managed objects from the agent's server.protected void
unregisterSnmpMIBs()
Deprecated.Unregister the basic MIB modules from the agent'sMOServer
.protected int
updateEngineBoots()
Deprecated.Updates the engine boots counter and returns the actual value.protected void
updateSession(org.snmp4j.Session session)
Deprecated.Updates all objects with a new session instance.
-
-
-
Field Detail
-
STATE_CREATED
public static final int STATE_CREATED
Deprecated.- See Also:
- Constant Field Values
-
STATE_INIT_STARTED
public static final int STATE_INIT_STARTED
Deprecated.- See Also:
- Constant Field Values
-
STATE_INIT_FINISHED
public static final int STATE_INIT_FINISHED
Deprecated.- See Also:
- Constant Field Values
-
STATE_RUNNING
public static final int STATE_RUNNING
Deprecated.- See Also:
- Constant Field Values
-
STATE_STOPPED
public static final int STATE_STOPPED
Deprecated.- See Also:
- Constant Field Values
-
snmpv2MIB
protected SNMPv2MIB snmpv2MIB
Deprecated.
-
snmpMpdMib
protected SnmpMpdMib snmpMpdMib
Deprecated.
-
snmpFrameworkMIB
protected SnmpFrameworkMIB snmpFrameworkMIB
Deprecated.
-
snmpTargetMIB
protected SnmpTargetMIB snmpTargetMIB
Deprecated.
-
snmpNotificationMIB
protected SnmpNotificationMIB snmpNotificationMIB
Deprecated.
-
snmpProxyMIB
protected SnmpProxyMIB snmpProxyMIB
Deprecated.
-
snmpCommunityMIB
protected SnmpCommunityMIB snmpCommunityMIB
Deprecated.
-
snmp4jLogMIB
protected Snmp4jLogMib snmp4jLogMIB
Deprecated.
-
snmp4jConfigMIB
protected Snmp4jConfigMib snmp4jConfigMIB
Deprecated.
-
usmMIB
protected UsmMIB usmMIB
Deprecated.
-
vacmMIB
protected VacmMIB vacmMIB
Deprecated.
-
server
protected DefaultMOServer server
Deprecated.
-
session
protected org.snmp4j.Snmp session
Deprecated.
-
transportMappings
protected org.snmp4j.TransportMapping<? extends org.snmp4j.smi.Address>[] transportMappings
Deprecated.
-
dispatcher
protected org.snmp4j.MessageDispatcherImpl dispatcher
Deprecated.
-
agent
protected CommandProcessor agent
Deprecated.
-
mpv3
protected org.snmp4j.mp.MPv3 mpv3
Deprecated.
-
usm
protected org.snmp4j.security.USM usm
Deprecated.
-
bootCounterFile
protected org.snmp4j.cfg.EngineBootsCounterFile bootCounterFile
Deprecated.
-
notificationOriginator
protected NotificationOriginator notificationOriginator
Deprecated.
-
defaultProxyForwarder
protected ProxyForwarder defaultProxyForwarder
Deprecated.
-
sysDescr
protected org.snmp4j.smi.OctetString sysDescr
Deprecated.
-
sysOID
protected org.snmp4j.smi.OID sysOID
Deprecated.
-
sysServices
protected org.snmp4j.smi.Integer32 sysServices
Deprecated.
-
agentState
protected int agentState
Deprecated.
-
defaultContext
protected org.snmp4j.smi.OctetString defaultContext
Deprecated.
-
defaultPersistenceProvider
protected DefaultMOPersistenceProvider defaultPersistenceProvider
Deprecated.
-
configFileURI
protected String configFileURI
Deprecated.
-
-
Constructor Detail
-
BaseAgent
protected BaseAgent(String configURI)
Deprecated.Creates a base agent with aDefaultMOServer
asMOServer
. To use a different server implementation, modify theserver
member after construction.- Parameters:
configURI
- the URI of the config file holding persistent data for this agent. If persistent data is not used then set this parameter tonull
.
-
BaseAgent
protected BaseAgent(File bootCounterFile, File configFile, CommandProcessor commandProcessor)
Deprecated.Creates a base agent with boot-counter, config file, and a CommandProcessor for processing SNMP requests.- Parameters:
bootCounterFile
- a file with serialized boot-counter information (read/write). If the file does not exist it is created on shutdown of the agent.configFile
- a file with serialized configuration information (read/write). If the file does not exist it is created on shutdown of the agent.commandProcessor
- theCommandProcessor
instance that handles the SNMP requests.
-
-
Method Detail
-
init
public void init() throws IOException
Deprecated.Initialize transport mappings, message dispatcher, basic MIB modules, proxy forwarder, VACM and USM security, and custom MIB modules and objects provided by sub-classes.- Throws:
IOException
- if initialization fails because transport initialization fails.
-
initConfigMIB
protected void initConfigMIB()
Deprecated.
-
getContext
protected org.snmp4j.smi.OctetString getContext(MOGroup mibGroup)
Deprecated.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).- Returns:
- the context for which the module should be registered.
- Since:
- 1.1
-
registerSnmpMIBs
protected void registerSnmpMIBs()
Deprecated.Register the basic MIB modules at the agent'sMOServer
.
-
unregisterSnmpMIBs
protected void unregisterSnmpMIBs()
Deprecated.Unregister the basic MIB modules from the agent'sMOServer
.
-
registerManagedObjects
protected abstract void registerManagedObjects()
Deprecated.Register additional managed objects at the agent's server.
-
unregisterManagedObjects
protected abstract void unregisterManagedObjects()
Deprecated.Unregister additional managed objects from the agent's server.
-
setupDefaultProxyForwarder
protected void setupDefaultProxyForwarder()
Deprecated.Creates and registers the default proxy forwarder application (ProxyForwarderImpl
).
-
loadConfig
public void loadConfig(int importMode)
Deprecated.Loads the configuration using the specified import mode from the set config file.- Parameters:
importMode
- one of the import modes defined byImportMode
.
-
saveConfig
public void saveConfig()
Deprecated.Save the current (serializable) managed object configuration into the config file.
-
addShutdownHook
protected void addShutdownHook()
Deprecated.Adds a shutdown hook that saves the internal config into the config file when a SIGTERM (Ctrl-C) is terminating the agent.
-
finishInit
protected void finishInit()
Deprecated.Finishes initialization of the agent by connecting server and command processor, setting up USM, VACM, notification targets, and finally sending a coldStart notification to configured targets.
-
sendColdStartNotification
protected void sendColdStartNotification()
Deprecated.
-
run
public void run()
Deprecated.Starts the agent by let it listen on the configured SNMP agent ports (transpot mappings).
-
stop
public void stop()
Deprecated.Stops the agent by closing the SNMP session and associated transport mappings.- Since:
- 1.1
-
initMessageDispatcher
protected void initMessageDispatcher()
Deprecated.Initializes the message dispatcher (MessageDispatcherImpl
) with the transport mappings.
-
initSnmpSession
protected void initSnmpSession()
Deprecated.
-
updateSession
protected void updateSession(org.snmp4j.Session session)
Deprecated.Updates all objects with a new session instance. This method must be overwritten, if non-default SNMP MIB instances are created by a subclass.- Parameters:
session
- a SNMP Session instance.
-
updateEngineBoots
protected int updateEngineBoots()
Deprecated.Updates the engine boots counter and returns the actual value.- Returns:
- the actual boots counter value.
-
getEngineBoots
protected int getEngineBoots()
Deprecated.Reads the engine boots counter from the corresponding input stream (file).- Returns:
- the boots counter value read or zero if it could not be read.
-
addUsmUser
protected abstract void addUsmUser(org.snmp4j.security.USM usm)
Deprecated.Adds all the necessary initial users to the USM.- Parameters:
usm
- the USM instance used by this agent.
-
addNotificationTargets
protected abstract void addNotificationTargets(SnmpTargetMIB targetMIB, SnmpNotificationMIB notificationMIB)
Deprecated.Adds initial notification targets and filters.- Parameters:
targetMIB
- the SnmpTargetMIB holding the target configuration.notificationMIB
- the SnmpNotificationMIB holding the notification (filter) configuration.
-
addViews
protected abstract void addViews(VacmMIB vacmMIB)
Deprecated.Adds initial VACM configuration.- Parameters:
vacmMIB
- the VacmMIB holding the agent's view configuration.
-
addCommunities
protected abstract void addCommunities(SnmpCommunityMIB communityMIB)
Deprecated.Adds community to security name mappings needed for SNMPv1 and SNMPv2c.- Parameters:
communityMIB
- the SnmpCommunityMIB holding coexistence configuration for community based security models.
-
initTransportMappings
protected void initTransportMappings() throws IOException
Deprecated.Initializes the transport mappings (ports) to be used by the agent.- Throws:
IOException
- if an IO exception occurs while initializing the default transport mapping on all local IP addresses on port 161.
-
getNotificationOriginator
public NotificationOriginator getNotificationOriginator()
Deprecated.
-
setDefaultProxyForwarder
public void setDefaultProxyForwarder(ProxyForwarder defaultProxyForwarder)
Deprecated.
-
setSysDescr
public void setSysDescr(org.snmp4j.smi.OctetString sysDescr)
Deprecated.
-
setSysOID
public void setSysOID(org.snmp4j.smi.OID sysOID)
Deprecated.
-
setSysServices
public void setSysServices(org.snmp4j.smi.Integer32 sysServices)
Deprecated.
-
setAgent
public void setAgent(CommandProcessor agent)
Deprecated.
-
setBootCounterFile
public void setBootCounterFile(File bootCounterFile)
Deprecated.
-
setConfigFile
public void setConfigFile(File configFile)
Deprecated.
-
setDefaultContext
public void setDefaultContext(org.snmp4j.smi.OctetString defaultContext)
Deprecated.Sets the default context for this base agent. By setting this value before any MIB modules have been registered at the internal server, the context for which the registration is performed can be changed. The default context isnull
which causes MIB objects to be virtually registered for all contexts.- Parameters:
defaultContext
- the context for default MIB objects.- Since:
- 1.1
-
getDefaultProxyForwarder
public ProxyForwarder getDefaultProxyForwarder()
Deprecated.
-
getSysDescr
public org.snmp4j.smi.OctetString getSysDescr()
Deprecated.
-
getSysOID
public org.snmp4j.smi.OID getSysOID()
Deprecated.
-
getSysServices
public org.snmp4j.smi.Integer32 getSysServices()
Deprecated.
-
getAgent
public CommandProcessor getAgent()
Deprecated.
-
getBootCounterFile
public File getBootCounterFile()
Deprecated.
-
getConfigFile
public File getConfigFile()
Deprecated.
-
getSnmp4jConfigMIB
public Snmp4jConfigMib getSnmp4jConfigMIB()
Deprecated.
-
getSnmp4jLogMIB
public Snmp4jLogMib getSnmp4jLogMIB()
Deprecated.
-
getSnmpCommunityMIB
public SnmpCommunityMIB getSnmpCommunityMIB()
Deprecated.
-
getSnmpFrameworkMIB
public SnmpFrameworkMIB getSnmpFrameworkMIB()
Deprecated.
-
getSnmpNotificationMIB
public SnmpNotificationMIB getSnmpNotificationMIB()
Deprecated.
-
getSnmpProxyMIB
public SnmpProxyMIB getSnmpProxyMIB()
Deprecated.
-
getSnmpTargetMIB
public SnmpTargetMIB getSnmpTargetMIB()
Deprecated.
-
getSnmpv2MIB
public SNMPv2MIB getSnmpv2MIB()
Deprecated.
-
getSnmpMpdMib
public SnmpMpdMib getSnmpMpdMib()
Deprecated.
-
getUsmMIB
public UsmMIB getUsmMIB()
Deprecated.
-
getVacmMIB
public VacmMIB getVacmMIB()
Deprecated.
-
getSession
public org.snmp4j.Snmp getSession()
Deprecated.
-
getServer
public DefaultMOServer getServer()
Deprecated.
-
getMPv3
public org.snmp4j.mp.MPv3 getMPv3()
Deprecated.
-
getUsm
public org.snmp4j.security.USM getUsm()
Deprecated.
-
getAgentState
public int getAgentState()
Deprecated.Returns the agent's state.- Returns:
- one of the state's starting from
STATE_CREATED
toSTATE_RUNNING
. - Since:
- 1.1
-
getDefaultContext
public org.snmp4j.smi.OctetString getDefaultContext()
Deprecated.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.- Since:
- 1.1
-
-