# </Result>
# </Query>
# <Database "customers_db">
+# #PluginName "mycompany"
# Driver "mysql"
# DriverOption "host" "localhost"
# DriverOption "username" "collectd"
# </Result>
# </Query>
# <Database "product_information">
+# #PluginName "warehouse"
# ConnectID "db01"
# Username "oracle"
# Password "secret"
# StoreRates true
# </Writer>
# <Database foo>
+# #PluginName "kingdom"
# Host "hostname"
# Port "5432"
# User "username"
</Result>
</Query>
<Database "product_information">
+ #PluginName "warehouse"
Driver "mysql"
Interval 120
DriverOption "host" "localhost"
=over 4
+=item B<PluginName> I<PluginName>
+
+Use I<PluginName> as the plugin name when submitting query results from
+this B<Database>. Defaults to 'dbi'.
+
=item B<Interval> I<Interval>
Sets the interval (in seconds) in which the values will be collected from this
</Result>
</Query>
<Database "product_information">
+ #PluginName "warehouse"
ConnectID "db01"
Username "oracle"
Password "secret"
=over 4
+=item B<PluginName> I<PluginName>
+
+Use I<PluginName> as the plugin name when submitting query results from
+this B<Database>. Defaults to 'oracle'.
+
=item B<ConnectID> I<ID>
Defines the "database alias" or "service name" to connect to. Usually, these
</Writer>
<Database foo>
+ PluginName "kingdom"
Host "hostname"
Port "5432"
User "username"
amount of time will be lost, for example, if a single statement within the
transaction fails or if the database server crashes.
+=item B<PluginName> I<PluginName>
+
+Use I<PluginName> as the plugin name when submitting query results from
+this B<Database>. Defaults to 'postgresql'.
+
=item B<Instance> I<name>
Specify the plugin instance name that should be used instead of the database
{
char *name;
char *select_db;
+ char *plugin_name;
cdtime_t interval;
return;
sfree(db->name);
+ sfree(db->select_db);
+ sfree(db->plugin_name);
sfree(db->driver);
+ sfree(db->host);
for (size_t i = 0; i < db->driver_options_num; i++) {
sfree(db->driver_options[i].key);
status = cf_util_get_string(child, &db->host);
else if (strcasecmp("Interval", child->key) == 0)
status = cf_util_get_cdtime(child, &db->interval);
+ else if (strcasecmp("PluginName", child->key) == 0)
+ status = cf_util_get_string(child, &db->plugin_name);
else {
WARNING("dbi plugin: Option `%s' not allowed here.", child->key);
status = -1;
udb_query_prepare_result(
q, prep_area, (db->host ? db->host : hostname_g),
- /* plugin = */ "dbi", db->name, column_names, column_num,
+ /* plugin = */ (db->plugin_name != NULL) ? db->plugin_name : "dbi",
+ db->name, column_names, column_num,
/* interval = */ (db->interval > 0) ? db->interval : 0);
/* 0 = error; 1 = success; */
char *connect_id;
char *username;
char *password;
+ char *plugin_name;
udb_query_preparation_area_t **q_prep_areas;
udb_query_t **queries;
sfree(db->username);
sfree(db->password);
sfree(db->queries);
+ sfree(db->plugin_name);
if (db->q_prep_areas != NULL)
for (size_t i = 0; i < db->queries_num; ++i)
db->connect_id = NULL;
db->username = NULL;
db->password = NULL;
+ db->plugin_name = NULL;
status = cf_util_get_string(ci, &db->name);
if (status != 0) {
status = cf_util_get_string(child, &db->username);
else if (strcasecmp("Password", child->key) == 0)
status = cf_util_get_string(child, &db->password);
+ else if (strcasecmp("PluginName", child->key) == 0)
+ status = cf_util_get_string(child, &db->plugin_name);
else if (strcasecmp("Query", child->key) == 0)
status = udb_query_pick_from_list(child, queries, queries_num,
&db->queries, &db->queries_num);
status = udb_query_prepare_result(
q, prep_area, (db->host != NULL) ? db->host : hostname_g,
- /* plugin = */ "oracle", db->name, column_names, column_num,
+ /* plugin = */ (db->plugin_name != NULL) ? db->plugin_name : "oracle",
+ db->name, column_names, column_num,
/* interval = */ 0);
if (status != 0) {
ERROR("oracle plugin: o_read_database_query (%s, %s): "
char *password;
char *instance;
+ char *plugin_name;
char *sslmode;
db->instance = sstrdup(name);
+ db->plugin_name = NULL;
+
db->sslmode = NULL;
db->krbsrvname = NULL;
sfree(db->instance);
+ sfree(db->plugin_name);
+
sfree(db->sslmode);
sfree(db->krbsrvname);
else
host = db->host;
- status =
- udb_query_prepare_result(q, prep_area, host, "postgresql", db->instance,
- column_names, (size_t)column_num, db->interval);
+ status = udb_query_prepare_result(
+ q, prep_area, host,
+ (db->plugin_name != NULL) ? db->plugin_name : "postgresql",
+ db->instance, column_names, (size_t)column_num, db->interval);
+
if (0 != status) {
log_err("udb_query_prepare_result failed with status %i.", status);
BAIL_OUT(-1);
cf_util_get_string(c, &db->password);
else if (0 == strcasecmp(c->key, "Instance"))
cf_util_get_string(c, &db->instance);
+ else if (0 == strcasecmp (c->key, "PluginName"))
+ cf_util_get_string (c, &db->plugin_name);
else if (0 == strcasecmp(c->key, "SSLMode"))
cf_util_get_string(c, &db->sslmode);
else if (0 == strcasecmp(c->key, "KRBSrvName"))