public class SampleAgent extends Object implements VariableProvider
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.
In order to add a new MIB object, call server.register(..)
or replace the Modules.java
file in this
package by the Modules.java
generated by AgenPro for your MIB module(s).
The agent uses the ConsoleLogFactory
to log messages.
Modifier and Type | Field and Description |
---|---|
protected AgentConfigManager |
agent |
protected Modules |
modules |
protected MOServer |
server |
protected Properties |
tableSizeLimits |
Constructor and Description |
---|
SampleAgent(Map<String,List<?>> args) |
Modifier and Type | Method and Description |
---|---|
protected void |
addListenAddresses(org.snmp4j.MessageDispatcher md,
List<?> addresses) |
protected MOFactory |
getFactory()
Get the
MOFactory that creates the various MOs (MIB Objects). |
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.
|
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 AgentConfigManager agent
protected MOServer server
protected Modules modules
protected Properties tableSizeLimits
protected void addListenAddresses(org.snmp4j.MessageDispatcher md, List<?> addresses)
public void run()
protected 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 org.snmp4j.smi.Variable getVariable(String name)
VariableProvider
getVariable
in interface VariableProvider
name
- the name or OID of the variable to return.null
if such a variable with the
specified name or OID does not exists.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
.Copyright © 2019 SNMP4J.org. All rights reserved.