|Callbacks:||config, init, read, shutdown|
|Copyright:||2008–2009 Florian octo Forster|
|List of Plugins|
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). This plugin is a generic plugin, i.e. it cannot work without configuration, because there is no reasonable default behavior. Please read the Plugin dbi section of the collectd.conf(5) manual page for an in-depth description of the plugin's configuration.
Being an abstraction layer, libdbi can connect to and talk with a variety of database systems. Database specific code is encapsulated in "database drivers" (DBD), which are developed as the separate libdbi-drivers project. Currently, drivers for the following databases are available:
- Firebird / Interbase
- FreeTDS (provides access to MS SQL Server and Sybase)
- SQLite / SQLite3
The configuration syntax of the DBI, Oracle, and PostgreSQL plugins is very similar, because the configuration of those plugins is handled by the same module. Also, we tried to keep the syntax similar to that of the SNMP plugin. So if you use any of those plugins already, most of the following will look familiar.
<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" # You may connect via socket as well: # DriverOption "mysql_unix_socket" "/var/tmp/mysql.sock" DriverOption "username" "collectd" DriverOption "password" "aZo6daiw" DriverOption "dbname" "prod_info" SelectDB "prod_info" Query "out_of_stock" </Database> </Plugin>
None yet. Add one now!