org.snmp4j.agent.example
Class SampleAgent

java.lang.Object
  extended by org.snmp4j.agent.example.SampleAgent
All Implemented Interfaces:
VariableProvider

public class SampleAgent
extends java.lang.Object
implements 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 Java logging framework to log messages.

Version:
1.3.2
Author:
Frank Fock

Field Summary
protected  AgentConfigManager agent
           
protected  Modules modules
           
protected  MOServer server
           
protected  java.util.Properties tableSizeLimits
           
 
Constructor Summary
SampleAgent(java.util.Map args)
           
 
Method Summary
protected  void addListenAddresses(org.snmp4j.MessageDispatcher md, java.util.List<java.lang.String> addresses)
           
protected  MOFactory getFactory()
          Get the MOFactory that creates the various MOs (MIB Objects).
 org.snmp4j.smi.Variable getVariable(java.lang.String name)
          Gets the variable with the specified name, which might be either a textual name or an instance OID.
static void main(java.lang.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()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

agent

protected AgentConfigManager agent

server

protected MOServer server

modules

protected Modules modules

tableSizeLimits

protected java.util.Properties tableSizeLimits
Constructor Detail

SampleAgent

public SampleAgent(java.util.Map args)
Method Detail

addListenAddresses

protected void addListenAddresses(org.snmp4j.MessageDispatcher md,
                                  java.util.List<java.lang.String> addresses)

run

public void run()

getFactory

protected MOFactory getFactory()
Get the MOFactory that creates the various MOs (MIB Objects).

Returns:
a DefaultMOFactory instance by default.
Since:
1.3.2

registerMIBs

protected void registerMIBs()
Register your own MIB modules in the specified context of the agent. The MOFactory provided to the Modules constructor is returned by getFactory().


getVariable

public org.snmp4j.smi.Variable getVariable(java.lang.String name)
Description copied from interface: VariableProvider
Gets the variable with the specified name, which might be either a textual name or an instance OID.

Specified by:
getVariable in interface VariableProvider
Parameters:
name - the name or OID of the variable to return.
Returns:
a Variable instance or null if such a variable with the specified name or OID does not exists.

main

public static void main(java.lang.String[] args)
Runs a sample agent with a default configuration defined by 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
 

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 see ArgumentParser.

Copyright 2005-2010 Frank Fock (SNMP4J.org)

Copyright © 2011 SNMP4J.org. All Rights Reserved.