Class AgentXSubagent
java.lang.Object
org.snmp4j.agent.agentx.subagent.AgentXSubagent
- All Implemented Interfaces:
EventListener, AgentXCommandListener, org.snmp4j.agent.NotificationOriginator, org.snmp4j.transport.TransportStateListener
public class AgentXSubagent
extends Object
implements AgentXCommandListener, org.snmp4j.agent.NotificationOriginator, org.snmp4j.transport.TransportStateListener
The
AgentXSubagent class implements the AgentX communication
for an AgentX subagent implementation and the agent configuration via AgentConfigManager although many
configurations that are necessary for a regular command responder and AgentX master agent are not applicable
for a subagent.
Since version 3.1.1 this class uses a ConcurrentHashMap to store AgentX sessions, which allows better
concurrent operations on agents using multiple sessions.- Version:
- 3.2.0
- Author:
- Frank Fock
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classTheRequestIDuniquely identifies a set request in the request list by the master's address, the AgentX session ID, and the AgentX transaction ID. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intThe next AgentX transaction ID to be assigned bygetNextTransactionID().protected final Map<org.snmp4j.smi.Address, AgentXPeer<?>> The AgentX peer agents (masters).protected org.snmp4j.agent.RequestHandler<AgentXRequest> Request handler for CleanupSet requests.protected org.snmp4j.agent.RequestHandler<AgentXRequest> Request handler for CommitSet requests.protected org.snmp4j.agent.RequestHandler<AgentXRequest> Request handler for Get requests.protected org.snmp4j.agent.RequestHandler<AgentXRequest> Request handler for GetBulk requests.protected org.snmp4j.agent.RequestHandler<AgentXRequest> Request handler for GetNext requests.protected org.snmp4j.agent.RequestHandler<AgentXRequest> Request handler for TestSet requests.protected org.snmp4j.agent.RequestHandler<AgentXRequest> Request handler for UndoSet requests.protected final Map<AgentXSubagent.RequestID, AgentXRequest> The request list.protected final Map<Integer, AgentXSession<?>> The sessions hold by this sub-agent.protected Map<String, AgentXSharedMOTableSupport<?, ?>> Shared table support map with a key composed ofsessionID + "#" + context. -
Constructor Summary
ConstructorsConstructorDescriptionAgentXSubagent(AgentX agentX, org.snmp4j.smi.OID subagentID, org.snmp4j.smi.OctetString subagentDescr, SubagentXConfigManager configManager, org.snmp4j.agent.audit.AgentAuditPolicy auditPolicy) Creates a AgentX sub-agent using aSubagentXConfigManager. -
Method Summary
Modifier and TypeMethodDescription<A extends org.snmp4j.smi.Address>
intaddAgentCaps(AgentXSession<A> session, org.snmp4j.smi.OctetString context, org.snmp4j.smi.OID id, org.snmp4j.smi.OctetString descr) Registers an agent capability (sysORID) with the master agent for the given context.protected <A extends org.snmp4j.smi.Address>
org.snmp4j.transport.ConnectionOrientedTransportMapping<A> Creates and registers a newConnectionOrientedTransportMappingfor communicating with a master agent, bound to the given local address, and starts listening on it.voidAdds aPingListenerthat is notified about the results of the periodic ping requests sent to the master agent (seesetPingDelay(int)).intclose(AgentXSession<?> session, byte reason) Close an AgentX session.Map<AgentXSession<?>, Integer> closeAllSessions(byte reason) Close all sessions hold by this sub-agent and return the AgentX status of the close operation together with theAgentXSessionobject.protected intcloseSession(int sessionID, byte reason) Close the AgentX session with the given session ID and reason.<A extends org.snmp4j.smi.Address>
intconnect(A masterAddress, A localAddress, AgentXSession<A> session) Connect to the given AgentX master using the specified local address.<A extends org.snmp4j.smi.Address>
intconnect(A masterAddress, A localAddress, AgentXSession<A> session, List<org.snmp4j.transport.TransportStateListener> stateListeners) Connect to the given AgentX master using the specified local address.voidconnectionStateChanged(org.snmp4j.transport.TransportStateEvent transportStateEvent) protected <R extends org.snmp4j.agent.mo.MOTableRow, A extends org.snmp4j.smi.Address>
AgentXSharedMOTableSupport<R, ?> createSharedTableSupport(AgentXSession<A> session, org.snmp4j.smi.OctetString context) Create a newAgentXSharedMOTableSupportinstance for the given AgentX session and context.<A extends org.snmp4j.smi.Address>
voiddisconnect(A masterAddress) Disconnect from master and suspend any sending of packets to the given master address, before actually closing the transport used to communicate with the specified master.voiddispatchCommand(AgentXCommandEvent<?> cmd) Dispatches an incoming AgentX command event to the appropriate request handler and sends the response back to the master agent.protected voidfirePinged(PingEvent<?> event) Notifies all registeredPingListeners about the given ping event.final AgentXSession<?> Returns the first session that have been opened by this subagent and is still open.Collection<org.snmp4j.smi.OctetString> Returns all contexts supported by theMOServers registered with this sub-agent.byteGets the default priority used to register regions at the master agent.protected intGet the next AgentX transaction ID.protected bytegetPriority(org.snmp4j.agent.ManagedObject<?> mo, AgentXRegion region) Gets the priority with which the supplied managed object and region should be registered at the master agent.org.snmp4j.agent.MOServergetServer(org.snmp4j.smi.OctetString context) Returns theMOServerthat serves the given context.<A extends org.snmp4j.smi.Address>
AgentXResponseEvent<A> notify(AgentXSession<A> session, org.snmp4j.smi.OctetString context, org.snmp4j.smi.OID notificationID, org.snmp4j.smi.TimeTicks sysUpTime, org.snmp4j.smi.VariableBinding[] vbs) Send an AgentX notification to the master which will then be forwarded to trap/notification targets of the master.notify(org.snmp4j.smi.OctetString context, org.snmp4j.smi.OID notificationID, org.snmp4j.smi.TimeTicks sysUpTime, org.snmp4j.smi.VariableBinding[] vbs) notify(org.snmp4j.smi.OctetString context, org.snmp4j.smi.OID notificationID, org.snmp4j.smi.VariableBinding[] vbs) Sends notifications (traps) to all appropriate notification targets through the master agent.protected <A extends org.snmp4j.smi.Address>
intopenSession(org.snmp4j.transport.ConnectionOrientedTransportMapping<A> transport, A masterAddress, AgentXSession<A> session) Open a new AgentX session with the given transport and master address.<A extends org.snmp4j.smi.Address>
voidprocessCommand(AgentXCommandEvent<A> event) Process an AgentX message.protected voidprocessNextSubRequest(AgentXRequest request, org.snmp4j.agent.MOServer server, org.snmp4j.smi.OctetString context, AgentXRequest.AgentXSubRequest sreq) Processes a single GetNext/GetBulk sub-request by looking up the next managed object in the given server and applying it to the sub-request.protected voidprocessResponse(AgentXCommandEvent<?> cmd) Processes an AgentX response received from a master agent.protected <A extends org.snmp4j.smi.Address>
intregisterRegion(AgentXSession<A> session, org.snmp4j.smi.OctetString context, AgentXRegion region, byte priority, org.snmp4j.smi.TimeTicks sysUpTime) Registers a single AgentX region at the master agent on behalf of the given session.voidregisterRegions(AgentXSession<?> session, org.snmp4j.smi.OctetString context, org.snmp4j.smi.TimeTicks sysUpTime, RegistrationCallback registrationCallback) Registers the subagent regions at the master agent.<R extends org.snmp4j.agent.mo.MOTableRow, C extends org.snmp4j.agent.mo.MOColumn<?>, M extends org.snmp4j.agent.mo.MOTableModel<R>>
voidregisterSharedTableRows(AgentXSession<?> session, org.snmp4j.smi.OctetString context, AgentXSharedMOTable<R, C, M> mo, RegistrationCallback registrationCallback, AgentXSharedMOTableSupport<R, ?> sharedTableSupport) Registers the indexes and (row) regions of a shared table.<R extends org.snmp4j.agent.mo.MOTableRow, C extends org.snmp4j.agent.mo.MOColumn<?>, M extends org.snmp4j.agent.mo.MOTableModel<R>, A extends org.snmp4j.smi.Address>
voidregisterSharedTableRows(AgentXSession<A> session, org.snmp4j.smi.OctetString context, AgentXSharedMOTable<R, C, M> mo, RegistrationCallback registrationCallback) Deprecated.protected voidrelease(org.snmp4j.agent.MOServer server, AgentXRequest req) Releases (unlocks) all managed objects that were locked by the sub-requests of the given request on the specified server.<A extends org.snmp4j.smi.Address>
intremoveAgentCaps(AgentXSession<A> session, org.snmp4j.smi.OctetString context, org.snmp4j.smi.OID id) Removes a previously registered agent capability (sysORID) from the master agent for the given context.protected voidremoveMaster(org.snmp4j.TransportMapping<?> transport) Removes and closes the given transport mapping that was used to communicate with a master agent.voidRemoves a previously addedPingListener.<A extends org.snmp4j.smi.Address>
booleanresetConnection(A masterAddress, boolean sendClosePdu) Reset a connection not working anymore either by trying to close all open sessions with an AgentXClosePdu (when sendClosePdu is true) or silently without sending any messages.<A extends org.snmp4j.smi.Address>
booleanresumeConnecting(A masterAddress, org.snmp4j.transport.ConnectionOrientedTransportMapping<A> transportMapping) Resumes auto connection to the specified address using the given transport.protected <A extends org.snmp4j.smi.Address>
voidsendResponse(AgentXCommandEvent<A> cmd, AgentXRequest request) Sends the response PDU of the given request back to the master agent that initiated the command.voidsetDefaultPriority(byte priority) Sets the default priority used to register regions at the master agent, unlessgetPriority(ManagedObject, AgentXRegion)is overridden to return an individual priority.voidsetPingDelay(int seconds) Sets the ping delay in seconds.protected <A extends org.snmp4j.smi.Address>
intunregisterRegion(AgentXSession<A> session, org.snmp4j.smi.OctetString context, AgentXRegion region, byte timeout) Unregisters a single AgentX region at the master agent on behalf of the given session.
-
Field Details
-
requestList
The request list. -
peers
The AgentX peer agents (masters). -
sessions
The sessions hold by this sub-agent. -
requestHandlerGet
Request handler for Get requests. -
requestHandlerGetNext
Request handler for GetNext requests. -
requestHandlerGetBulk
Request handler for GetBulk requests. -
requestHandlerTestSet
Request handler for TestSet requests. -
requestHandlerCommitSet
Request handler for CommitSet requests. -
requestHandlerUndoSet
Request handler for UndoSet requests. -
requestHandlerCleanupSet
Request handler for CleanupSet requests. -
nextTransactionID
protected int nextTransactionIDThe next AgentX transaction ID to be assigned bygetNextTransactionID().
-
-
Constructor Details
-
AgentXSubagent
public AgentXSubagent(AgentX agentX, org.snmp4j.smi.OID subagentID, org.snmp4j.smi.OctetString subagentDescr, SubagentXConfigManager configManager, org.snmp4j.agent.audit.AgentAuditPolicy auditPolicy) Creates a AgentX sub-agent using aSubagentXConfigManager.- Parameters:
agentX- theAgentXprotocol to be used by this sub-agent.subagentID- the unique identifier for this subagent.subagentDescr- a textual description for this subagent.configManager- the configuration manager that organizes howManagedObjects of this subagent are initialized, persistently stored, and served to the agent.- Since:
- 3.0
-
-
Method Details
-
setPingDelay
public void setPingDelay(int seconds) Sets the ping delay in seconds. If greater than zero, for each session a ping PDU is sent to the master to validate the session regularly with the specified delay. To monitor the ping requests, it is necessary to add aPingListenerwithaddPingListener(PingListener).- Parameters:
seconds- the delay. If zero or a negative value is supplied, no pings are sent
-
processCommand
Description copied from interface:AgentXCommandListenerProcess an AgentX message.- Specified by:
processCommandin interfaceAgentXCommandListener- Type Parameters:
A-Addresstype of peer that trigger this command.- Parameters:
event- the AgentX message and necessary context information.
-
getNextTransactionID
protected int getNextTransactionID()Get the next AgentX transaction ID.- Returns:
- a unique AgentX transaction ID for this sub-agent execution runtime.
-
closeSession
Close the AgentX session with the given session ID and reason.- Parameters:
sessionID- an AgentX session ID. If such a session does not exist,AgentXProtocol.AGENTX_NOT_OPENis returned.reason- the AgentX reason (AgentXProtocol.REASON_SHUTDOWN,AgentXProtocol.REASON_TIMEOUTS,AgentXProtocol.REASON_BY_MANAGER,AgentXProtocol.REASON_PROTOCOL_ERROR,AgentXProtocol.REASON_PARSE_ERROR,AgentXProtocol.REASON_OTHER) for closing the session.- Returns:
- the error status returned by the master agent or
AgentXProtocol.AGENTX_TIMEOUTif the master did not respond in time. - Throws:
IOException- if the IO operation failed.
-
openSession
protected <A extends org.snmp4j.smi.Address> int openSession(org.snmp4j.transport.ConnectionOrientedTransportMapping<A> transport, A masterAddress, AgentXSession<A> session) throws IOException Open a new AgentX session with the given transport and master address.- Type Parameters:
A- type ofAddressfor the session's master address.- Parameters:
transport- theTransportMappingto use.masterAddress- the AgentX master agent address to connect.session- a newAgentXSession. On success, the session ID will be set to the value returned by the master.- Returns:
- the error status returned by the master agent or
AgentXProtocol.AGENTX_TIMEOUTif the master did not respond in time. - Throws:
IOException- if the IO operation failed.
-
disconnect
Disconnect from master and suspend any sending of packets to the given master address, before actually closing the transport used to communicate with the specified master.- Type Parameters:
A- theAddresstype.- Parameters:
masterAddress- the master's address to suspend and then disconnect.- Throws:
IOException- if the closing of the connection fails.- Since:
- 3.2.0
-
resumeConnecting
public <A extends org.snmp4j.smi.Address> boolean resumeConnecting(A masterAddress, org.snmp4j.transport.ConnectionOrientedTransportMapping<A> transportMapping) Resumes auto connection to the specified address using the given transport. This call does not actually send any packets to the address, instead it simply (re)activates the mechanism to automatically establish a connection to the specified address, when a new packet (i.e. openSessionPDU) is sent to the master address. Thus, callopenSession(ConnectionOrientedTransportMapping, Address, AgentXSession)immediately after calling this method to reconnect to a master, after adisconnect(Address)with suspend or aresetConnection(Address, boolean)call.- Type Parameters:
A- theAddresstype.- Parameters:
masterAddress- the master's address to disconnect and optionally suspend.transportMapping- theTransportMappingto resume.- Returns:
trueif the master address was suspended before and is resumed now,falseif resuming the master address was not necessary (i.e. is already active).- Since:
- 3.2.0
-
resetConnection
public <A extends org.snmp4j.smi.Address> boolean resetConnection(A masterAddress, boolean sendClosePdu) Reset a connection not working anymore either by trying to close all open sessions with an AgentXClosePdu (when sendClosePdu is true) or silently without sending any messages. In both cases the connection associated with the given master address is closed (withdisconnect(Address)) and all related sessions are removed and closed too.- Type Parameters:
A- theAddresstype of the connection.- Parameters:
masterAddress- the address of the peer to reset the connection.sendClosePdu-trueif this subagent should try to send AgentXClosePdus for each open session before resetting the connection offalseif the connection should be closed silently. Close PDU will be sent only if the transport is still listening.- Returns:
trueif the connection has been successfully reset,falseotherwise.- Since:
- 3.1.1
-
connect
public <A extends org.snmp4j.smi.Address> int connect(A masterAddress, A localAddress, AgentXSession<A> session) throws IOException Connect to the given AgentX master using the specified local address.- Type Parameters:
A- address type to connect to.- Parameters:
masterAddress- the (TCP) address of the master agent.localAddress- the local address. Use port 0 to letAgentXSubagentchoose an available port.session- returns theAgentXSessioninformation of the new AgentX session, i.e., the session ID returned by the * master agent.- Returns:
AgentXProtocol.AGENTX_SUCCESSif the session has been established or an AgentX error status, if not.- Throws:
IOException- if an IO operation failed.
-
connect
public <A extends org.snmp4j.smi.Address> int connect(A masterAddress, A localAddress, AgentXSession<A> session, List<org.snmp4j.transport.TransportStateListener> stateListeners) throws IOException Connect to the given AgentX master using the specified local address.- Type Parameters:
A- address type to connect to.- Parameters:
masterAddress- the (TCP) address of the master agent.localAddress- the local address. Use port 0 to letAgentXSubagentchoose an available port.session- returns theAgentXSessioninformation of the new AgentX session, i.e. the session ID returned by the master agent.stateListeners- an optional list ofTransportStateListenerto register forTransportStateEvents before the connection is being established using a newConnectionOrientedTransportMapping.- Returns:
AgentXProtocol.AGENTX_SUCCESSif the session has been established or an AgentX error status, if not.- Throws:
IOException- if an IO operation failed.- Since:
- 3.0.1
-
close
Close an AgentX session.- Parameters:
session- aAgentXSession.reason- the AgentX reason (AgentXProtocol.REASON_SHUTDOWN,AgentXProtocol.REASON_TIMEOUTS,AgentXProtocol.REASON_BY_MANAGER,AgentXProtocol.REASON_PROTOCOL_ERROR,AgentXProtocol.REASON_PARSE_ERROR,AgentXProtocol.REASON_OTHER) for closing the session.- Returns:
AgentXProtocol.AGENTX_SUCCESSif the session has been closed or an AgentX error status, if not.- Throws:
IOException- if an IO operation failed.
-
closeAllSessions
Close all sessions hold by this sub-agent and return the AgentX status of the close operation together with theAgentXSessionobject.- Specified by:
closeAllSessionsin interfaceAgentXCommandListener- Parameters:
reason- the AgentX reason (AgentXProtocol.REASON_SHUTDOWN,AgentXProtocol.REASON_TIMEOUTS,AgentXProtocol.REASON_BY_MANAGER,AgentXProtocol.REASON_PROTOCOL_ERROR,AgentXProtocol.REASON_PARSE_ERROR,AgentXProtocol.REASON_OTHER) for closing the session.- Returns:
- a map of the AgentXSession session objects hold by this agent and the corresponding AgentX error code. An
error code of
AgentXProtocol.AGENTX_SUCCESSindicates that this session was successfully closed. - Since:
- 3.0.0
-
setDefaultPriority
public void setDefaultPriority(byte priority) Sets the default priority used to register regions at the master agent, unlessgetPriority(ManagedObject, AgentXRegion)is overridden to return an individual priority.- Parameters:
priority- the priority between 0 and 255 (lower value results in higher priority).
-
getDefaultPriority
public byte getDefaultPriority()Gets the default priority used to register regions at the master agent.- Returns:
- the priority between 0 and 255 (lower value results in higher priority).
-
getPriority
Gets the priority with which the supplied managed object and region should be registered at the master agent. Overwrite this method to use individual priorities depending on the registered region/managed object. The default implementation returnsgetDefaultPriority().- Parameters:
mo- ManagedObject a managed object instance that managesregion.region- the region to be registered.- Returns:
- the priority between 0 and 255 (lower value results in higher priority).
-
registerRegions
public void registerRegions(AgentXSession<?> session, org.snmp4j.smi.OctetString context, org.snmp4j.smi.TimeTicks sysUpTime, RegistrationCallback registrationCallback) Registers the subagent regions at the master agent. It uses theAgentXSharedMOTableSupportinstances ofAgentXSharedMutableMOTableinstances. For any other instances a support object instance will be created for each session and context.- Parameters:
session- the session on whose behalf regions are registered.context- the context to use for registration.sysUpTime- if notnull, the master agent's notion of the sysUpTime for the registered context is returned. The input value is always ignored!registrationCallback- a possiblynullreference to aRegistrationCallbackinstance to handle registration events.
-
registerRegion
protected <A extends org.snmp4j.smi.Address> int registerRegion(AgentXSession<A> session, org.snmp4j.smi.OctetString context, AgentXRegion region, byte priority, org.snmp4j.smi.TimeTicks sysUpTime) throws IOException Registers a single AgentX region at the master agent on behalf of the given session.- Type Parameters:
A- theAddresstype of the session.- Parameters:
session- the session on whose behalf the region is registered. Ifnullor closed,AgentXProtocol.AGENTX_NOT_OPENis returned.context- the context to use for registration.region- theAgentXRegionto register.priority- the priority between 0 and 255 (lower value results in higher priority).sysUpTime- if notnull, the master agent's notion of the sysUpTime for the registered context is returned. The input value is always ignored.- Returns:
- the AgentX error status returned by the master agent, or
AgentXProtocol.AGENTX_NOT_OPENif the session is not open. - Throws:
IOException- if the IO operation failed.
-
unregisterRegion
protected <A extends org.snmp4j.smi.Address> int unregisterRegion(AgentXSession<A> session, org.snmp4j.smi.OctetString context, AgentXRegion region, byte timeout) throws IOException Unregisters a single AgentX region at the master agent on behalf of the given session.- Type Parameters:
A- theAddresstype of the session.- Parameters:
session- the session on whose behalf the region is unregistered. Ifnullor closed,AgentXProtocol.AGENTX_NOT_OPENis returned.context- the context that was used for registration.region- theAgentXRegionto unregister.timeout- the timeout in seconds to use for the unregister operation. If zero, the session's timeout is used.- Returns:
- the AgentX error status returned by the master agent, or
AgentXProtocol.AGENTX_NOT_OPENif the session is not open. - Throws:
IOException- if the IO operation failed.
-
addMaster
protected <A extends org.snmp4j.smi.Address> org.snmp4j.transport.ConnectionOrientedTransportMapping<A> addMaster(A localAddress, List<org.snmp4j.transport.TransportStateListener> stateListeners) throws IOException Creates and registers a newConnectionOrientedTransportMappingfor communicating with a master agent, bound to the given local address, and starts listening on it.- Type Parameters:
A- theAddresstype.- Parameters:
localAddress- the local address to bind the transport to. Use port 0 to let the transport choose an available port.stateListeners- an optional (possiblynull) list ofTransportStateListeners to register with the new transport before it starts listening.- Returns:
- the created and listening
ConnectionOrientedTransportMapping. - Throws:
IOException- if the transport could not be created or could not start listening.
-
removeMaster
protected void removeMaster(org.snmp4j.TransportMapping<?> transport) Removes and closes the given transport mapping that was used to communicate with a master agent.- Parameters:
transport- theTransportMappingto remove from theAgentXinstance and close.
-
getServer
public org.snmp4j.agent.MOServer getServer(org.snmp4j.smi.OctetString context) Returns theMOServerthat serves the given context.- Parameters:
context- the context for which the responsible server is returned.- Returns:
- the
MOServersupporting the given context, ornullif no server supports it.
-
getContexts
Returns all contexts supported by theMOServers registered with this sub-agent.- Returns:
- a collection of the
OctetStringcontext names of all servers of this sub-agent.
-
dispatchCommand
Dispatches an incoming AgentX command event to the appropriate request handler and sends the response back to the master agent. Confirmed PDUs (Get, GetNext, GetBulk, TestSet, CommitSet, UndoSet, CleanupSet, and Close) are processed here, while responses are forwarded toprocessResponse(AgentXCommandEvent).- Parameters:
cmd- theAgentXCommandEventto dispatch.
-
sendResponse
protected <A extends org.snmp4j.smi.Address> void sendResponse(AgentXCommandEvent<A> cmd, AgentXRequest request) Sends the response PDU of the given request back to the master agent that initiated the command. The session ID, transaction ID, byte order, and packet ID of the response are copied from the initiating command PDU. No response is sent if the request has no response PDU.- Type Parameters:
A- theAddresstype of the command event.- Parameters:
cmd- theAgentXCommandEventthat initiated the request.request- theAgentXRequestwhose response PDU is sent.
-
release
Releases (unlocks) all managed objects that were locked by the sub-requests of the given request on the specified server.- Parameters:
server- theMOServerthat holds the locks.req- theAgentXRequestwhose sub-requests' target managed objects are unlocked.
-
processResponse
Processes an AgentX response received from a master agent. The default implementation only logs the response at debug level. Overwrite this method to handle responses to unconfirmed PDUs.- Parameters:
cmd- theAgentXCommandEventcarrying the received response.
-
processNextSubRequest
protected void processNextSubRequest(AgentXRequest request, org.snmp4j.agent.MOServer server, org.snmp4j.smi.OctetString context, AgentXRequest.AgentXSubRequest sreq) throws NoSuchElementException Processes a single GetNext/GetBulk sub-request by looking up the next managed object in the given server and applying it to the sub-request. If no next object exists, the variable binding is set toendOfMibView.- Parameters:
request- theAgentXRequestthe sub-request belongs to.server- theMOServerto look up the next managed object in.context- the context of the request.sreq- theAgentXRequest.AgentXSubRequestto process.- Throws:
NoSuchElementException- if a required sub-request element cannot be found.
-
notify
public Object notify(org.snmp4j.smi.OctetString context, org.snmp4j.smi.OID notificationID, org.snmp4j.smi.VariableBinding[] vbs) Sends notifications (traps) to all appropriate notification targets through the master agent.- Specified by:
notifyin interfaceorg.snmp4j.agent.NotificationOriginator- Parameters:
context- the context name of the context on whose behalf this notification has been generated.notificationID- the object ID that uniquely identifies this notification. For SNMPv1 traps, the notification ID has to be build using the rules provided by RFC 2576.vbs- an array ofVariableBindinginstances representing the payload of the notification.- Returns:
- an
AgentXResponseEventinstance ornullif the notification request timed out.
-
notify
public Object notify(org.snmp4j.smi.OctetString context, org.snmp4j.smi.OID notificationID, org.snmp4j.smi.TimeTicks sysUpTime, org.snmp4j.smi.VariableBinding[] vbs) - Specified by:
notifyin interfaceorg.snmp4j.agent.NotificationOriginator
-
firstSession
Returns the first session that have been opened by this subagent and is still open. If no open session exists,nullis returned.- Returns:
- an
AgentXSession.
-
notify
public <A extends org.snmp4j.smi.Address> AgentXResponseEvent<A> notify(AgentXSession<A> session, org.snmp4j.smi.OctetString context, org.snmp4j.smi.OID notificationID, org.snmp4j.smi.TimeTicks sysUpTime, org.snmp4j.smi.VariableBinding[] vbs) throws IOException Send an AgentX notification to the master which will then be forwarded to trap/notification targets of the master.- Type Parameters:
A- address type associated with theAgentXSessionfor which the notification is created.- Parameters:
session- theAgentXSessionto be used.context- the SNMPv3 (AgentX) context of the notification.notificationID- theOIDthe identifies the notification as defined in the corresponding MIB.sysUpTime- the current notion of the sub-agents up-time.vbs- a notification payload as an array ofVariableBindinginstances.AgentXProtocol.AGENTX_SUCCESSif the session has been closed or an AgentX error status, if not.- Returns:
- a
AgentXResponseEventobject that provides detailed information about the response returned by the AgentX peer. - Throws:
IOException- if an IO operation failed.
-
addAgentCaps
public <A extends org.snmp4j.smi.Address> int addAgentCaps(AgentXSession<A> session, org.snmp4j.smi.OctetString context, org.snmp4j.smi.OID id, org.snmp4j.smi.OctetString descr) Registers an agent capability (sysORID) with the master agent for the given context.- Type Parameters:
A- theAddresstype of the session.- Parameters:
session- theAgentXSessionto use.context- the context for which the capability is registered.id- theOIDof the capability (an AGENT-CAPABILITIES OID).descr- a textual description of the capability.- Returns:
- the AgentX error status returned by the master agent, or
AgentXProtocol.AGENTX_TIMEOUTif no response was received, orAgentXProtocol.AGENTX_NOT_OPENif the PDU could not be sent.
-
removeAgentCaps
public <A extends org.snmp4j.smi.Address> int removeAgentCaps(AgentXSession<A> session, org.snmp4j.smi.OctetString context, org.snmp4j.smi.OID id) Removes a previously registered agent capability (sysORID) from the master agent for the given context.- Type Parameters:
A- theAddresstype of the session.- Parameters:
session- theAgentXSessionto use.context- the context for which the capability was registered.id- theOIDof the capability to remove.- Returns:
- the AgentX error status returned by the master agent, or
AgentXProtocol.AGENTX_NOT_OPENif the PDU could not be sent.
-
addPingListener
Adds aPingListenerthat is notified about the results of the periodic ping requests sent to the master agent (seesetPingDelay(int)).- Parameters:
l- thePingListenerto add.
-
removePingListener
Removes a previously addedPingListener.- Parameters:
l- thePingListenerto remove.
-
firePinged
Notifies all registeredPingListeners about the given ping event.- Parameters:
event- thePingEventto fire to the registered listeners.
-
connectionStateChanged
public void connectionStateChanged(org.snmp4j.transport.TransportStateEvent transportStateEvent) - Specified by:
connectionStateChangedin interfaceorg.snmp4j.transport.TransportStateListener
-
registerSharedTableRows(org.snmp4j.agent.agentx.AgentXSession, org.snmp4j.smi.OctetString, AgentXSharedMOTable, RegistrationCallback, AgentXSharedMOTableSupport)instead.