org.opennms.bb.dp.capsd.components
Class CapsReader

java.lang.Object
  |
  +--org.opennms.bb.dp.capsd.components.CapsReader
All Implemented Interfaces:
Runnable

public final class CapsReader
extends Object
implements Runnable

The CapsReader class is used to query a remote host for its SNMP information and the services it supports. The SNMP data collected from the host includes:

In addition to collecting the SNMP information, each discovered interface is queried about the services it supports. The services are interogated via the plugins provided to the constructor.

Version:
$Revision: 1.13 $
Author:
Sowmya, OpenNMS

Inner Class Summary
private  class CapsReader.SignalAfter
          The SignalAfter class is used to delay the notification of a signal until a predefined number of "signals" have occured.
 
Field Summary
private static String IF_INDEX
          The lookup string for looking up the value of ifIndex
private static String IF_TYPE
          The lookup string for looking up the value of ifType
private static String IP_ADDR_ENT_ADDR
          The lookup string for looking up the value of ipAdEntAddr
private static String IP_ADDR_IF_INDEX
          The lookup string for looking up the value of ipAdEntIfIndex
private  Set m_dupNodes
          duplicate nodes set.
private  IfTable m_ifTable
          The remote agents interface table.
private  IpAddrTable m_ipAddrTable
          The remote agent's IP Address table.
private  IpNetToMediaTable m_ipNetToMediaTable
          The remote agents Network to Media table.
private  IpRouteTable m_ipRouteTable
          The remote agents routing information.
private  IPv4Address m_nodeAddress
          The node address that is being queried by the reader.
private  List m_plugins
          The list of plugin modules.
private  Dictionary m_services
          Tracks the status of various plugin modules.
private  SnmpSession m_session
          The SNMP session used to communicate with the remote interface.
private  SystemGroup m_sysGroup
          The SNMP System Group information.
 
Constructor Summary
CapsReader(String ifAddress, List plugins, Set dupNodes)
          The class constructor used to create an instance of the CapsdReader.
 
Method Summary
 Set getDuplicateNodes()
          Returns the duplicate nodes set.
 IPv4Address getIfAddress()
          Returns the IP address of the host that was queried for information by the reader.
 IfTable getIfTable()
          Returns the SNMP interface table collected from the remote host.
private  String getIpAddress(int ifIndex)
          Returns the IP Address of the specified interface.
 IpAddrTable getIpAddrTable()
          Returns the SNMP IP Address table from the remote host.
 IpNetToMediaTable getIpNetToMediaTable()
          Returns the SNMP IP Network to Media table from the remote SNMP agent.
 IpRouteTable getIpRouteTable()
          Returns the SNMP IP Route information from the remote.
 Dictionary getSupportedServices()
          Returns the dictionary that contains the status mapping of interface address to supported protocols.
 SystemGroup getSystemGroup()
          Returns the SNMP system group information collected from the remote host.
private  List ifProbe(InetAddress ifAddr)
          This method is used to probe the passed interface address for service support using the currently loaded plugins.
private  void probe()
          The probe method is used to check the remote interfaces discovered by through SNMP for service support using the registered plugins.
 void run()
          The run method is required by the Runnable interface and actually preforms the bulk of the work for the CapsdReader object.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

IF_INDEX

private static final String IF_INDEX
The lookup string for looking up the value of ifIndex

IF_TYPE

private static final String IF_TYPE
The lookup string for looking up the value of ifType

IP_ADDR_IF_INDEX

private static final String IP_ADDR_IF_INDEX
The lookup string for looking up the value of ipAdEntIfIndex

IP_ADDR_ENT_ADDR

private static final String IP_ADDR_ENT_ADDR
The lookup string for looking up the value of ipAdEntAddr

m_plugins

private List m_plugins

The list of plugin modules. The list is used to query for protocol support on each discovered interface.


m_nodeAddress

private IPv4Address m_nodeAddress

The node address that is being queried by the reader. The address will be tested for SNMP support and then by each of the service plugins.


m_dupNodes

private Set m_dupNodes
duplicate nodes set. Reader will add the ip addresses of all the interfaces for the targeted node if SNMP query is successful

m_session

private SnmpSession m_session

The SNMP session used to communicate with the remote interface.


m_sysGroup

private SystemGroup m_sysGroup

The SNMP System Group information.


m_ifTable

private IfTable m_ifTable

The remote agents interface table. This is a collection of interface entries.


m_ipAddrTable

private IpAddrTable m_ipAddrTable

The remote agent's IP Address table. This can be used to pair interfaces with their IP Addresses.


