Package com.ibm.di.connector
Class SNMPConnector
- java.lang.Object
-
- com.ibm.di.connector.Connector
-
- com.ibm.di.connector.SNMPConnector
-
- All Implemented Interfaces:
ConnectorInterface
,VersionInfoInterface
,com.tivoli.snmp.TrapFilter
,com.tivoli.snmp.TrapListener
,java.io.Serializable
public class SNMPConnector extends Connector implements com.tivoli.snmp.TrapListener, com.tivoli.snmp.TrapFilter
The SNMPConnector implements get/set/walk and trap-receive operations by means of the IBM Tivoli SNMP Stack.The connector can operate in two modes: Client and Trap Receiver - Client Mode
In client mode you can use it in iterator mode where the connector will send a getnext request to the snmp agent and return one entry for each OID returned by the agent. In Lookup mode the connector will perform a get request returning the oid/value for the requested oid. The link criteria specifies: oid and optionally server, port and version.
- Trap Receiver Mode
In trap receiver mode the connector can only be used in Iterator mode. The connector will listen for incoming snmp traps and return each as an entry to the caller. Both V1, V2c and V3 traps are handled.
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class com.ibm.di.connector.Connector
ALL_MODES, myLog, PROPERTY_MESSAGE, PROPERTY_READER, PROPERTY_WRITER
-
-
Constructor Summary
Constructors Constructor Description SNMPConnector()
" Constructor for the SNMPConnector object
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
filter(com.tivoli.snmp.SnmpTrap trap)
Indicates that trap should be sent to this connector.Entry
findEntry(SearchCriteria search)
Searches for an entry matching the specified search criteria.Entry
getNextEntry()
Gets the nextEntry attribute of the SNMPConnector objectjava.lang.String
getVersion()
Version information.void
handle(com.tivoli.snmp.SnmpTrap trap)
Trap listenervoid
initialize(java.lang.Object o)
This methods initializes the SNMP API library, reads the Connector configurations parameters, subscribes for SNMP Traps and opens an SNMP session.void
putEntry(Entry entry)
Send SNMP data.void
reconnect()
Reconnect to the underlying data source.Entry
returnEntry(java.lang.Object obj)
Checks the type of the given object.void
selectEntries()
This method initializes the SNMP PDU (protocol data unit) to be sent on all subsequent getNextEntry calls as part of the get next request.void
sendTrap(Entry entry)
Send a SNMP trap using the given Entryvoid
terminate()
This method unsubscribes from SNMP Trap events, terminates the SNMP API library, i.e.-
Methods inherited from class com.ibm.di.connector.Connector
addFindEntry, allModes, clearFindEntries, debug, debugMode, deleteEntry, extractExceptionInformation, findEntry, getBoolean, getClassInstance, getConfiguration, getContext, getFindEntryCount, getFirstFindEntry, getLog, getMaxDuplicateEntries, getModes, getModes, getName, getNextClient, getNextFindEntry, getParam, getParser, getProperty, getPushbackEntry, getRawConnectorConfiguration, getRSInterface, getUI, hasConfigValue, hasParser, initParser, isDeltaSupported, isExceptionFatal, isIOException, logError, logmsg, modEntry, modEntry, pushback, queryOperations, queryReply, querySchema, queryTables, reconnect, registerScriptBeans, replyEntry, setConfiguration, setContext, setCurrent, setDebugMode, setLog, setMaxDuplicateEntries, setModes, setModes, setName, setParam, setParser, setProperty, setRSInterface, terminateServer
-
-
-
-
Method Detail
-
getVersion
public java.lang.String getVersion()
Version information.- Specified by:
getVersion
in interfaceVersionInfoInterface
- Returns:
- version information
-
getNextEntry
public Entry getNextEntry() throws java.lang.Exception
Gets the nextEntry attribute of the SNMPConnector object- Specified by:
getNextEntry
in interfaceConnectorInterface
- Overrides:
getNextEntry
in classConnector
- Returns:
- The nextEntry value
- Throws:
java.lang.Exception
- An exception is thrown if this method fails.- See Also:
ConnectorInterface.selectEntries()
-
returnEntry
public Entry returnEntry(java.lang.Object obj) throws java.lang.Exception
Checks the type of the given object. If it is an Entry, it casts it to an Entry and returns it.- Parameters:
obj
- String, Entry or Exception.- Returns:
- returns null if a String is passed. Otherwise if an Entry is passed returns the Object cast to Entry.
- Throws:
java.lang.Exception
- If the object is an Exception or is not an instance of the above classes, an Exception is thrown.
-
initialize
public void initialize(java.lang.Object o) throws java.lang.Exception
This methods initializes the SNMP API library, reads the Connector configurations parameters, subscribes for SNMP Traps and opens an SNMP session.- Specified by:
initialize
in interfaceConnectorInterface
- Overrides:
initialize
in classConnector
- Parameters:
o
- An object the AssemblyLine passes to the Connector on init- Throws:
java.lang.Exception
- An exception is thrown if this method fails.
-
terminate
public void terminate()
This method unsubscribes from SNMP Trap events, terminates the SNMP API library, i.e. this method cleans up.- Specified by:
terminate
in interfaceConnectorInterface
- Overrides:
terminate
in classConnector
-
selectEntries
public void selectEntries() throws java.lang.Exception
This method initializes the SNMP PDU (protocol data unit) to be sent on all subsequent getNextEntry calls as part of the get next request.- Specified by:
selectEntries
in interfaceConnectorInterface
- Overrides:
selectEntries
in classConnector
- Throws:
java.lang.Exception
- An exception is thrown if this method fails.
-
findEntry
public Entry findEntry(SearchCriteria search) throws java.lang.Exception
Searches for an entry matching the specified search criteria.- Specified by:
findEntry
in interfaceConnectorInterface
- Overrides:
findEntry
in classConnector
- Parameters:
search
- the search criteria- Returns:
- the entry found
- Throws:
java.lang.Exception
- An exception is thrown if this method fails.
-
putEntry
public void putEntry(Entry entry) throws java.lang.Exception
Send SNMP data.- Specified by:
putEntry
in interfaceConnectorInterface
- Overrides:
putEntry
in classConnector
- Parameters:
entry
- an entry containing the SNMP data to send- Throws:
java.lang.Exception
- An exception is thrown if this method fails.
-
sendTrap
public void sendTrap(Entry entry) throws java.io.IOException
Send a SNMP trap using the given Entry- Parameters:
entry
-- Throws:
java.io.IOException
-
filter
public boolean filter(com.tivoli.snmp.SnmpTrap trap)
Indicates that trap should be sent to this connector.- Specified by:
filter
in interfacecom.tivoli.snmp.TrapFilter
- Parameters:
trap
- theSnmpTrap
object.- Returns:
- true
-
handle
public void handle(com.tivoli.snmp.SnmpTrap trap)
Trap listener- Specified by:
handle
in interfacecom.tivoli.snmp.TrapListener
- Parameters:
trap
- The SNMP trap to be handled
-
reconnect
public void reconnect() throws java.lang.Exception
Reconnect to the underlying data source.- Overrides:
reconnect
in classConnector
- Throws:
java.lang.Exception
- if an error occurs.- See Also:
Connector.initialize(Object)
-
-