OpenNMS API 1.2.3

org.opennms.netmgt.collectd
Class SnmpCollector

java.lang.Object
  extended byorg.opennms.netmgt.collectd.SnmpCollector
All Implemented Interfaces:
ServiceCollector

final class SnmpCollector
extends java.lang.Object
implements ServiceCollector

The SnmpCollector class ...

Author:
Mike Davidson , OpenNMS

Field Summary
private static int DEFAULT_MAX_VARS_PER_PDU
          This defines the default maximum number of variables the collector is permitted to pack into a single outgoing PDU.
private static java.lang.String DEFAULT_OBJECT_IDENTIFIER
          Default object to collect if "oid" property not available.
(package private) static java.lang.String IF_MAP_KEY
          Interface attribute key used to store the map of IfInfo objects which hold data about each interface on a particular node.
(package private) static java.lang.String INTERFACE_COUNT_KEY
          Interface attribute key used to store the number of interfaces configured on the remote host.
private static java.lang.String INTERFACES_IFNUMBER
          Object identifier used to retrieve interface count.
private  java.lang.String m_host
          Local host name
private  int m_maxVarsPerPdu
          Max number of variables permitted in a single outgoing SNMP PDU request..
private  java.lang.String m_rrdPath
          Path to SNMP RRD file repository.
(package private) static java.lang.String MAX_VARS_PER_PDU_STORAGE_KEY
          Interface attribute key used to store configured value for the maximum number of variables permitted in a single outgoing SNMP PDU request.
(package private) static java.lang.String NODE_INFO_KEY
          Interface attribute key used to store a NodeInfo object which holds data about the node being polled.
private static java.lang.String SERVICE_NAME
          Name of monitored service.
(package private) static java.lang.String SNMP_PEER_KEY
          Interface attribute key used to store the interface's JoeSNMP SnmpPeer object.
private static java.lang.String SNMP_STORAGE_ALL
           
(package private) static java.lang.String SNMP_STORAGE_KEY
          Interface attribute key used to store the data collection scheme to be followed.
private static java.lang.String SNMP_STORAGE_PRIMARY
          Valid values for the 'snmpStorageFlag' attribute in datacollection-config xml file.
private static java.lang.String SNMP_STORAGE_SELECT
           
private static java.lang.String SQL_CHECK_SNMPV2
          SQL statement to check for SNMPv2 for a node
private static java.lang.String SQL_GET_ISSNMPPRIMARY
          SQL statement to retrieve interface's 'issnmpprimary' table information.
private static java.lang.String SQL_GET_NODEID
          SQL statement to retrieve interface's 'ipinterface' table information.
