summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bea5daa)
raw | patch | inline | side by side (parent: bea5daa)
author | Pavel Rochnyack <pavel2000@ngs.ru> | |
Thu, 12 May 2016 10:24:00 +0000 (16:24 +0600) | ||
committer | Pavel Rochnyack <pavel2000@ngs.ru> | |
Mon, 10 Jul 2017 10:13:15 +0000 (17:13 +0700) |
src/collectd.conf.in | patch | blob | history | |
src/collectd.conf.pod | patch | blob | history | |
src/dbi.c | patch | blob | history | |
src/oracle.c | patch | blob | history | |
src/postgresql.c | patch | blob | history |
diff --git a/src/collectd.conf.in b/src/collectd.conf.in
index 3eaeb5d535096c0f0813d8f928666af6df31459b..8ab20d192b2ccc482d95a72e11c9ca092435cd10 100644 (file)
--- a/src/collectd.conf.in
+++ b/src/collectd.conf.in
# </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"
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index 9b31de7ec28d16324ba74f43048b2fef763271fb..b4fe2f967bd48dbee29f047ba867ab3590096e26 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
</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
diff --git a/src/dbi.c b/src/dbi.c
index ac307ff2e01f57f00268c77870c8991b28323892..ba91bffc51b24b8b769058ad8712a0c983de5e0d 100644 (file)
--- a/src/dbi.c
+++ b/src/dbi.c
{
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; */
diff --git a/src/oracle.c b/src/oracle.c
index 2d98f0aa3d2734fc682e8534ff76d623647f64e3..69e519bdf1280a6f36c3def18c21dc15e8967b4a 100644 (file)
--- a/src/oracle.c
+++ b/src/oracle.c
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): "
diff --git a/src/postgresql.c b/src/postgresql.c
index d0c0ae1324a457e5aeb706196536878fbea10a11..70467c21a2b8e9133ddd486584f1aefa423962e2 100644 (file)
--- a/src/postgresql.c
+++ b/src/postgresql.c
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"))