JDBCMonitor

The JDBCMonitor checks that it is able to connect to a database and if it can get the database catalog from that database management system (DBMS). It is based on the JDBC technology to connect and communicate with the database.

Monitor facts

Class Name

org.opennms.netmgt.poller.monitors.JDBCMonitor

Configuration and use

Table 1. Monitor-specific parameters for the JDBCMonitor
Parameter Description Default value

Required

driver

JDBC driver class to use.

org.postgresql.Driver

url {}

JDBC URL to connect to.

jdbc:postgresql://:OPENNMS_JDBC_HOSTNAME/opennms

user {}

Database user

postgres

password {}

Database password

empty string

Optional

retries

How many retries to perform before failing the test.

0

{} indicates the parameter supports placeholder substitution.

The OPENNMS_JDBC_HOSTNAME is replaced in the url parameter with the IP or resolved hostname of the interface the monitored service is assigned to.

This monitor implements the Common Configuration Parameters.

Database driver

The JDBCMonitor is based on JDBC and requires a JDBC driver to communicate with any database. Since Horizon itself uses a PostgreSQL database, the PostgreSQL JDBC driver is available out of the box. For all other database systems, you must provide a compatible JDBC driver to Horizon as a JAR file. To provide a JDBC driver, place the driver-jar in your ${OPENNMS_HOME}/lib folder.

Examples

The following example checks if the PostgreSQL database that Horizon uses is available.

Note that you must include the monitor section in your definition.

<service name="OpenNMS-DBMS" interval="30000" user-defined="true" status="on">
  <parameter key="driver" value="org.postgresql.Driver"/>
  <parameter key="url" value="jdbc:postgresql://OPENNMS_JDBC_HOSTNAME:5432/opennms"/>
  <parameter key="user" value="opennms"/>
  <parameter key="password" value="opennms"/>
</service>

<monitor service="OpenNMS-DBMS" class-name="org.opennms.netmgt.poller.monitors.JDBCMonitor" />