OpenNMS API 1.1.3

org.opennms.netmgt.poller
Class SnmpMonitor

java.lang.Object
  extended byorg.opennms.netmgt.poller.IPv4Monitor
      extended byorg.opennms.netmgt.poller.SnmpMonitor
All Implemented Interfaces:
ServiceMonitor

public final class SnmpMonitor
extends IPv4Monitor

This class is designed to be used by the service poller framework to test the availability of the SNMP service on remote interfaces. The class implements the ServiceMonitor interface that allows it to be used along with other plug-ins by the service poller framework.

Author:
Tarus Balog, Mike Davidson, OpenNMS

Field Summary
private static java.lang.String DEFAULT_OBJECT_IDENTIFIER
          Default object to collect if "oid" property not available.
private static int DEFAULT_PORT
          The default port on which the host is checked to see if it supports SNMP.
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.
 
Fields inherited from interface org.opennms.netmgt.poller.ServiceMonitor
SERVICE_AVAILABLE, SERVICE_STATUS_MASK, SERVICE_UNAVAILABLE, SERVICE_UNRESPONSIVE, SURPRESS_EVENT_MASK
 
Constructor Summary
SnmpMonitor()
           
 
Method Summary
 void initialize(java.util.Map parameters)
          Initialize the service monitor.
 void initialize(NetworkInterface iface)
          Called by the poller framework when an interface is being added to the scheduler.
 int poll(NetworkInterface iface, java.util.Map parameters, Package pkg)
          The poll() method is responsible for polling the specified address for SNMP service availability.
 void release()
          This method is called whenever the plug-in is being unloaded, normally during framework exit.
 void release(NetworkInterface iface)
          This method is the called whenever an interface is being removed from the scheduler.
 java.lang.String serviceName()
          Returns the name of the service that the plug-in monitors ("SNMP").
 
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

DEFAULT_PORT

private static int DEFAULT_PORT

The default port on which the host is checked to see if it supports SNMP.


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

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
Constructor Detail

SnmpMonitor

public SnmpMonitor()
Method Detail

serviceName

public java.lang.String serviceName()

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

Returns:
The service that the plug-in monitors.

initialize

public void initialize(java.util.Map parameters)

Initialize the service monitor.

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

initialize

public void initialize(NetworkInterface iface)

Called by the poller framework when an interface is being added to the scheduler. Here we perform any necessary initialization to prepare the NetworkInterface object for polling.

Specified by:
initialize in interface ServiceMonitor
Overrides:
initialize in class IPv4Monitor
Parameters:
iface - The network interface to be initialized.
Throws:
java.lang.RuntimeException - Thrown if an unrecoverable error occurs that prevents the interface from being monitored.

poll

public int poll(NetworkInterface iface,
                java.util.Map parameters,
                Package pkg)

The poll() method is responsible for polling the specified address for SNMP service availability.

Parameters:
iface - The network interface to test the service on.
parameters - The package parameters (timeout, retry, etc...) to be used for this poll.
Returns:
The availability of the interface and if a transition event should be supressed.
Throws:
java.lang.RuntimeException - Thrown for any uncrecoverable errors.
See Also:
ServiceMonitor.SURPRESS_EVENT_MASK, ServiceMonitor.SERVICE_AVAILABLE, ServiceMonitor.SERVICE_UNAVAILABLE

release

public void release()

This method is called whenever the plug-in is being unloaded, normally during framework exit. During this time the framework may release any resource and save any state information using the proxy object from the initialization routine.

Even if the plug-in throws a monitor exception, it will not prevent the plug-in from being unloaded. The plug-in should not return until all of its state information is saved. Once the plug-in returns from this call its configuration proxy object is considered invalid.

Specified by:
release in interface ServiceMonitor
Throws:
java.lang.RuntimeException - Thrown if an error occurs during deallocation.

release

public void release(NetworkInterface iface)

This method is the called whenever an interface is being removed from the scheduler. For example, if a service is determined as being no longer supported then this method will be invoked to cleanup any information associated with this device. This gives the implementor of the interface the ability to serialize any data prior to the interface being discarded.

If an exception is thrown during the release the exception will be logged, but the interface will still be discarded for garbage collection.

Specified by:
release in interface ServiceMonitor
Parameters:
iface - The network interface that was being monitored.
Throws:
java.lang.RuntimeException - Thrown if an unrecoverable error occurs that prevents the interface from being monitored.

OpenNMS API 1.1.3

Generated by root on August 19 2004 0130.