Class 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
    • Constructor Detail

      • SNMPConnector

        public SNMPConnector()
        " Constructor for the SNMPConnector object
    • Method Detail

      • getVersion

        public java.lang.String getVersion()
        Version information.
        Specified by:
        getVersion in interface VersionInfoInterface
        Returns:
        version information
      • 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 interface ConnectorInterface
        Overrides:
        initialize in class Connector
        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 interface ConnectorInterface
        Overrides:
        terminate in class Connector
      • 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 interface ConnectorInterface
        Overrides:
        selectEntries in class Connector
        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 interface ConnectorInterface
        Overrides:
        findEntry in class Connector
        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 interface ConnectorInterface
        Overrides:
        putEntry in class Connector
        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 interface com.tivoli.snmp.TrapFilter
        Parameters:
        trap - the SnmpTrap object.
        Returns:
        true
      • handle

        public void handle​(com.tivoli.snmp.SnmpTrap trap)
        Trap listener
        Specified by:
        handle in interface com.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 class Connector
        Throws:
        java.lang.Exception - if an error occurs.
        See Also:
        Connector.initialize(Object)