m_ipRouteTable

private IpRouteTable m_ipRouteTable

The remote agents routing information.


m_ipNetToMediaTable

private IpNetToMediaTable m_ipNetToMediaTable

The remote agents Network to Media table.


m_services

private Dictionary m_services

Tracks the status of various plugin modules.

Constructor Detail

CapsReader

public CapsReader(String ifAddress,
                  List plugins,
                  Set dupNodes)

The class constructor used to create an instance of the CapsdReader. The constructor will verify the validity of the passed address and initialize the object to query the remote host. In order to query the remote host the run method should be invoked to actually query the host.

Parameters:
ifAddress - The IP Address of the remote interface.
plugins - The list of plugin modules to invoke.
dupNodes - Set of ip addresses already known to Capsd.
Throws:
SocketException - Thrown if there is an error settting up the SnmpSession to query the remote.
UnknownHostException - Thrown if a lookup error occurs trying to resolve the address of the remote.
See Also:
SnmpSession
Method Detail

ifProbe

private List ifProbe(InetAddress ifAddr)

This method is used to probe the passed interface address for service support using the currently loaded plugins. Each plugin is tested against the interface and a list of supported ServiceStatus objects are returned to the caller. If there are no supported services, or the plugins could not be loaded then a null object is returned.

Parameters:
ifAddr - The interface address to test for services.
Returns:
A list of ServiceStatus objects for the supporting services or null if no services are found. Additionally, if errors occur then a null is returned.

probe

private void probe()

The probe method is used to check the remote interfaces discovered by through SNMP for service support using the registered plugins. The list of interfaces are iterated though and probed if the interface is not unnammed (it must have an IP address bound to it).

The method modifies the serviceStatus dictionary and associates either a list of ServiceStatus information or a null with the interfaces address.


getIpAddress

private String getIpAddress(int ifIndex)

Returns the IP Address of the specified interface. The interface is specified by the interface's index number from the remotes interface table. If no corresponding address or interface is found then a null address is returned.

Parameters:
ifIndex - The interface's index number from the remote SNMP agent.
Returns:
The IP Address string for the interface. Null if the interface or address is not found.

run

public void run()

The run method is required by the Runnable interface and actually preforms the bulk of the work for the CapsdReader object. When the run method is invoked the reader will attempt to connect to the remote host's SNMP agent, if any. While connected to the remote the MIB system group, interface table, net to media table, and other SNMP objects are collected by the reader.

Once the information has been collected by the reader the SNMP connection is closed and a set of capsd plugin checkers are run against the remote inteface(s). If there are multiple interfaces on the remote host then each interface is tried to determine what services are supported.

Specified by:
run in interface Runnable

getIfAddress

public IPv4Address getIfAddress()

Returns the IP address of the host that was queried for information by the reader.

Returns:
The IP Address of the probed remote.

getSystemGroup

public SystemGroup getSystemGroup()

Returns the SNMP system group information collected from the remote host. If there was an SNMP error or no agent on the remote then a null pointer is returned to the caller.

Returns:
The SNMP system group information if successfully collected. A null if the collection failed.

getIfTable

public IfTable getIfTable()

Returns the SNMP interface table collected from the remote host. If the host did not have an agent or an error occured during the collection then a null pointer is returned.

Returns:
The SNMP interface table on success, a null if the collection failed.

getIpAddrTable

public IpAddrTable getIpAddrTable()

Returns the SNMP IP Address table from the remote host. Should and error occur or the host not have an SNMP agent then a null will be returned to the caller.

Returns:
The SNMP IP Address table information on success, a null if the collection failed.

getIpRouteTable

public IpRouteTable getIpRouteTable()

Returns the SNMP IP Route information from the remote. If an error should occur or the remote not have an SNMP agent then a null will be returned to the caller.

Returns:
The SNMP IP Routing table on success, a null if the information could not be collected.

getIpNetToMediaTable

public IpNetToMediaTable getIpNetToMediaTable()

Returns the SNMP IP Network to Media table from the remote SNMP agent. If an error occurs during the collection or the remote does not have an SNMP agent then a null will be returned.

Returns:
The SNMP IP Network to Media table on success. A null will be returned if an error occured.

getSupportedServices

public Dictionary getSupportedServices()

Returns the dictionary that contains the status mapping of interface address to supported protocols. The dictionary key is the IP address of the interface. The mapped object is a list of supported services.

Returns:
The mapping for interface to capabilities.

getDuplicateNodes

public Set getDuplicateNodes()

Returns the duplicate nodes set.