The check_dbi Plugin

check_dbi v2.3git (monitoring-plugins 2.3git)
Copyright (c) 2011 Monitoring Plugins Development Team

This program connects to an (SQL) database using DBI and checks the
specified metric against threshold levels. The default metric is
the result of the specified query.

check_dbi -d <DBI driver> [-o <DBI driver option> [...]] [-q <query>]
 [-H <host>] [-c <critical range>] [-w <warning range>] [-m <metric>]
 [-e <string>] [-r|-R <regex>]

 -h, --help
    Print detailed help screen
 -V, --version
    Print version information
    Read options from an ini file. See
    for usage and examples.

 -d, --driver=STRING
    DBI driver to use
 -o, --option=STRING
    DBI driver options
 -q, --query=STRING
    query to execute

 -w, --warning=RANGE
    Warning range (format: start:end). Alert if outside this range
 -c, --critical=RANGE
    Critical range
 -e, --expect=STRING
    String to expect as query result
    Do not mix with -w, -c, -r, or -R!
 -r, --regex=REGEX
    Extended POSIX regular expression to check query result against
    Do not mix with -w, -c, -e, or -R!
 -R, --regexi=REGEX
    Case-insensitive extended POSIX regex to check query result against
    Do not mix with -w, -c, -e, or -r!
 -m, --metric=METRIC
    Metric to check thresholds against. Available metrics:
    CONN_TIME    - time used for setting up the database connection
    QUERY_RESULT - result (first column of first row) of the query
    QUERY_TIME   - time used to execute the query
                   (ignore the query result)

 -t, --timeout=INTEGER
    Seconds before connection times out (default: 10)
 -v, --verbose
    Show details for command-line debugging (output may be truncated by
    the monitoring system)

 A DBI driver (-d option) is required. If the specified metric operates
 on a query, one has to be specified (-q option).

 This plugin connects to an (SQL) database using libdbi and, optionally,
 executes the specified query. The first column of the first row of the
 result will be parsed and, in QUERY_RESULT mode, compared with the
 warning and critical ranges. The result from the query has to be numeric
 (strings representing numbers are fine).

 The number and type of required DBI driver options depends on the actual
 driver. See its documentation at
 for details.

  check_dbi -d pgsql -o username=postgres -m QUERY_RESULT \
    -q 'SELECT COUNT(*) FROM pg_stat_activity' -w 5 -c 10
  Warning if more than five connections; critical if more than ten.

  check_dbi -d mysql -H localhost -o username=user -o password=secret \
    -q 'SELECT COUNT(*) FROM logged_in_users -w 5:20 -c 0:50
  Warning if less than 5 or more than 20 users are logged in; critical
  if more than 50 users.

  check_dbi -d firebird -o username=user -o password=secret -o dbname=foo \
    -m CONN_TIME -w 0.5 -c 2
  Warning if connecting to the database takes more than half of a second;
  critical if it takes more than 2 seconds.

  check_dbi -d mysql -H localhost -o username=user \
    -q 'SELECT concat(@@version, " ", @@version_comment)' \
    -r '^5\.[01].*MySQL Enterprise Server'
  Critical if the database server is not a MySQL enterprise server in either
  version 5.0.x or 5.1.x.

  check_dbi -d pgsql -u username=user -m SERVER_VERSION \
    -w 090000:090099 -c 090000:090199
  Warn if the PostgreSQL server version is not 9.0.x; critical if the version
  is less than 9.x or higher than 9.1.x.

Send email to if you have questions regarding
use of this software. To submit patches or suggest improvements, send email