private static java.lang.String SQL_GET_NODESYSOID
          /** SQL statement to retrieve node's system object id.
private static java.lang.String SQL_GET_SNMP_INFO
          SQL statement to fetch the ifIndex, ifName, and ifDescr values for all interfaces associated with a node
 
Fields inherited from interface org.opennms.netmgt.collectd.ServiceCollector
COLLECTION_FAILED, COLLECTION_SUCCEEDED, COLLECTION_UNKNOWN, statusType
 
Constructor Summary
(package private) SnmpCollector()
           
 
Method Summary
private  java.util.List buildDataSourceList(java.lang.String collectionName, java.util.List oidList)
          This method is responsible for building a list of RRDDataSource objects from the provided list of MibObject objects.
 int collect(NetworkInterface iface, EventProxy eproxy, java.util.Map parameters)
          Perform data collection.
private  void generateForceRescanEvent(java.lang.String ifAddress, EventProxy eventProxy)
          This method is responsible for building a Capsd forceRescan event object and sending it out over the EventProxy.
private  int getInterfaceCount(SnmpPeer peer)
          Retrieves ifNumber object from the MIB-II interfaces table which is the number of interfaces on the remote node and then returns this value.
 java.lang.String getRRDValue(DataSource ds, SNMPCollectorEntry collectorEntry)
           
 void initialize(java.util.Map parameters)
           Initialize the service collector.
 void initialize(NetworkInterface iface, java.util.Map parameters)
          Responsible for performing all necessary initialization for the specified interface in preparation for data collection.
 void release()
          Responsible for freeing up any resources held by the collector.
 void release(NetworkInterface iface)
          Responsible for releasing any resources associated with the specified interface.
 java.lang.String serviceName()
           Returns the name of the service that the plug-in collects ("SNMP").
private  boolean testSnmpV2Support(java.net.InetAddress addr)
          Responsible for testing the specified interface for SNMPv2 support.
private  boolean updateRRDs(java.lang.String collectionName, NetworkInterface iface, SnmpNodeCollector nodeCollector, SnmpIfCollector ifCollector)
          This method is responsible for building an RRDTool style 'update' command which is issued via the RRD JNI interface in order to push the latest SNMP-collected values into the interface's RRD database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SERVICE_NAME

private static final java.lang.String SERVICE_NAME
Name of monitored service.

See Also:
Constant Field Values

SQL_GET_NODEID

private static final java.lang.String SQL_GET_NODEID
SQL statement to retrieve interface's 'ipinterface' table information.

See Also:
Constant Field Values

SQL_GET_ISSNMPPRIMARY

private static final java.lang.String SQL_GET_ISSNMPPRIMARY
SQL statement to retrieve interface's 'issnmpprimary' table information.

See Also:
Constant Field Values

SQL_GET_NODESYSOID

private static final java.lang.String SQL_GET_NODESYSOID
/** SQL statement to retrieve node's system object id.

See Also:
Constant Field Values

SQL_CHECK_SNMPV2

private static final java.lang.String SQL_CHECK_SNMPV2
SQL statement to check for SNMPv2 for a node

See Also:
Constant Field Values

SQL_GET_SNMP_INFO

private static final java.lang.String SQL_GET_SNMP_INFO
SQL statement to fetch the ifIndex, ifName, and ifDescr values for all interfaces associated with a node

See Also:
Constant Field Values

DEFAULT_OBJECT_IDENTIFIER

private static final java.lang.String DEFAULT_OBJECT_IDENTIFIER
Default object to collect if "oid" property not available.

See Also:
Constant Field Values

INTERFACES_IFNUMBER

private static final java.lang.String INTERFACES_IFNUMBER
Object identifier used to retrieve interface count.

See Also:
Constant Field Values

SNMP_STORAGE_PRIMARY

private static java.lang.String SNMP_STORAGE_PRIMARY
Valid values for the 'snmpStorageFlag' attribute in datacollection-config xml file. "primary" = only primary SNMP interface should be collected and stored "all" = all primary SNMP interfaces should be collected and stored


SNMP_STORAGE_ALL

private static java.lang.String SNMP_STORAGE_ALL

SNMP_STORAGE_SELECT

private static java.lang.String SNMP_STORAGE_SELECT

DEFAULT_MAX_VARS_PER_PDU

private static int DEFAULT_MAX_VARS_PER_PDU
This defines the default maximum number of variables the collector is permitted to pack into a single outgoing PDU. This value is intentionally kept relatively small in order to communicate successfully with the largest possible number of agents.


m_maxVarsPerPdu

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


m_rrdPath

private java.lang.String m_rrdPath
Path to SNMP RRD file repository.


m_host

private java.lang.String m_host
Local host name


SNMP_PEER_KEY

static final java.lang.String SNMP_PEER_KEY
Interface attribute key used to store the interface's JoeSNMP SnmpPeer object.

See Also:
Constant Field Values

INTERFACE_COUNT_KEY

static final java.lang.String INTERFACE_COUNT_KEY
Interface attribute key used to store the number of interfaces configured on the remote host.

See Also:
Constant Field Values

IF_MAP_KEY

static java.lang.String IF_MAP_KEY
Interface attribute key used to store the map of IfInfo objects which hold data about each interface on a particular node.


NODE_INFO_KEY

static java.lang.String NODE_INFO_KEY
Interface attribute key used to store a NodeInfo object which holds data about the node being polled.


SNMP_STORAGE_KEY

static java.lang.String SNMP_STORAGE_KEY
Interface attribute key used to store the data collection scheme to be followed. Two possible values: SNMP_STORAGE_PRIMARY = "primary" SNMP_STORAGE_ALL = "all" SNMP_STORAGE_SELECT = "select"


MAX_VARS_PER_PDU_STORAGE_KEY

static java.lang.String MAX_VARS_PER_PDU_STORAGE_KEY
Interface attribute key used to store configured value for the maximum number of variables permitted in a single outgoing SNMP PDU request.

Constructor Detail

SnmpCollector

SnmpCollector()
Method Detail

serviceName

public java.lang.String serviceName()

Returns the name of the service that the plug-in collects ("SNMP").

Returns:
The service that the plug-in collects.

initialize

public void initialize(java.util.Map parameters)

Initialize the service collector.

During initialization the SNMP collector: - Initializes various configuration factories. - Verifies access to the database - Verifies access to RRD file repository - Verifies access to JNI RRD shared library - Determines if SNMP to be stored for only the node'sprimary interface or for all interfaces.

Specified by:
initialize in interface ServiceCollector
Parameters:
parameters - Not currently used.
Throws:
java.lang.RuntimeException - Thrown if an unrecoverable error occurs that prevents the plug-in from functioning.

release

public void release()
Responsible for freeing up any resources held by the collector.

Specified by:
release in interface ServiceCollector

initialize

public void initialize(NetworkInterface iface,
                       java.util.Map parameters)
Responsible for performing all necessary initialization for the specified interface in preparation for data collection.

Specified by:
initialize in interface ServiceCollector
Parameters:
iface - Network interface to be prepped for collection.
parameters - Key/value pairs associated with the package to which the interface belongs..

release

public void release(NetworkInterface iface)
Responsible for releasing any resources associated with the specified interface.

Specified by:
release in interface ServiceCollector
Parameters:
iface - Network interface to be released.

collect

public int collect(NetworkInterface iface,
                   EventProxy eproxy,
                   java.util.Map parameters)
Perform data collection.

Specified by:
collect in interface ServiceCollector
Parameters:
iface - Network interface to be data collected.
eproxy - Eventy proxy for sending events.
parameters - Key/value pairs from the package to which the interface belongs.

updateRRDs

private boolean updateRRDs(java.lang.String collectionName,
                           NetworkInterface iface,
                           SnmpNodeCollector nodeCollector,
                           SnmpIfCollector ifCollector)
This method is responsible for building an RRDTool style 'update' command which is issued via the RRD JNI interface in order to push the latest SNMP-collected values into the interface's RRD database.

Parameters:
collectionName - SNMP data Collection name from 'datacollection-config.xml'
iface - NetworkInterface object of the interface currently being polled
nodeCollector - Node level MIB data collected via SNMP for the polled interface
ifCollector - Interface level MIB data collected via SNMP for the polled interface
Throws:
java.lang.RuntimeException - Thrown if the data source list for the interface is null.

getRRDValue

public java.lang.String getRRDValue(DataSource ds,
                                    SNMPCollectorEntry collectorEntry)
                             throws java.lang.IllegalArgumentException
Parameters:
ds -
collectorEntry -
Returns:
Throws:
java.lang.Exception
java.lang.IllegalArgumentException

buildDataSourceList

private java.util.List buildDataSourceList(java.lang.String collectionName,
                                           java.util.List oidList)
This method is responsible for building a list of RRDDataSource objects from the provided list of MibObject objects.

Parameters:
collectionName - Collection name
oidList - List of MibObject objects defining the oid's to be collected via SNMP.
Returns:
list of RRDDataSource objects

generateForceRescanEvent

private void generateForceRescanEvent(java.lang.String ifAddress,
                                      EventProxy eventProxy)
This method is responsible for building a Capsd forceRescan event object and sending it out over the EventProxy.

Parameters:
ifAddress - interface address to which this event pertains
eventProxy - proxy over which an event may be sent to eventd

testSnmpV2Support

private boolean testSnmpV2Support(java.net.InetAddress addr)
Responsible for testing the specified interface for SNMPv2 support.

Parameters:
addr - Interface to test.
Returns:
true if remote SNMP agent supports SNMPv2, false otherwise.

getInterfaceCount

private int getInterfaceCount(SnmpPeer peer)
Retrieves ifNumber object from the MIB-II interfaces table which is the number of interfaces on the remote node and then returns this value.

Parameters:
peer - SnmpPeer object used to communicate with the remote SNMP agent.
Returns:
number of interfaces on the remote node.

OpenNMS API 1.2.3

Generated by eevans on May 29 2005 2015.