public class AgentWorker
extends java.lang.Object
FriendlyAgent
which exposes minimal set of publicly
available methods.FriendlyAgent
Modifier and Type | Class and Description |
---|---|
static class |
AgentWorker.ExceptionType
Enumeration of exception types
|
Constructor and Description |
---|
AgentWorker(java.lang.String appTitle,
java.lang.String appVersion,
java.util.Properties propApp)
Constructor
|
Modifier and Type | Method and Description |
---|---|
protected void |
addCommunities(org.snmp4j.agent.mo.snmp.SnmpCommunityMIB communityMIB)
Adds community to security name mappings needed for SNMPv1 and SNMPv2c.
|
void |
addFExceptionListener(FExceptionListener l)
Adds
FExceptionListener |
protected void |
addNotificationTargets(org.snmp4j.agent.mo.snmp.SnmpTargetMIB targetMIB,
org.snmp4j.agent.mo.snmp.SnmpNotificationMIB notificationMIB)
Adds initial notification targets and filters.
|
protected void |
addShutdownHook()
Adds shutdown hook to intercept JVM shutdown event.
|
void |
addShutdownListener(ShutdownListener l)
Adds
ShutdownListener |
void |
addTarget(TargetBase target)
Adds
TargetBase objects to the collection of targets
without actual initialization of the added target. |
void |
addUncaughtExceptionListener(UncaughtExceptionListener l)
Adds
UncaughtExceptionListener |
protected void |
addUsmUser(org.snmp4j.security.USM usmUser)
Adds all the necessary initial users to the USM.
|
protected void |
addViews(org.snmp4j.agent.mo.snmp.VacmMIB vacmMIB)
Adds initial VACM configuration.
|
void |
exceptionThrown(FException e)
Sends exception to all registered listeners in the application.
|
void |
exceptionThrown(FTable table,
FException e)
Sends exception to the registered listeners in the application with
a message that a problem is found while updating the table.
|
void |
exceptionThrown(java.lang.String msg,
FException e)
Sends exception to the registered listener in the application
|
org.snmp4j.agent.CommandProcessor |
getAgent()
Returns agent: CommandProcessor object.
|
FConfig |
getConfig()
Returns configuration object
|
int |
getIgnoreUpdateMs()
Returns ignore updates interval (in milliseconds).
|
FNode |
getNode(org.snmp4j.smi.OID oid) |
FNotification |
getNotification(org.snmp4j.smi.OID oid) |
PersistStorage |
getPersistStorage()
Returns default persistence storage object.
|
FScalar |
getScalar(org.snmp4j.smi.OID oid) |
org.snmp4j.agent.DefaultMOServer |
getServer()
Returns server object.
|
FID |
getSnmpEngineBootsFID()
Returns FID of the snmpEngineBoots scalar.
|
FTable |
getTable(org.snmp4j.smi.OID oid) |
TransportSnmp |
getTransport()
Returns transport
|
TransportDomain |
getTransportDomain()
Returns transport domain
|
void |
initAgent()
This method performs all essential actions as
org.snmp4j.agent.BaseAgent.init() does. |
protected void |
initMessageDispatcher()
Initializes the message dispatcher (
MessageDispatcherImpl ) with
the transport mappings. |
protected void |
initSecurityModels()
Initializes security models.
|
protected void |
initTransportMappings()
Initializes the transport mappings (ports) to be used by the agent.
|
boolean |
isRunning() |
protected void |
registerManagedObjects()
Register managed objects in registered MIBs at the agent's server.
|
void |
removeFExceptionListener(FExceptionListener l)
Removes
FExceptionListener |
void |
removeShutdownListener(ShutdownListener l)
Removes
ShutdownListener |
void |
removeUncaughtExceptionListener(UncaughtExceptionListener l)
Removes
UncaughtExceptionListener |
void |
reportException(java.lang.String comment,
java.lang.Throwable e)
Call this method to report a caught exception in the application
to the MIB browser.
|
void |
sendNotification(org.snmp4j.smi.OID oid,
org.snmp4j.smi.VariableBinding[] vbs)
Sends notification.
|
void |
startAgent()
Starts the agent.
|
void |
stopAgent()
Stops the agent by closing the SNMP session and associated transport mappings.
|
public AgentWorker(java.lang.String appTitle, java.lang.String appVersion, java.util.Properties propApp) throws FException
appTitle
- application title.appVersion
- application version.propApp
- properties.FException
- failure to init.public void initAgent() throws java.io.IOException, FException
org.snmp4j.agent.BaseAgent.init()
does.java.io.IOException
- loading persistence or properties problemFException
- loading initial values and initializationpublic void startAgent() throws FException
FException
- if wrong state, fails to increment boot, fails to start session.public void stopAgent() throws FException
FException
- if wrong state.public boolean isRunning()
protected void addShutdownHook()
BaseAgent.addShutdownHook()
public FID getSnmpEngineBootsFID()
public void addUncaughtExceptionListener(UncaughtExceptionListener l)
UncaughtExceptionListener
l
- UncaughtExceptionListener
objectpublic void removeUncaughtExceptionListener(UncaughtExceptionListener l)
UncaughtExceptionListener
l
- UncaughtExceptionListener
objectpublic void addFExceptionListener(FExceptionListener l)
FExceptionListener
l
- FExceptionListener
objectpublic void removeFExceptionListener(FExceptionListener l)
FExceptionListener
l
- FExceptionListener
objectpublic void addShutdownListener(ShutdownListener l)
ShutdownListener
l
- ShutdownListener
objectpublic void removeShutdownListener(ShutdownListener l)
ShutdownListener
l
- ShutdownListener
objectpublic void exceptionThrown(FException e)
e
- exceptionFExceptionListener
public void exceptionThrown(FTable table, FException e)
table
- the table with the exceptione
- exceptionpublic void exceptionThrown(java.lang.String msg, FException e)
msg
- message with details about the exception, or nulle
- exceptionpublic void sendNotification(org.snmp4j.smi.OID oid, org.snmp4j.smi.VariableBinding[] vbs)
FNotification
objects. Do not call this method directly.oid
- identifier.vbs
- variable bindings.public void reportException(java.lang.String comment, java.lang.Throwable e)
comment
- error messagee
- exceptionpublic int getIgnoreUpdateMs()
public TransportSnmp getTransport()
public TransportDomain getTransportDomain()
public void addTarget(TargetBase target) throws FException
TargetBase
objects to the collection of targets
without actual initialization of the added target.target
- target.FException
- if wrong state, duplicate target, failure to init target.public FConfig getConfig()
public PersistStorage getPersistStorage()
public FNode getNode(org.snmp4j.smi.OID oid)
public FScalar getScalar(org.snmp4j.smi.OID oid)
public FTable getTable(org.snmp4j.smi.OID oid)
public FNotification getNotification(org.snmp4j.smi.OID oid)
protected void addCommunities(org.snmp4j.agent.mo.snmp.SnmpCommunityMIB communityMIB)
communityMIB
- the SnmpCommunityMIB holding coexistence configuration for community
based security models.BaseAgent.addCommunities(org.snmp4j.agent.mo.snmp.SnmpCommunityMIB)
protected void addViews(org.snmp4j.agent.mo.snmp.VacmMIB vacmMIB)
vacmMIB
- the VacmMIB holding the agent's view configuration.BaseAgent.addViews(org.snmp4j.agent.mo.snmp.VacmMIB)
protected void addUsmUser(org.snmp4j.security.USM usmUser)
usmUser
- the USM instance used by this agent.BaseAgent.addUsmUser(org.snmp4j.security.USM)
protected void addNotificationTargets(org.snmp4j.agent.mo.snmp.SnmpTargetMIB targetMIB, org.snmp4j.agent.mo.snmp.SnmpNotificationMIB notificationMIB)
targetMIB
- the SnmpTargetMIB holding the target configuration.notificationMIB
- the SnmpNotificationMIB holding the notification (filter)
configuration.BaseAgent.addNotificationTargets(
org.snmp4j.agent.mo.snmp.SnmpTargetMIB, org.snmp4j.agent.mo.snmp.SnmpNotificationMIB)
protected void registerManagedObjects()
BaseAgent.registerManagedObjects()
protected void initTransportMappings() throws java.io.IOException
java.io.IOException
- if failed to create transport mapping.BaseAgent.initTransportMappings()
protected void initSecurityModels()
protected void initMessageDispatcher()
MessageDispatcherImpl
) with
the transport mappings.
See also: org.snmp4j.agent.AgentConfigManager#initMessageDispatcherWithMPs()public org.snmp4j.agent.CommandProcessor getAgent()
public org.snmp4j.agent.DefaultMOServer getServer()