- java.lang.Object
-
- org.snmp4j.agent.example.SampleAgent
-
public class SampleAgent extends java.lang.ObjectThe SampleAgent uses anAgentConfigManagerinstance to create a minimal SNMP agent using the configuration defined bySampleAgentConfig.propertiesin 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 theModules.javafile in this package by theModules.javagenerated by AgenPro for your MIB module(s).The agent uses the
ConsoleLogFactoryto log messages.- Version:
- 3.0
- Author:
- Frank Fock
-
-
Field Summary
Fields Modifier and Type Field Description protected AgentConfigManageragentprotected Modulesmodulesprotected MOServerserverprotected java.util.PropertiestableSizeLimits
-
Constructor Summary
Constructors Constructor Description SampleAgent(java.util.Map<java.lang.String,java.util.List<java.lang.Object>> args)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddListenAddresses(org.snmp4j.MessageDispatcher md, java.util.List<java.lang.Object> addresses)protected MOFactorygetFactory()Get theMOFactorythat creates the various MOs (MIB Objects).static voidmain(java.lang.String[] args)Runs a sample agent with a default configuration defined bySampleAgentConfig.properties.protected voidregisterMIBs()Register your own MIB modules in the specified context of the agent.voidrun()
-
-
-
Field Detail
-
agent
protected AgentConfigManager agent
-
server
protected MOServer server
-
modules
protected Modules modules
-
tableSizeLimits
protected java.util.Properties tableSizeLimits
-
-
Method Detail
-
addListenAddresses
protected void addListenAddresses(org.snmp4j.MessageDispatcher md, java.util.List<java.lang.Object> addresses)
-
run
public void run()
-
getFactory
protected MOFactory 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().
-
main
public static void main(java.lang.String[] args)
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.
-
-