collectd/collectd — pull request #179 by tokkee (2012-11-14 09:37:19+00:00)
Title: postgresql plugin: Added generic support for writing values to a database

This has been implemented by requiring the user to specify an SQL statement to
be used for storing a value-list in PostgreSQL. Usually, this should be done
by creating custom functions to take care of that.

The user specified statement will then be called by collectd with eight
arguments: time, host, plugin, plugin instance (or NULL), type, type instance
(or NULL), array of value names (data source names) and an array of the
values.

Two elements have been added to the config parser: A block may be
used to name an SQL statement (specified using the 'Statement' option) to be
used for writing data. In a block, the new option 'Writer' may be
used to apply a writer to a database connection.

The current approach has two benefits: for one, a user may chose whatever
database layout best suits her needs. Also, it is very easy to experiment with
different approaches on how to structure the data in a database without the
need to modify the plugin. This can be done in SQL, which (hopefully) is the
language that people working with PostgreSQL databases like most ;-)
If it happens to turn out that some approach is rather superior, it may still
be re-implemented in a specific plugin in later versions.