The generic JDBC

This class back end can be using to monitor services using SQL queries. Any database with a JDBC driver can be used. Probes using it can be technical probes monitoring the database server. They can also monitor application using a database. JRDS include postgres and mysql JDBCdrivers, other one must be manually downloaded. Each database must be declared in a connection, using the following parameters :

<connection type="jrds.probe.jdbc.JdbcConnection">
            <attr name="user">someuser</attr>
            <attr name="password">somepassowrd</attr>
            <attr name="url">jdbc:protocol://${host}</attr>
            <attr name="driverClass">class</attr>
</connection>

A forth optional argument can be used, the class name for the JDBC driver that will used for this connection. It must be in the class path. One can use the propertie classpath for that.

The probe itself take an optionnal list as an argument, see the specific probes for details. For example, on a postgress probe :

    <probe type="PgStatDatabase">
        <list>
            <arg type="String" value="${database}" />
        </list>
    </probe>

A generic JDBC probe send an sql query defined in the “query” specific. It parses then the row returned and build a map of values using the column name as a key.

If the result of the query contains many rows, another specific named “key” is used. The key for the map is then constructed by prefixing the row name with the value of the column with the key name.

For example, if the returned value is :

ColumnA ColumnB
vA1 vB1
vA2 vB2

If the specific “key” is ”ColumnA”, then the map will be filled with :

key value
vA1.ColumnB vB1
vA2.ColumnB vB2

Without this specific, only the last row would have been used with the values :

key value
ColumnA vA2
ColumnB vB2

For example, with Mysql, if we check the monitoring query :

mysql> SHOW /*!50002 GLOBAL */ STATUS;
+-----------------------------------+-------------+
| Variable_name                     | Value       |
+-----------------------------------+-------------+
| Aborted_clients                   | 3721        | 
| Aborted_connects                  | 21753       | 
...

Then the probe description should contains :

    <specific name="query">SHOW /*!50002 GLOBAL */ STATUS;</specific>
    <specific name="key">Variable_name</specific>
    <ds>
        <dsName>Aborted_clients</dsName>
        <dsType>counter</dsType>
        <collect>Aborted_clients.Value</collect>
    </ds>
    <ds>
        <dsName>Aborted_connects</dsName>
        <dsType>counter</dsType>
        <collect>Aborted_connects.Value</collect>
   </ds>
   ...

Some generic JDBC probes are bundled with JRDS :

The connection class for this probe is jrds.probe.jdbc.JdbcConnection.

 
sourcetype/jdbc/start.txt · Last modified: 2015/11/27 11:58 by root     Back to top