OpenNMS API 1.2.3

org.opennms.netmgt.collectd
Class SnmpNodeCollector

java.lang.Object
  extended byorg.opennms.netmgt.collectd.SnmpNodeCollector
All Implemented Interfaces:
SnmpHandler

public class SnmpNodeCollector
extends java.lang.Object
implements SnmpHandler

The SnmpNodeCollector class is responsible for performing the actual SNMP data collection for a node over a specified network interface. The SnmpNodeCollector implements the SnmpHandler class in order to receive notifications when an SNMP reply is received or error occurs. The SnmpNodeCollector is provided a list of MIB objects to collect and an interface over which to collect the data. Data collection can be via SNMPv1 GetNext requests or SNMPv2 GetBulk requests depending upon the parms used to construct the collector.

Version:
1.1.1.1
Author:
Mike , Jon Whetzel , OpenNMS

Field Summary
private  SNMPCollectorEntry m_collectorEntry
          Used to store the collected MIB data.
private  boolean m_error
          Flag indicating the success or failure of the informational query.
private  int m_errorIndex
          If the SNMP collection failed due to a problem with one or more varbinds (for example if a particular object oid is requested which is not implemented in the target's SNMP agent) then this value will be set equal to the *first* failing varbind in the request.
private  int m_errorStatus
          Reason that the SNMP request failed.
private static java.lang.String[] m_errorText
          Array of SNMPv1 error strings.
private  int m_maxVarsPerPdu
          Max number of variables permitted in a single outgoing SNMP PDU request..
private  java.util.List m_objList
          List of MibObject objects to be collected.
private  int m_oidListIndex
          Initialized to zero.
private  java.lang.String m_primaryIf
          Holds the IP Address of the primary SNMP iterface.
private  Signaler m_signal
          Used to synchronize the class to ensure that the session has finished collecting data before the value of success or failure is set, and control is returned to the caller.
private  boolean m_timeout
          Flag indicating if the SNMP collection failed due to the SNMP request timing out.
private  int m_version
          Used for classifying the SNMP version of the session.
 
Constructor Summary
private SnmpNodeCollector()
          The default constructor is marked private and will always throw an exception.
  SnmpNodeCollector(SnmpSession session, Signaler signaler, java.util.List objList, int maxVarsPerPdu)
          The class constructor is used to initialize the collector and send out the initial SNMP packet requesting data.
 
Method Summary
 boolean failed()
          Returns the success or failure code for collection of the data.
 SNMPCollectorEntry getEntry()
          Returns the list of all entry maps that can be used to access all the information from the service polling.
 SnmpPduPacket getNextPdu(java.lang.String ifAddress)
          This method constructs the next SnmpPduPacket (pdu) for sending to the remote node.
 void snmpInternalError(SnmpSession session, int error, SnmpSyntax pdu)
          This method is part of the SnmpHandler interface and called when an internal error happens in a session.
 void snmpReceivedPdu(SnmpSession session, int command, SnmpPduPacket pdu)
          This method is used to process received SNMP PDU packets from the remote agent.
 void snmpTimeoutError(SnmpSession session, SnmpSyntax pdu)
          This method is part of the SnmpHandler interface and is invoked when the SnmpSession does not receive a reply after exhausting the retransmission attempts.
static SnmpObjectId stop_oid(java.lang.String oid)
          This method will take an OID, and generate the succeeding OID.
 boolean timedout()
          Returns true if SNMP collection failed due to timeout.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_error

private boolean m_error
Flag indicating the success or failure of the informational query. If the flag is set to false then either part of all of the information was unable to be retreived. If it is set to true then all of the data was received from the remote host.


m_errorStatus

private int m_errorStatus
Reason that the SNMP request failed. Please see org.opennms.protocols.snmp.SnmpPduPacket class for a list of possible SNMP error codes. This variable only has meaning of m_error flag is true.


m_errorText

private static java.lang.String[] m_errorText
Array of SNMPv1 error strings. Please see org.opennms.protocols.snmp.SnmpPduPacket class for list of SNMP error codes which serve as indices into this string array.


m_errorIndex

private int m_errorIndex
If the SNMP collection failed due to a problem with one or more varbinds (for example if a particular object oid is requested which is not implemented in the target's SNMP agent) then this value will be set equal to the *first* failing varbind in the request. This variable only has meaning if m_error flag is true. Will be set to -1 if the SNMP collection failed for an unrelated reason.


m_timeout

private boolean m_timeout
Flag indicating if the SNMP collection failed due to the SNMP request timing out. Its value only has meaning if m_error flag is true.


m_signal

private Signaler m_signal
Used to synchronize the class to ensure that the session has finished collecting data before the value of success or failure is set, and control is returned to the caller.


m_objList

private java.util.List m_objList
List of MibObject objects to be collected.


m_oidListIndex

private int m_oidListIndex
Initialized to zero. As each response PDU is received this value is incremented by the number of vars contained in the response. Processing will continue until this value reaches the total number of oids in the MibObject list (m_olbjList) and all oid values have been retrieved.


m_collectorEntry

private SNMPCollectorEntry m_collectorEntry
Used to store the collected MIB data.


m_version

private int m_version
Used for classifying the SNMP version of the session.


m_primaryIf

private java.lang.String m_primaryIf
Holds the IP Address of the primary SNMP iterface.


m_maxVarsPerPdu

private int m_maxVarsPerPdu
Max number of variables permitted in a single outgoing SNMP PDU request..

Constructor Detail

SnmpNodeCollector

private SnmpNodeCollector()
                   throws java.lang.UnsupportedOperationException
The default constructor is marked private and will always throw an exception. This is done to disallow the default constructor. The reason is that this object requires several arguments to perform it's duties.

Throws:
java.lang.UnsupportedOperationException - Always thrown from this method since it is not supported.

SnmpNodeCollector

public SnmpNodeCollector(SnmpSession session,
                         Signaler signaler,
                         java.util.List objList,
                         int maxVarsPerPdu)
The class constructor is used to initialize the collector and send out the initial SNMP packet requesting data. The data is then received and store by the object. When all the data has been collected the passed signaler object is notified using the notifyAll() method.

Parameters:
session - The SNMP session with the remote agent.
signaler - The object signaled when data collection is done.
objList - The list of object id's to be collected.
maxVarsPerPdu - Max number of vars permitted in a single PDU
Method Detail

stop_oid

public static SnmpObjectId stop_oid(java.lang.String oid)
This method will take an OID, and generate the succeeding OID. This will be used for examining responses from SNMPv2 GETBULK packets when doing SNMPv2 collection, so that we can keep all the data for a particular object, and throw out the rest.

Parameters:
oid - Object identifier from which to generate the stop oid
Returns:
SnmpObjectId object which represents the oid on which to stop the bulk collection.

getNextPdu

public SnmpPduPacket getNextPdu(java.lang.String ifAddress)
This method constructs the next SnmpPduPacket (pdu) for sending to the remote node. The version of SNMP supported will determine whether a GET or GETBULK PDU is built. For SNMPv1, GET commands are built. Each constructed PDU contains varbinds for all the objects to be collected. For SNMPv2, GETBULK commands are built. Each constructed PDU contains varbinds for all the objects to be collected.

Parameters:
ifAddress - Interface address of the remote agent
Returns:
An SnmpPduPacket appropriate for the SNMP version supported.
See Also:
SnmpNull, SnmpPduPacket

snmpReceivedPdu

public void snmpReceivedPdu(SnmpSession session,
                            int command,
                            SnmpPduPacket pdu)
This method is used to process received SNMP PDU packets from the remote agent. The method is part of the SnmpHandler interface and will be invoked when a PDU is successfully decoded. The method is passed the receiving session, the PDU command, and the actual PDU packet. When all the data has been received from the session the signaler object, initialized in the constructor, is signaled. In addition, the receiving instance will call notifyAll() on itself at the same time.

Specified by:
snmpReceivedPdu in interface SnmpHandler
Parameters:
session - The SNMP Session that received the PDU
command - The command contained in the received pdu
pdu - The actual received PDU.

snmpInternalError

public void snmpInternalError(SnmpSession session,
                              int error,
                              SnmpSyntax pdu)
This method is part of the SnmpHandler interface and called when an internal error happens in a session. This is usually the result of an I/O error. This method will not be called if the session times out sending a packet, see snmpTimeoutError for timeout handling.

Specified by:
snmpInternalError in interface SnmpHandler
Parameters:
session - The session that had an unexpected error
error - The error condition
pdu - The PDU being sent when the error occured
See Also:
snmpTimeoutError(org.opennms.protocols.snmp.SnmpSession, org.opennms.protocols.snmp.SnmpSyntax), SnmpHandler

snmpTimeoutError

public void snmpTimeoutError(SnmpSession session,
                             SnmpSyntax pdu)
This method is part of the SnmpHandler interface and is invoked when the SnmpSession does not receive a reply after exhausting the retransmission attempts.

Specified by:
snmpTimeoutError in interface SnmpHandler
Parameters:
session - The session invoking the error handler
pdu - The PDU that the remote failed to respond to.
See Also:
SnmpHandler

failed

public boolean failed()
Returns the success or failure code for collection of the data.


timedout

public boolean timedout()
Returns true if SNMP collection failed due to timeout. Otherwise, returns false.


getEntry

public SNMPCollectorEntry getEntry()
Returns the list of all entry maps that can be used to access all the information from the service polling.


OpenNMS API 1.2.3

Generated by eevans on May 29 2005 2015.