JdbcCollector

The JdbcCollector collects performance data via JDBC drivers. Attributes are retrieved using SQL queries. The JDBC driver for PostgreSQL is included with Horizon. Any other JDBC driver must be manually loaded to collect from other types of database servers.

Collector facts

Class Name

org.opennms.netmgt.collectd.JdbcCollector

Package

core

Supported on Minion

Yes (see limitations)

Configuration Files

$OPENNMS_HOME/etc/jdbc-datacollection-config.xml

Limitations on Minion

No JDBC drivers are included with Minion. See install JDBC drivers on Minion for instructions.

Also, when running on Minion, you cannot reference the data sources in opennms-datasources.xml. Instead, you must use the service parameters to set the JDBC connection settings.

Configuration and use

Table 1. Collector-specific parameters for the JdbcCollector
Parameter Description Default

Required

collection

The name of the JDBC Collection to use.

n/a

Optional

data-source

Use an existing datasource defined in opennms-datasources.xml.

NO_DATASOURCE_FOUND

driver

Driver class name

org.postgresql.Driver

url

JDBC URL

jdbc:postgresql://OPENNMS_JDBC_HOSTNAME/opennms

user

JDBC username

postgres

password

JDBC password

n/a

JDBC collection configuration

Understanding resource types helps when editing collector-specific configuration files.

Define JDBC collections in etc/jdbc-datacollection-config.xml.

This snippet provides a sample collection definition named opennms-stats:

<jdbc-collection name="opennms-stats">
  <rrd step="300">
    <rra>RRA:AVERAGE:0.5:1:2016</rra>
    <rra>RRA:AVERAGE:0.5:12:1488</rra>
    <rra>RRA:AVERAGE:0.5:288:366</rra>
    <rra>RRA:MAX:0.5:288:366</rra>
    <rra>RRA:MIN:0.5:288:366</rra>
  </rrd>
  <queries>
    <query name="opennmsQuery" ifType="ignore">
      <statement data-source="opennms">
        <queryString>select count(*) as event_count from events;</queryString>
      </statement>
      <columns>
        <column name="event_count" data-source-name="event_count" alias="event_count" type="GAUGE"/>
      </columns>
    </query>
  </queries>
</jdbc-collection>

Once added to etc/jdbc-datacollection-config.xml, you can test it using the collect command available in the Karaf Shell:

opennms:collect org.opennms.netmgt.collectd.JdbcCollector 127.0.0.1 collection=opennms-stats data-source=opennms

To test this same collection on Minion, you must specify the JDBC settings as service attributes, for example:

opennms:collect -l MINION org.opennms.netmgt.collectd.JdbcCollector 127.0.0.1 collection=opennms-stats driver=org.postgresql.Driver url=jdbc:postgresql://localhost:5432/opennms user=opennms password=opennms