Plugin:DBI

From collectd Wiki
Revision as of 18:57, 26 February 2009 by Octo (talk | contribs) (Created initial page.)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Description

The DBI plugin uses libdbi, a database abstraction library, to execute SQL statements on a database and read back the result. Depending on the configuration, the returned values are then converted into collectd "value lists" (the data structure used internally to pass statistics around). It is a very generic plugin, so reading the collectd.conf(5) manpage is a must.

We tried to keep the syntax similar to that of the SNMP plugin. So if you use that already, most of the following will look familiar.

Synopsis

<Plugin dbi>
  <Query "out_of_stock">
    Statement "SELECT category, COUNT(*) AS value FROM products WHERE in_stock = 0 GROUP BY category"
    # Use with MySQL 5.0.0 or later
    MinVersion 50000
    <Result>
      Type "gauge" 
      InstancePrefix "out_of_stock"
      InstancesFrom "category"
      ValuesFrom "value" 
    </Result>
  </Query>
  <Database "product_information">
    Driver "mysql" 
    DriverOption "host" "localhost"
    DriverOption "username" "collectd"
    DriverOption "password" "aZo6daiw"
    DriverOption "dbname" "prod_info"
    SelectDB "prod_info"
    Query "out_of_stock"
  </Database>
</Plugin>

Example graph

None yet. Add one now!

Dependencies