Package org.snmp4j.agent.example
Class SampleAgent
java.lang.Object
org.snmp4j.agent.example.SampleAgent
- All Implemented Interfaces:
VariableProvider
The SampleAgent uses an
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.
- Version:
- 2.7.3
- Author:
- Frank Fock
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AgentConfigManagerprotected Modulesprotected MOServerprotected Properties -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddListenAddresses(org.snmp4j.MessageDispatcher md, List<?> addresses) protected MOFactoryGet theMOFactorythat creates the various MOs (MIB Objects).org.snmp4j.smi.VariablegetVariable(String name) Gets the variable with the specified name, which might be either a textual name or an instance OID.static voidRuns a sample agent with a default configuration defined bySampleAgentConfig.properties.protected voidRegister your own MIB modules in the specified context of the agent.voidrun()
-
Field Details
-
agent
-
server
-
modules
-
tableSizeLimits
-
-
Constructor Details
-
SampleAgent
-
-
Method Details
-
addListenAddresses
-
run
public void run() -
getFactory
Get theMOFactorythat creates the various MOs (MIB Objects).- Returns:
- a
DefaultMOFactoryinstance by default. - Since:
- 1.3.2
-
registerMIBs
protected void registerMIBs()Register your own MIB modules in the specified context of the agent. TheMOFactoryprovided to theModulesconstructor is returned bygetFactory(). -
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.
-
main
Runs a sample agent with a default configuration defined bySampleAgentConfig.properties. A sample command line is:-c SampleAgent.cfg -bc SampleAgent.bc udp:127.0.0.1/4700 tcp:127.0.0.1/4700
- Parameters:
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 seeArgumentParser.
-