org.snmp4j.agent.AgentStateListener
public class SampleAgent extends Object implements org.snmp4j.agent.AgentStateListener
AgentConfigManager
instance to create a
minimal SNMP agent using the configuration defined by
SampleAgentConfig.properties
in this package. That properties
file defines the initial content of the registered MIB objects of this agent
which may differ from the hard coded defaults.
This SampleAgent
uses the MOXodusPersistenceProvider
to persistently
store ManagedObject
s. It assumes that all managed objects that are non-volatile
are implementing the RandomAccessManagedObject
interfaces.
The agent uses the console logging to log messages.
Modifier and Type | Field | Description |
---|---|---|
protected org.snmp4j.agent.AgentConfigManager |
agent |
|
protected org.snmp4j.agent.MOServer |
server |
|
protected Properties |
tableSizeLimits |
Constructor | Description |
---|---|
SampleAgent(Map<String,List<?>> args) |
Modifier and Type | Method | Description |
---|---|---|
protected void |
addListenAddresses(org.snmp4j.MessageDispatcher md,
List<String> addresses) |
|
void |
agentStateChanged(org.snmp4j.agent.AgentConfigManager agentConfigManager,
org.snmp4j.agent.AgentState newState) |
The agent state has changed to the new state as provided.
|
protected org.snmp4j.agent.mo.MOFactory |
getFactory() |
Get the
MOFactory that creates the various MOs (MIB Objects). |
static void |
main(String[] args) |
Runs a sample agent with a default configuration defined by
SampleAgentConfig.properties . |
protected void |
registerMIBs() |
Register your own MIB modules in the specified context of the agent.
|
void |
run() |
protected org.snmp4j.agent.AgentConfigManager agent
protected org.snmp4j.agent.MOServer server
protected Properties tableSizeLimits
protected void addListenAddresses(org.snmp4j.MessageDispatcher md, List<String> addresses)
public void run()
protected org.snmp4j.agent.mo.MOFactory getFactory()
MOFactory
that creates the various MOs (MIB Objects).DefaultMOFactory
instance by default.protected void registerMIBs()
MOFactory
provided to the Modules
constructor
is returned by getFactory()
.public static void main(String[] args)
SampleAgentConfig.properties
. A sample command line is:
-c SampleAgent.cfg -bc SampleAgent.bc udp:127.0.0.1/4700 tcp:127.0.0.1/4700
args
- the command line arguments defining at least the listen addresses.
The format is -c[s{=SampleAgent.cfg}] -bc[s{=SampleAgent.bc}]
+ts[s] +cfg[s] #address[s<(udp|tcp|tls):.*[/[0-9]+]?>] ..
.
For the format description see ArgumentParser
.public void agentStateChanged(org.snmp4j.agent.AgentConfigManager agentConfigManager, org.snmp4j.agent.AgentState newState)
agentStateChanged
in interface org.snmp4j.agent.AgentStateListener
agentConfigManager
- the agent's configuration manager. Use this object to access all agent resources, if needed to process this
event.newState
- the new state of the agent. Although the listener may advance to agent state further, it is not recommended
to do so, because the AgentConfigManager
will do it anyway.Copyright © 2018 SNMP4J.org. All rights reserved.