|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.adventnet.snmp.snmp2.agent.Cache
com.adventnet.snmp.snmp2.agent.BaseSnmpStore
com.adventnet.snmp.snmp2.agent.BaseSnmpTrapService
public class BaseSnmpTrapService
Used to send traps
Use setUsesSeperateSession(false) to have a same Session which shares with the Agent for sending traps. By default uses separate session for sending Traps. The default implementation requires the Agent (or the source bean for SnmpPduRequestEvent) to be alive
Provides a low level API to send traps
Listener component for TrapRequestEvents doesn't provide MIB support ie API users would need to explicitly fill the Trap details which needs to be sent.
Based on the Event parameters a BaseTrapForwardingTable is used for sending Traps If the agent acts as a standalone agent then the trap is send through SnmpSession for the registered managers in the table maintained by this BaseSnmpTrapService.
Both SnmpTrapService and MicroSnmpTrapService
extend this class.
SnmpTrapService,
MicroSnmpTrapService,
BaseSnmpAgent,
SnmpAgent,
TrapForwardingTableInterface,
TrapRequestEvent,
Serialized Form| Field Summary | |
|---|---|
(package private) java.lang.String |
agentAddr
|
(package private) java.lang.String |
community
|
(package private) SnmpOID |
enterprise
|
(package private) BaseForwardingTable |
forTable
|
(package private) BaseTrapForwardingTable |
hdlr
|
protected boolean |
isInformRequest
|
(package private) RegistrationListener |
listener
|
(package private) java.lang.String |
managerHost
|
(package private) int |
managerPort
|
(package private) int |
rowIndex
|
boolean |
selectedPort
|
(package private) int |
sessionPort
|
protected Log |
snmpLog
|
(package private) TrapForwardingTableInterface |
tfTable
|
(package private) int |
trapIndex
|
(package private) SnmpPDU |
trapPDU
|
(package private) boolean |
trapSource
|
(package private) boolean |
trapSourceDefault
|
(package private) java.util.Vector |
varb
|
(package private) int |
version
|
| Fields inherited from class com.adventnet.snmp.snmp2.agent.BaseSnmpStore |
|---|
debugLevel, oldAddress, oldPort, protocol, session |
| Fields inherited from class com.adventnet.snmp.snmp2.agent.Cache |
|---|
cache, debug |
| Constructor Summary | |
|---|---|
BaseSnmpTrapService()
no arg constructor which uses the separate SnmpSession. |
|
BaseSnmpTrapService(int port)
The port Constructor so that the Traps will be sent throgh the Session opened at the specified Port. |
|
BaseSnmpTrapService(java.lang.String ipAddress,
int port)
The ipAddress, port Constructor so that the Traps will be sent through the Session opened at the specified Port and Address. |
|
| Method Summary | |
|---|---|
void |
addRegistrationListener(RegistrationListener l)
adds the registration listener for this bean.This listener maintains the registration tree where VarBindRequestListeners can register for their interested OID. |
protected void |
addSnmpV1TrapHeader(SnmpPDU pdu,
SnmpSession session,
SnmpOID enterprise,
int trapIndex,
long timeticks)
Adds Trap Header in Snmp Version 1 model |
protected void |
addSnmpV2TrapHeader(SnmpPDU pdu,
SnmpSession session,
SnmpOID enterprise,
int trapIndex,
long timeticks)
Adds Trap Header in Snmp Version 2 model |
void |
addTrapRequest(TrapRequestEvent te)
This is the listener method for TrapRequestEvents. |
void |
closeTrapSession()
closes the TrapSession if open |
ProtocolOptions |
createProtocolOptions(java.lang.String remoteHost,
int remotePort,
int localPort)
This method will be called when by the SnmpSession to get the ProtocolOptions for the transport provider. |
void |
disableAuthTraps(boolean auth)
|
protected void |
doRegistration()
Does the Registration of the TrapForwarding Table to the PduRequestHandler Tree. |
java.lang.String |
getAgentAddr()
Getter for agent address. |
java.lang.String |
getCommunity()
Getter for community to be used. |
java.lang.String |
getEnterpriseOID()
Getter for enterprise OID |
boolean |
getInformFlag()
Method to get the Inform flag. |
java.lang.String |
getLocalAddress()
Getter for the Address which sends the Trap |
java.lang.String |
getManagerHost()
Getter for managerHost default localhost The source of this information could also be specified in form of ACL files or by simple TrapForwarding Table Typical TrapRequestEvent listeners would look at this values when the source value returned is DEFAULT |
int |
getManagerPort()
Getter for managerPort The source of this information could also be specified in form of ACL files or by simple TrapForwarding Table Typical TrapRequestEvent listeners would look at this values when the source value returned is DEFAULT |
TrapForwardingTableInterface |
getTrapForwardingTable()
Gets the BaseTrapForwardingTable which is used by this TrapRequestListener. |
int |
getTrapIndex()
trapIndex value this could either be generic or enterpise specific value which is decided by the enterprise OID which is set by the user |
protected SnmpSession |
getTrapSession()
Method to retrieve the Trap Session used by this TrapService. |
java.util.Vector |
getVarbind()
Getter for varbind. |
int |
getVersion()
Getter of SNMP version of trap events. |
protected SnmpSession |
initSeperateTrapSession()
This method initialises a seperate session for sending TRAPs. |
boolean |
isTrapSessionAlive()
This method checks for if session being used by the Trap Service is alive. |
boolean |
isTrapSourceDefault()
Getter of TrapSourceDefault value |
boolean |
isUsesSeperateSession()
getter for flag which indicates whether the Session is used is the same as the Session used by agent |
protected boolean |
oidEqualsSnmp(int[] oid)
A Checker for enterprise OID to be equal to the SNMP OID |
protected boolean |
oidEqualsSnmp(SnmpOID oid)
A Checker for enterprise OID to be equal to the SNMP OID |
protected void |
printDecodedPDU(SnmpPDU pdu)
|
void |
removeRegistrationListener(RegistrationListener l)
removes the registration listener for this bean. |
void |
sendTrap()
Default sendTrap method which sends traps based on the properties set in the Service. |
void |
sendTrap(java.lang.Long timeticks)
sendTrap with properties in the service and timeticks value(Agent UpTime) |
void |
sendTrap(java.lang.Object entry,
SnmpOID enterprise,
java.lang.String community,
int trapIndex,
long timeticks,
java.util.Vector varbindVector)
send the Trap to the managers in the TrapForwarding Table |
protected void |
sendTrap(SnmpPDU pdu,
java.lang.String managerNode,
int managerPort,
java.lang.String community)
Used to send SNMPV1 and SNMPV2 Traps This is low_level method which API users can use to send trap. |
void |
sendTrap(java.lang.String managerNode,
int managerPort,
SnmpOID enterprise,
java.lang.String community,
int trapIndex,
long timeticks,
java.util.Vector varbindVector,
int version)
Used to send SNMPV1 & SNMPV2 traps This is low_level method which API users can use to send trap. |
void |
sendTrap(TrapRequestEvent ev)
this method just calls addTrapRequest(ev); |
protected void |
sendTrapDefault(TrapRequestEvent te)
|
protected void |
sendTrapToManagers(TrapRequestEvent te)
|
protected void |
sendTrapToManagersInTable(SnmpOID enterprise,
java.lang.String community,
int trapIndex,
long timeticks,
java.util.Vector varbindings,
int version)
send the Trap to the managers in the TrapForwarding Table |
void |
setAgentAddr(java.lang.String agentAddr)
Setter for agent address - This has to be set to send the AgentAddress along with the SnmpV1 Traps |
void |
setCommunity(java.lang.String community)
Setter for community to be used. |
void |
setDebug(boolean val)
Deprecated. use Logging. sets the debug messages true for SnmpAPI. |
void |
setDefaultTrap(boolean isDefault)
This method switches the trapSource (DEFAULT/TFTABLE) ie, specifies whether the manager to which the trap to be sent must be taken from TFTABLE / DEFAULT. |
void |
setEnterpriseOID(java.lang.String oid)
Setter for enterprise OID |
void |
setForwardingEntryOID(java.lang.String oid)
Sets the TrapForwardingEntry oid. |
void |
setHandler(BaseTrapForwardingTable handler)
Method to set the BaseTrapForwardingTable Handler for this TrapService. |
void |
setInformFlag(boolean ir)
Setter for this TrapSerive to send Inform requests. |
void |
setLocalAddress(java.lang.String localAddress)
Sets the address of the agent which sends the trap |
void |
setManagerHost(java.lang.String managerHost)
Setter for managerHost |
void |
setManagerPort(int managerPort)
Setter for managerPort |
void |
setProtocol(int protocol)
To set the protocol to be used by the session. |
void |
setTrapForwardingTable(TrapForwardingTableInterface intf)
Sets the TrapForwardingTable which is used by this TrapRequestListener By default the BaseSnmpTrapService maintains a TrapTable which takes the default managers from a text file under the directory "conf". |
void |
setTrapIndex(int value)
setter for the trapIndex |
void |
setTrapSession(SnmpSession session)
Sets the session being used by the service as specified in the param. |
protected void |
setTrapSessionPort(int aport)
|
void |
setTrapSourceDefault(boolean trapSourceDefault)
Deprecated. use the method setDefaultTrap(boolean isDefault) Setter for the TrapSourceDefault value. |
void |
setUsesSeperateSession(boolean val)
This method must be set when you would like a seperate session to be to be started for sending traps. |
void |
setVarbind(java.util.Vector varb)
Setter for varbind |
void |
setVersion(int version)
Setter for version of this TrapRequest |
boolean |
validateTrap(SnmpPDU pdu,
java.lang.String managerHost,
int managerPort)
This is the Dummy Method added, to be Overwritten by the User to Validate the Traps that is sent from the Agent by adding a new class extending the SnmpTrapService. |
| Methods inherited from class com.adventnet.snmp.snmp2.agent.BaseSnmpStore |
|---|
closeAll, finalize, getSnmpAPI, getSnmpSession, getSnmpSession, initSession, initSnmpStore, isAlive, isDebug, killSnmpAgent |
| Methods inherited from class com.adventnet.snmp.snmp2.agent.Cache |
|---|
getFromCache, getMibOperations, putInCache, setMibOperations |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected boolean isInformRequest
public boolean selectedPort
SnmpPDU trapPDU
boolean trapSourceDefault
TrapForwardingTableInterface tfTable
BaseForwardingTable forTable
boolean trapSource
int rowIndex
int version
SnmpOID enterprise
int trapIndex
java.lang.String community
java.lang.String managerHost
int managerPort
java.lang.String agentAddr
java.util.Vector varb
RegistrationListener listener
BaseTrapForwardingTable hdlr
protected Log snmpLog
int sessionPort
| Constructor Detail |
|---|
public BaseSnmpTrapService()
public BaseSnmpTrapService(int port)
port - the int value of the port from where the Traps are to be
sent.
public BaseSnmpTrapService(java.lang.String ipAddress,
int port)
port - the int value of the port from where the Traps are to be sent.ipAddress - String denoting the ipAddress to which the TrapSession
has to be bound.| Method Detail |
|---|
public void setTrapSourceDefault(boolean trapSourceDefault)
trapSourceDefault - specifies the handling the TrapForwarding
using DEFAULT(true) option or the TFTABLE(false) optionpublic void setDefaultTrap(boolean isDefault)
value - The Default option flag, if true the Default option is
taken.isTrapSourceDefault()public boolean isTrapSourceDefault()
public void setDebug(boolean val)
BaseSnmpStore
setDebug in class BaseSnmpStoreval - true or false .SnmpAPIpublic void setTrapForwardingTable(TrapForwardingTableInterface intf)
For example to make a manager entry remotely,
API users can have their own trapForwardingTable and call this method.
intf - the TrapForwardingTableInterfacepublic TrapForwardingTableInterface getTrapForwardingTable()
public void addTrapRequest(TrapRequestEvent te)
addTrapRequest in interface TrapRequestListenerte - the trap eventTrapRequestEventpublic boolean isUsesSeperateSession()
public void setUsesSeperateSession(boolean val)
val - yes for seperate session for Traps no for share the
the same session.public void setTrapSession(SnmpSession session)
session - the SnmpSessionprotected boolean oidEqualsSnmp(SnmpOID oid)
oid - enterpise OID which needs to be checked
protected boolean oidEqualsSnmp(int[] oid)
public void sendTrap(java.lang.String managerNode,
int managerPort,
SnmpOID enterprise,
java.lang.String community,
int trapIndex,
long timeticks,
java.util.Vector varbindVector,
int version)
managerNode - The Manager HostmanagerPort - The Manager Port to send the Trapenterprise - Enterprise Oidcommunity - The community with which the Trap is to be senttrapIndex - The TrapIndex of the Traptimeticks - The Agent upTimevarbind - Vector of SnmpVarBind variablesversion - SnmpTrap version to be sent.SnmpAPI,
SnmpVarBind
protected void sendTrap(SnmpPDU pdu,
java.lang.String managerNode,
int managerPort,
java.lang.String community)
pdu - The enterprise SNMP PDUmanagerNode - The Manager HostmanagerPort - The Manager Port to which the Trap is to be sentcommunity - The community with which the Trap is to be sentSnmpPDUprotected void printDecodedPDU(SnmpPDU pdu)
protected void addSnmpV1TrapHeader(SnmpPDU pdu,
SnmpSession session,
SnmpOID enterprise,
int trapIndex,
long timeticks)
protected void addSnmpV2TrapHeader(SnmpPDU pdu,
SnmpSession session,
SnmpOID enterprise,
int trapIndex,
long timeticks)
public java.lang.String getLocalAddress()
public void setLocalAddress(java.lang.String localAddress)
localAddress - The hostName or the IP of the machine which sends the trappublic void setProtocol(int protocol)
protocol - the protocol to be used for transport. To use the user
specifed
transport layer this param value should be SnmpAgent.TRANSPORT_PROVIDER
public ProtocolOptions createProtocolOptions(java.lang.String remoteHost,
int remotePort,
int localPort)
createProtocolOptions in class BaseSnmpStoreremoteHost - the remoteHost name. For agent session this value will
be null. For SnmpTrapService session, this has the manager's host name.remotePort - the remotePort value. For agent session this value
will be 0. For SnmpTrapService session, this has the manager's port
number.localPort - the port number of the session by which the agent will be started.
protected SnmpSession initSeperateTrapSession()
protected SnmpSession getTrapSession()
public void closeTrapSession()
public void sendTrap()
public void sendTrap(java.lang.Long timeticks)
timeticks - timer valuepublic void sendTrap(TrapRequestEvent ev)
te - The TrapRequestEvent object.addTrapRequest(TrapRequestEvent)public boolean isTrapSessionAlive()
protected void sendTrapToManagersInTable(SnmpOID enterprise,
java.lang.String community,
int trapIndex,
long timeticks,
java.util.Vector varbindings,
int version)
enterprise - The enterprise OIDcommunity - The community with which the Trap is to be senttrapIndex - The Trap Index of the Trap to be senttimeticks - The Agent UpTimevarbindings - The varBind Vectorversion - The Snmp Version of the Trapprotected void sendTrapToManagers(TrapRequestEvent te)
protected void sendTrapDefault(TrapRequestEvent te)
public int getVersion()
constant values for valid
version settingspublic void setVersion(int version)
the - SNMP versionpublic java.lang.String getEnterpriseOID()
public void setEnterpriseOID(java.lang.String oid)
enterprise - OIDpublic int getTrapIndex()
public void setTrapIndex(int value)
value - the trap index.public java.lang.String getCommunity()
public void setCommunity(java.lang.String community)
community - value of the communitypublic java.lang.String getManagerHost()
public void setManagerHost(java.lang.String managerHost)
managerHost - the host namepublic int getManagerPort()
setManagerPort(int managerPort)public void setManagerPort(int managerPort)
the - manager port numbergetManagerPort()public java.lang.String getAgentAddr()
setAgentAddr(String agentAddr)public void setAgentAddr(java.lang.String agentAddr)
agentAddr - agent addressgetAgentAddr()public java.util.Vector getVarbind()
setVarbind(Vector varb)public void setVarbind(java.util.Vector varb)
varb - vector contains the varbindgetVarbind()public void addRegistrationListener(RegistrationListener l)
l - the registration listener to whom the SnmpTrapService
registers the TrapForwardingTable(VarBindRequestListener).removeRegistrationListener(RegistrationListener l)public void removeRegistrationListener(RegistrationListener l)
l - the registration listener to whom the SnmpTrapService
registers the TrapForwardingTable(VarBindRequestListener).addRegistrationListener(RegistrationListener l)public void setForwardingEntryOID(java.lang.String oid)
oid - ex:- .1.3.6.1.4.1.2162.10.3.1.2.2.1.1 The Entry OID of the
V1V2TrapForwarding Table in the AGENT-SNMP-CONFIG-MIB.protected void doRegistration()
public void setHandler(BaseTrapForwardingTable handler)
handler - The BaseTrapForwardingTable instance.
public void sendTrap(java.lang.Object entry,
SnmpOID enterprise,
java.lang.String community,
int trapIndex,
long timeticks,
java.util.Vector varbindVector)
entry - the Forwarding Entry Object for which the
Trap is to be sent.enterprise - The enterprise OIDcommunity - The community with which the Trap is to be senttrapIndex - The Trap Index of the Trap to be senttimeticks - The Agent UpTimevarbindings - The varBind Vectorversion - The Snmp Version of the Trapprotected void setTrapSessionPort(int aport)
public boolean validateTrap(SnmpPDU pdu,
java.lang.String managerHost,
int managerPort)
The method to Validate the Traps. This will get called before the sendTrap method Sends the Traps to the Managers in the TFTable. Users have to Instrument the validating conditions in this method fulfilling their requirement.
pdu - The Trap SnmpPDU.managerNode - The ManagerHost for which the Trap is targeted.managerPort - The ManagerPort for which the Trap is targeted.public void setInformFlag(boolean ir)
ir - true to send Inform Requests.public boolean getInformFlag()
public void disableAuthTraps(boolean auth)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||