devices
Class SNMPDevice

java.lang.Object
  extended bydevices.SNMPDevice

public class SNMPDevice
extends java.lang.Object

A device that contains the information and functionality needed to talk SNMP.

Version:
0.1
Author:
gswalters

Field Summary
static java.lang.String ifDescr
           
static java.lang.String ifIndex
           
static java.lang.String ifNumber
           
static java.lang.String ifOperStatus
           
static java.lang.String ifSpeed
           
static java.lang.String sysContact
           
static java.lang.String sysDescr
           
static java.lang.String sysLocation
           
static java.lang.String sysName
           
static java.lang.String sysServices
           
static java.lang.String sysUpTime
           
 
Constructor Summary
SNMPDevice(Device device)
          Create an SNMPDevice given a Device.
SNMPDevice(Device device, int port)
          Create an SNMPDevice given a Device.
SNMPDevice(java.lang.String deviceIpAddress, java.lang.String deviceCommunityString)
          Create an SNMPDevice given an IP address and a community string.
SNMPDevice(java.lang.String deviceIpAddress, java.lang.String deviceCommunityString, int port)
          Create an SNMPDevice given an IP address and a community string.
 
Method Summary
 java.lang.Object getAttributeValue(java.lang.String OID)
          Gets an attribute value given an OID.
 java.lang.Object[] getAttributeValues(java.lang.String[] OID)
          Retrieve the attributes for an array of Interface OIDs
 Device getDevice()
           
 DeviceInterface getInterface(int index)
          Gets an active interface on the SNMPDevice.
 DeviceInterface[] getInterfaces(int ifNumber)
          Using the GetNext requests, retrieve all interfaces from a device.
 int getNumberOfInterfaces()
          Gets the number of active interfaces on the SNMPDevice.
 long getSysUpTime()
           
 boolean isActiveDevice()
          Determines whether the SNMPDevice is active and talking SNMP.
 void stop()
          Stop an SNMP connection and free its resources.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sysDescr

public static final java.lang.String sysDescr
See Also:
Constant Field Values

sysUpTime

public static final java.lang.String sysUpTime
See Also:
Constant Field Values

sysContact

public static final java.lang.String sysContact
See Also:
Constant Field Values

sysName

public static final java.lang.String sysName
See Also:
Constant Field Values

sysLocation

public static final java.lang.String sysLocation
See Also:
Constant Field Values

sysServices

public static final java.lang.String sysServices
See Also:
Constant Field Values

ifNumber

public static final java.lang.String ifNumber
See Also:
Constant Field Values

ifIndex

public static final java.lang.String ifIndex
See Also:
Constant Field Values

ifDescr

public static final java.lang.String ifDescr
See Also:
Constant Field Values

ifSpeed

public static final java.lang.String ifSpeed
See Also:
Constant Field Values

ifOperStatus

public static final java.lang.String ifOperStatus
See Also:
Constant Field Values
Constructor Detail

SNMPDevice

public SNMPDevice(Device device)
           throws java.io.IOException
Create an SNMPDevice given a Device. Use this constructor to use the default port 161.

Parameters:
device - the Device.
Throws:
java.io.IOException - if the device does not have a valid IP address.

SNMPDevice

public SNMPDevice(Device device,
                  int port)
           throws java.io.IOException
Create an SNMPDevice given a Device. Use this constructor to use a different port other than the default 161.

Parameters:
device - the Device.
port - the port to talk SNMP on.
Throws:
java.io.IOException - if the device does not have a valid IP address.

SNMPDevice

public SNMPDevice(java.lang.String deviceIpAddress,
                  java.lang.String deviceCommunityString)
           throws java.io.IOException
Create an SNMPDevice given an IP address and a community string. Use this constructor to create an SNMP device without having a Device.

Parameters:
deviceIpAddress - the device's IP address.
deviceCommunityString - the device's community string.
Throws:
java.io.IOException - if the IP address is not valid.

SNMPDevice

public SNMPDevice(java.lang.String deviceIpAddress,
                  java.lang.String deviceCommunityString,
                  int port)
           throws java.io.IOException
Create an SNMPDevice given an IP address and a community string. Use this constructor to create an SNMP device without having a Device and using a different port than the default 161.

Parameters:
deviceIpAddress - the device's IP address.
deviceCommunityString - the device's community string.
port - the port to talk SNMP on.
Throws:
java.io.IOException - if the IP address is not valid.
Method Detail

stop

public void stop()
Stop an SNMP connection and free its resources.


isActiveDevice

public boolean isActiveDevice()
Determines whether the SNMPDevice is active and talking SNMP.

Returns:
True if and only if the device is on and running an SNMP agent.

getDevice

public Device getDevice()

getSysUpTime

public long getSysUpTime()

getNumberOfInterfaces

public int getNumberOfInterfaces()
Gets the number of active interfaces on the SNMPDevice. A blocking call.

Returns:
the number of active interfaces.

getInterface

public DeviceInterface getInterface(int index)
Gets an active interface on the SNMPDevice.

Parameters:
index - the index of the interface.
Returns:
a DeviceInterface or null if it does not exist.

getInterfaces

public DeviceInterface[] getInterfaces(int ifNumber)
Using the GetNext requests, retrieve all interfaces from a device. Start with the OID of the 0 (zero) interface and ask for the next OID in the device's ifTable.

Returns:
a DeviceInterface Array containing all of the active interfaces or null values if the interface does not exist.

getAttributeValue

public java.lang.Object getAttributeValue(java.lang.String OID)
Gets an attribute value given an OID. This method returns either a String, Integer, or Long.

Parameters:
OID - the OID to query.
Returns:
The String, Integer, or Long value via an Object.

getAttributeValues

public java.lang.Object[] getAttributeValues(java.lang.String[] OID)
Retrieve the attributes for an array of Interface OIDs

Parameters:
OID - String array holding the OIDs to retrieve
Returns:
Object array containing the OID values