collectd/collectd — pull request #544 by manuelluis (2014-02-08 21:14:32+00:00)
Title: New Plugin notify_dbi: save notifications in db.

With this plugin you can save notifications in a database.
This is useful to get a history of the notifications or to have a view of errors and warnings in a web page.

A example of configuration to have a table with and history of the notifications and a table with the current warning and errors could be:

LoadPlugin notify_dbi

Driver "mysql"
DriverOption "host" "127.0.0.1"
DriverOption "port" "3306"
DriverOption "username" "collectd"
DriverOption "password" "collectd"
DriverOption "dbname" "collectd"

Query "Failure" "Warning" "Ok" "INSERT INTO alert_history (host, plugin, plugin_instance, type, type_instance, time, severity, message) VALUES ('%{host}', '%{plugin}', '%{plugin_instance}', '%{type}', '%{type_instance}', '%{time}', '%{severity}', '%{message}')"
Query "Failure" "Warning" "DELETE FROM alert where host = '%{host}' and plugin = '%{plugin}' and plugin_instance = '%{plugin_instance}' and type = '%{type}' and type_instance = '%{type_instance}'"
Query "Failure" "Warning" "INSERT INTO alert (host, plugin, plugin_instance, type, type_instance, time, severity, message) VALUES ('%{host}', '%{plugin}', '%{plugin_instance}', '%{type}', '%{type_instance}', '%{time}', '%{severity}', '%{message}')"
Query "Ok" "DELETE FROM alert where host = '%{host}' and plugin = '%{plugin}' and plugin_instance = '%{plugin_instance}' and type = '%{type}' and type_instance = '%{type_instance}'"

This plugin calls dbi_initialize, and plugin dbi too. I don't know if this is a problem.

In version 0.9 of libdbi the functions: dbi_initialize dbi_driver_open dbi_driver_list are marked deprecated.

http://libdbi.sourceforge.net/docs/programmers-guide/reference-core.html

Changes are necessary to compile this plugin and plugin dbi with libdbi 0.9, or you will get for example:

dbi.c: In function 'cdbi_init':
dbi.c:449:3: error: 'dbi_initialize' is deprecated (declared at /usr/include/dbi/dbi.h:169) [-Werror=deprecated-declarations]

Maybe it would be desirable to have support for both versions prior to 0.9 and later,

The entry in the man page may need a rewrite because my poor English.