org.opennms.netmgt.poller.monitors
Class JDBCMonitor

java.lang.Object
  extended by org.opennms.netmgt.poller.monitors.IPv4Monitor
      extended by org.opennms.netmgt.poller.monitors.JDBCMonitor
All Implemented Interfaces:
ServiceMonitor
Direct Known Subclasses:
JDBCStoredProcedureMonitor

@Distributable
public class JDBCMonitor
extends IPv4Monitor

This class implements a basic JDBC monitoring framework; The idea is than these tests doesn't take too long (or too much resources to run) and provide the basic healt information about the polled server. See src/services/org/opennms/netmgt/poller OpenNMS plugin information at OpenNMS developer site

Since:
0.1
Author:
Jose Vicente Nunez Zuleta (josevnz@users.sourceforge.net) - RHCE, SJCD, SJCP version 0.1 - 07/23/2002 * version 0.2 - 08/05/2002 -- Added retry logic, input validations to poller.

Field Summary
static int DEFAULT_RETRY
          Default number of times to retry a test
static int DEFAULT_TIMEOUT
          Number of miliseconds to wait before timing out a database login using JDBC Hint: 1 minute is 6000 miliseconds.
 
Constructor Summary
JDBCMonitor()
          Class constructor.
 
Method Summary
 PollStatus checkDatabaseStatus(Connection con, Map parameters)
           
protected  void closeStmt(Statement statement)
           
 void initialize(Map parameters)
          This method is called after the framework loads the plugin.
 void initialize(MonitoredService svc)
          This method is called when an interface that support the service is added to the scheduling service.
 PollStatus poll(MonitoredService svc, Map parameters)
          Network interface to poll for a given service.
 void release()
          Release any used services by the plugin,normally during framework exit For now this method is just an 'adaptor', does nothing
 void release(MonitoredService svc)
           This method is the called whenever an interface is being removed from the scheduler.
 
Methods inherited from class org.opennms.netmgt.poller.monitors.IPv4Monitor
log, logDown, logDown, logUp
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TIMEOUT

public static final int DEFAULT_TIMEOUT
Number of miliseconds to wait before timing out a database login using JDBC Hint: 1 minute is 6000 miliseconds.

See Also:
Constant Field Values

DEFAULT_RETRY

public static final int DEFAULT_RETRY
Default number of times to retry a test

See Also:
Constant Field Values
Constructor Detail

JDBCMonitor

public JDBCMonitor()
            throws ClassNotFoundException,
                   InstantiationException,
                   IllegalAccessException
Class constructor.

Throws:
ClassNotFoundException
InstantiationException
IllegalAccessException
Method Detail

initialize

public void initialize(Map parameters)
This method is called after the framework loads the plugin.

Specified by:
initialize in interface ServiceMonitor
Overrides:
initialize in class IPv4Monitor
Parameters:
parameters - Configuration parameters passed to the plugin
Throws:
RuntimeException - If there is any error that prevents the plugin from running

release

public void release()
Release any used services by the plugin,normally during framework exit For now this method is just an 'adaptor', does nothing

Specified by:
release in interface ServiceMonitor
Overrides:
release in class IPv4Monitor
Throws:
RuntimeException - Thrown if an error occurs during deallocation.

initialize

public void initialize(MonitoredService svc)
This method is called when an interface that support the service is added to the scheduling service.

Specified by:
initialize in interface ServiceMonitor
Overrides:
initialize in class IPv4Monitor
Parameters:
svc - TODO
Throws:
RuntimeException - Thrown if an unrecoverable error occurs that prevents the interface from being monitored.
NetworkInterfaceNotSupportedException - Thrown if the passed interface is invalid for this monitor.

release

public void release(MonitoredService svc)

This method is the called whenever an interface is being removed from the scheduler. For now this method is just an 'adaptor', does nothing

Specified by:
release in interface ServiceMonitor
Overrides:
release in class IPv4Monitor
Parameters:
svc - TODO
Throws:
RuntimeException - Thrown if an unrecoverable error occurs that prevents the interface from being monitored.

poll

public PollStatus poll(MonitoredService svc,
                       Map parameters)
Network interface to poll for a given service. Make sure you're using the latest (at least 5.5) JConnect version or the plugin will not be able to tell exactly if the service is up or not.

Specified by:
poll in interface ServiceMonitor
Specified by:
poll in class IPv4Monitor
Parameters:
parameters - Parameters to pass when polling the interface Currently recognized Map keys:
  • user - Database user
  • password - User password
  • port - server port
  • timeout - Number of miliseconds to wait before sending a timeout
  • driver - The JDBC driver to use
  • url - The vendor specific jdbc URL
iface - The interface to poll
Returns:
int An status code that shows the status of the service
Throws:
RuntimeException - Thrown if an unrecoverable error occurs that prevents the interface from being monitored.
See Also:
org.opennms.netmgt.poller.ServiceMonitor#SERVICE_AVAILABLE, org.opennms.netmgt.poller.ServiceMonitor#SERVICE_UNAVAILABLE, org.opennms.netmgt.poller.ServiceMonitor#SERVICE_UNRESPONSIVE, Error codes for JConnect

closeStmt

protected void closeStmt(Statement statement)

checkDatabaseStatus

public PollStatus checkDatabaseStatus(Connection con,
                                      Map parameters)


Copyright © 2009. All Rights Reserved.