OpenNMS API 1.2.9

## org.opennms.netmgt.trapd
Class Trapd

    java.lang.Object
      org.opennms.netmgt.trapd.Trapd

All Implemented Interfaces:
  Fiber, PausableFiber, SnmpTrapHandler

public class Trapd
extends java.lang.Object
implements SnmpTrapHandler, PausableFiber

The Trapd listens for SNMP traps on the standard port(162). Creates a SnmpTrapSession and implements the SnmpTrapHandler to get callbacks when traps are received

The received traps are converted into XML and sent to eventd

Note: Trapd is a PausableFiber so as to receive control events. However, a 'pause' on Trapd has no impact on the receiving and processing of traps

Author:
  Brian Weaver , Sowmya Nataraj , Lawrence Karnowski , Mike Davidson , Tarus Balog , OpenNMS.org

Nested Class Summary
`(package private) static class` `Trapd.V1TrapInformation` V1 trap element for processing by the queue reader
`(package private) static class` `Trapd.V2TrapInformation` V2 Trap information object for processing by the queue reader

Field Summary
`private static java.lang.String` `GET_KNOWN_IPS` SQL to get already kown IPs
`private static java.lang.String` `LOG4J_CATEGORY` The name of the logging category for Trapd.
`private FifoQueue` `m_backlogQ` The communication queue
`private BroadcastEventProcessor` `m_eventReader` The class instance used to recieve new events from for the system.
`private java.util.Map` `m_knownIps` The list of known IPs
`private java.lang.String` `m_name` The name of this service.
`private TrapQueueProcessor` `m_processor` The queue processing thread
`private static Trapd` `m_singleton` The singlton instance.
`private int` `m_status` The last status sent to the service control manager.
`private SnmpTrapSession` `m_trapSession` The trap session used by Trapd to receive traps

Fields inherited from interface org.opennms.core.fiber.PausableFiber
`PAUSE_PENDING, PAUSED, RESUME_PENDING`

Fields inherited from interface org.opennms.core.fiber.Fiber
`RUNNING, START_PENDING, STARTING, STATUS_NAMES, STOP_PENDING, STOPPED`

Constructor Summary
`Trapd()` Constructs a new Trapd object that receives and forwards trap messages via JSDT.

Method Summary
`static Trapd` `getInstance()` Returns the singular instance of the trapd daemon.
`java.lang.String` `getName()` Returns the name of the service.
`int` `getStatus()` Returns the current status of the service.
`void` `init()`
`void` `pause()` Pauses Trapd
`void` `resume()` Resumes Trapd
`void` `snmpReceivedTrap(SnmpTrapSession session, java.net.InetAddress agent, int port, SnmpOctetString community, SnmpPduPacket pdu)` Process the recieved SNMP v2c trap that was received by the underlying trap session.
`void` `snmpReceivedTrap(SnmpTrapSession session, java.net.InetAddress agent, int port, SnmpOctetString community, SnmpPduTrap pdu)` Process the recieved SNMP v1 trap that was received by the underlying trap session.
`void` `snmpTrapSessionError(SnmpTrapSession session, int error, java.lang.Object ref)` Processes an error condition that occurs in the SnmpTrapSession.
`void` `start()` Create the SNMP trap session and create the JSDT communication channel to communicate with eventd.
`void` `stop()` Stops the currently running service.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### LOG4J_CATEGORY

    private static final java.lang.String LOG4J_CATEGORY

  The name of the logging category for Trapd.

  See Also:
    Constant Field Values

### GET_KNOWN_IPS

    private static final java.lang.String GET_KNOWN_IPS

  SQL to get already kown IPs

  See Also:
    Constant Field Values

### m_singleton

    private static final Trapd m_singleton

  The singlton instance.

### m_trapSession

    private SnmpTrapSession m_trapSession

  The trap session used by Trapd to receive traps

### m_name

    private java.lang.String m_name

  The name of this service.

### m_status

    private int m_status

  The last status sent to the service control manager.

### m_backlogQ

    private FifoQueue m_backlogQ

  The communication queue

### m_knownIps

    private java.util.Map m_knownIps

  The list of known IPs

### m_processor

    private TrapQueueProcessor m_processor

  The queue processing thread

### m_eventReader

    private BroadcastEventProcessor m_eventReader

  The class instance used to recieve new events from for the system.

Constructor Detail

### Trapd

    public Trapd()

  Constructs a new Trapd object that receives and forwards trap messages via JSDT. The session is initialized with the default client name of OpenNMS.trapd. The trap session is started on the default port, as defined by the SNMP libarary.

See Also:
  `SnmpTrapSession`

Method Detail

### snmpReceivedTrap

    public void snmpReceivedTrap(SnmpTrapSession session,
                                 java.net.InetAddress agent,
                                 int port,
                                 SnmpOctetString community,
                                 SnmpPduPacket pdu)

  Process the recieved SNMP v2c trap that was received by the underlying trap session.

  Specified by:
    `snmpReceivedTrap` in interface `SnmpTrapHandler`
  Parameters:
    `session` - The trap session that received the datagram.
    `agent` - The remote agent that sent the datagram.
    `port` - The remmote port the trap was sent from.
    `community` - The community string contained in the message.
    `pdu` - The protocol data unit containing the data

### snmpReceivedTrap

    public void snmpReceivedTrap(SnmpTrapSession session,
                                 java.net.InetAddress agent,
                                 int port,
                                 SnmpOctetString community,
                                 SnmpPduTrap pdu)

  Process the recieved SNMP v1 trap that was received by the underlying trap session.

  Specified by:
    `snmpReceivedTrap` in interface `SnmpTrapHandler`
  Parameters:
    `session` - The trap session that received the datagram.
    `agent` - The remote agent that sent the datagram.
    `port` - The remmote port the trap was sent from.
    `community` - The community string contained in the message.
    `pdu` - The protocol data unit containing the data

### snmpTrapSessionError

    public void snmpTrapSessionError(SnmpTrapSession session,
                                     int error,
                                     java.lang.Object ref)

  Processes an error condition that occurs in the SnmpTrapSession. The errors are logged and ignored by the trapd class.

  Specified by:
    `snmpTrapSessionError` in interface `SnmpTrapHandler`
  Parameters:
    `session` - The SNMP Trap Session
    `error` - The error condition value.
    `ref` - The PDU reference, or potentially null. It may also be an exception.

### init

    public void init()

### start

    public void start()

  Create the SNMP trap session and create the JSDT communication channel to communicate with eventd.

  Specified by:
    `start` in interface `Fiber`
  Throws:
    `java.lang.reflect.UndeclaredThrowableException` - if an unexpected database, or IO exception occurs.
  See Also:
    `SnmpTrapSession`, `SnmpTrapHandler`

### pause

    public void pause()

  Pauses Trapd

  Specified by:
    `pause` in interface `PausableFiber`

### resume

    public void resume()

  Resumes Trapd

  Specified by:
    `resume` in interface `PausableFiber`

### stop

    public void stop()

  Stops the currently running service. If the service is not running then the command is silently discarded.

  Specified by:
    `stop` in interface `Fiber`

### getStatus

    public int getStatus()

  Returns the current status of the service.

  Specified by:
    `getStatus` in interface `Fiber`
  Returns:
    The service's status.

### getName

    public java.lang.String getName()

  Returns the name of the service.

  Specified by:
    `getName` in interface `Fiber`
  Returns:
    The service's name.

### getInstance

    public static Trapd getInstance()

  Returns the singular instance of the trapd daemon. There can be only one instance of this service per virtual machine.

OpenNMS API 1.2.9

Generated by ranger on May 19 2007 2335.