Class JDBCMonitor

  • All Implemented Interfaces:
    ServiceMonitor
    Direct Known Subclasses:
    JDBCQueryMonitor, JDBCStoredProcedureMonitor

    public class JDBCMonitor
    extends ParameterSubstitutingMonitor
    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
    Version:
    $Id: $
    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 Detail

      • LOG

        public static final org.slf4j.Logger LOG
      • 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 java.lang.ClassNotFoundException,
                           java.lang.InstantiationException,
                           java.lang.IllegalAccessException
        Class constructor.
        Throws:
        java.lang.ClassNotFoundException - if any.
        java.lang.InstantiationException - if any.
        java.lang.IllegalAccessException - if any.
    • Method Detail

      • poll

        public PollStatus poll​(MonitoredService svc,
                               java.util.Map<java.lang.String,​java.lang.Object> parameters)

        This method is the heart of the plug-in monitor. Each time an interface requires a check to be performed as defined by the scheduler the poll method is invoked. The poll is passed the service to check.

        By default when the status transition from up to down or vice versa the framework will generate an event. Additionally, if the polling interval changes due to an extended unavailability, the framework will generate an additional down event. The plug-in can suppress the generation of the default events by setting the suppress event bit in the returned integer.

        NOTE: This method may be invoked on a Minion, in which case certain bean and facilities will not be available. If any state related information is required such as agent related configuration, it should retrieved by the ServiceMonitor.getRuntimeAttributes(MonitoredService, Map).

        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.
        Parameters:
        svc - Includes details about to the service being monitored.
        parameters - Includes the service parameters defined in poller-configuration.xml and those returned by ServiceMonitor.getRuntimeAttributes(MonitoredService, Map).
        Returns:
        The availability of the interface and if a transition event should be suppressed.
        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​(java.sql.Statement statement)

        closeStmt

        Parameters:
        statement - a Statement object.
      • checkDatabaseStatus

        public PollStatus checkDatabaseStatus​(java.sql.Connection con,
                                              java.util.Map<java.lang.String,​java.lang.Object> parameters)

        checkDatabaseStatus

        Parameters:
        con - a Connection object.
        parameters - a Map object.
        Returns:
        a PollStatus object.