summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a92f88f)
raw | patch | inline | side by side (parent: a92f88f)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Wed, 11 Aug 2010 13:45:01 +0000 (15:45 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Wed, 11 Aug 2010 13:45:01 +0000 (15:45 +0200) |
The "legacy mode" supported an old configuration schema of the
PostgreSQL plugin. This commit removes it, so only the recommended
configuration remains possible.
PostgreSQL plugin. This commit removes it, so only the recommended
configuration remains possible.
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index 01f0f824374b5199953e330f07a90d2317345ac5..936088eb7df6cda19b4a910706ef15b81eb5210f 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
The returned lines will be handled separately one after another.
-=item B<Query> I<sql query statement>
-
-This is a deprecated synonym for B<Statement>. It will be removed in version 5
-of collectd.
-
=item B<Param> I<hostname>|I<database>|I<username>|I<interval>
Specify the parameters which should be passed to the SQL query. The parameters
@@ -3305,21 +3300,6 @@ This option is required inside a B<Result> block and may be specified multiple
times. If multiple B<ValuesFrom> options are specified, the columns are read
in the given order.
-=item B<Column> I<type> [I<type instance>]
-
-This is a deprecated alternative to a B<Result> block. It will be removed in
-version 5 of collectd. It is equivalent to the following B<Result> block:
-
- <Result>
- Type I<type>
- InstancePrefix I<type instance>
- ValuesFrom I<name of the x. column>
- </Result>
-
-The order of the B<Column> options defines which columns of the query result
-should be used. The first option specifies the data found in the first column,
-the second option that of the second column, and so on.
-
=item B<MinVersion> I<version>
=item B<MaxVersion> I<version>
and patch-level versions, each represented as two-decimal-digit numbers. For
example, version 8.2.3 will become 80203.
-=item B<MinPGVersion> I<version>
-
-=item B<MaxPGVersion> I<version>
-
-These are deprecated synonyms for B<MinVersion> and B<MaxVersion>
-respectively. They will be removed in version 5 of collectd.
-
=back
The following predefined queries are available (the definitions can be found
diff --git a/src/dbi.c b/src/dbi.c
index 77f393f5fc6a606c8151860617f4da4b9f62a0d3..cd9240a62931861bf2a468a5c8a8d49e6ed20a55 100644 (file)
--- a/src/dbi.c
+++ b/src/dbi.c
oconfig_item_t *child = ci->children + i;
if (strcasecmp ("Query", child->key) == 0)
udb_query_create (&queries, &queries_num, child,
- /* callback = */ NULL, /* legacy mode = */ 0);
+ /* callback = */ NULL);
else if (strcasecmp ("Database", child->key) == 0)
cdbi_config_add_database (child);
else
diff --git a/src/oracle.c b/src/oracle.c
index 3fe21254ab33f08391ec7c45c6c26216ec074816..2f218519e34bfcc30faf29847eba91c00961e2e2 100644 (file)
--- a/src/oracle.c
+++ b/src/oracle.c
oconfig_item_t *child = ci->children + i;
if (strcasecmp ("Query", child->key) == 0)
udb_query_create (&queries, &queries_num, child,
- /* callback = */ NULL, /* legacy mode = */ 0);
+ /* callback = */ NULL);
else if (strcasecmp ("Database", child->key) == 0)
o_config_add_database (child);
else
diff --git a/src/postgresql.c b/src/postgresql.c
index dd53cb4fd2b018fd11dd18a8d1c5788b7cc95a04..175cc095732d46c224684c469e2c64c21b929cd6 100644 (file)
--- a/src/postgresql.c
+++ b/src/postgresql.c
if (0 == strcasecmp (c->key, "Query"))
udb_query_create (&queries, &queries_num, c,
- /* callback = */ config_query_callback,
- /* legacy mode = */ 1);
+ /* callback = */ config_query_callback);
else if (0 == strcasecmp (c->key, "Database"))
c_psql_config_database (c);
else
diff --git a/src/utils_db_query.c b/src/utils_db_query.c
index 7d594d812a4e0bf2f0f1b9c3e936ec762f917e5a..78c8052e275336ea572f4a863e02fdfdd5768b47 100644 (file)
--- a/src/utils_db_query.c
+++ b/src/utils_db_query.c
char **values;
size_t values_num;
- /* Legacy data */
- int legacy_mode;
- size_t legacy_position;
- /* When in legacy mode:
- * - type/ds hold the format of the data
- * - instance_prefix is used as type-instance if non-NULL
- * - legacy_position holds the index of the column to use as value.
- */
-
udb_result_t *next;
}; /* }}} */
char *statement;
void *user_data;
- int legacy_mode;
-
unsigned int min_version;
unsigned int max_version;
return (0);
} /* }}} int udb_config_set_uint */
-/*
- * Legacy result private functions
- */
-static void udb_legacy_result_finish_result (const udb_result_t const *r, /* {{{ */
- udb_result_preparation_area_t *prep_area)
-{
- if ((r == NULL) || (prep_area))
- return;
-
- assert (r->legacy_mode == 1);
-
- prep_area->ds = NULL;
-} /* }}} void udb_legacy_result_finish_result */
-
-static int udb_legacy_result_handle_result (udb_result_t *r, /* {{{ */
- udb_query_preparation_area_t *q_area,
- udb_result_preparation_area_t *r_area,
- const udb_query_t const *q, char **column_values)
-{
- value_list_t vl = VALUE_LIST_INIT;
- value_t value;
- char *value_str;
-
- assert (r->legacy_mode == 1);
- assert (r_area->ds != NULL);
- assert (r_area->ds->ds_num == 1);
-
- vl.values = &value;
- vl.values_len = 1;
-
- value_str = column_values[r->legacy_position];
- if (0 != parse_value (value_str, &vl.values[0], r_area->ds->ds[0].type))
- {
- ERROR ("db query utils: udb_legacy_result_handle_result: "
- "Parsing `%s' as %s failed.", value_str,
- DS_TYPE_TO_STRING (r_area->ds->ds[0].type));
- errno = EINVAL;
- return (-1);
- }
-
- if (q_area->interval > 0)
- vl.interval = q_area->interval;
-
- sstrncpy (vl.host, q_area->host, sizeof (vl.host));
- sstrncpy (vl.plugin, q_area->plugin, sizeof (vl.plugin));
- sstrncpy (vl.plugin_instance, q_area->db_name, sizeof (vl.type_instance));
- sstrncpy (vl.type, r->type, sizeof (vl.type));
-
- if (r->instance_prefix != NULL)
- sstrncpy (vl.type_instance, r->instance_prefix,
- sizeof (vl.type_instance));
-
- plugin_dispatch_values (&vl);
-
- return (0);
-} /* }}} int udb_legacy_result_handle_result */
-
-static int udb_legacy_result_prepare_result (const udb_result_t const *r, /* {{{ */
- udb_result_preparation_area_t *prep_area,
- char **column_names, size_t column_num)
-{
- if (r == NULL)
- return (-EINVAL);
-
- assert (r->legacy_mode == 1);
-
- /* Make sure previous preparations are cleaned up. */
- udb_legacy_result_finish_result (r, prep_area);
-
- if (r->legacy_position >= column_num)
- {
- ERROR ("db query utils: The legacy configuration specified (at least) "
- "%zu `Column's, but the query returned only %zu columns!",
- r->legacy_position + 1, column_num);
- return (-ENOENT);
- }
-
- /* Read `ds' and check number of values {{{ */
- prep_area->ds = plugin_get_ds (r->type);
- if (prep_area->ds == NULL)
- {
- ERROR ("db query utils: udb_result_prepare_result: Type `%s' is not "
- "known by the daemon. See types.db(5) for details.",
- r->type);
- return (-1);
- }
-
- if (prep_area->ds->ds_num != 1)
- {
- ERROR ("db query utils: udb_result_prepare_result: The type `%s' "
- "requires exactly %i values, but the legacy configuration "
- "requires exactly one!",
- r->type,
- prep_area->ds->ds_num);
- return (-1);
- }
- /* }}} */
-
- return (0);
-} /* }}} int udb_legacy_result_prepare_result */
-
-static int udb_legacy_result_create (const char *query_name, /* {{{ */
- udb_result_t **r_head, oconfig_item_t *ci, size_t position)
-{
- udb_result_t *r;
-
- if ((ci->values_num < 1) || (ci->values_num > 2)
- || (ci->values[0].type != OCONFIG_TYPE_STRING)
- || ((ci->values_num == 2)
- && (ci->values[1].type != OCONFIG_TYPE_STRING)))
- {
- WARNING ("db query utils: The `Column' block needs either one or two "
- "string arguments.");
- return (-1);
- }
-
- r = (udb_result_t *) malloc (sizeof (*r));
- if (r == NULL)
- {
- ERROR ("db query utils: malloc failed.");
- return (-1);
- }
- memset (r, 0, sizeof (*r));
-
- r->legacy_mode = 1;
- r->legacy_position = position;
-
- r->type = strdup (ci->values[0].value.string);
- if (r->type == NULL)
- {
- ERROR ("db query utils: strdup failed.");
- free (r);
- return (-1);
- }
-
- r->instance_prefix = NULL;
- if (ci->values_num == 2)
- {
- r->instance_prefix = strdup (ci->values[1].value.string);
- if (r->instance_prefix == NULL)
- {
- ERROR ("db query utils: strdup failed.");
- free (r->type);
- free (r);
- return (-1);
- }
- }
-
- /* If all went well, add this result to the list of results. */
- if (*r_head == NULL)
- {
- *r_head = r;
- }
- else
- {
- udb_result_t *last;
-
- last = *r_head;
- while (last->next != NULL)
- last = last->next;
-
- last->next = r;
- }
-
- return (0);
-} /* }}} int udb_legacy_result_create */
-
/*
* Result private functions
*/
size_t i;
assert (r != NULL);
- assert (r->legacy_mode == 0);
assert (r_area->ds != NULL);
assert (((size_t) r_area->ds->ds_num) == r->values_num);
if ((r == NULL) || (prep_area == NULL))
return;
- if (r->legacy_mode == 1)
- {
- udb_legacy_result_finish_result (r, prep_area);
- return;
- }
-
- assert (r->legacy_mode == 0);
-
prep_area->ds = NULL;
sfree (prep_area->instances_pos);
sfree (prep_area->values_pos);
assert (r && q_area && r_area);
- if (r->legacy_mode == 1)
- return (udb_legacy_result_handle_result (r, q_area, r_area,
- q, column_values));
-
- assert (r->legacy_mode == 0);
-
for (i = 0; i < r->instances_num; i++)
r_area->instances_buffer[i] = column_values[r_area->instances_pos[i]];
if ((r == NULL) || (prep_area == NULL))
return (-EINVAL);
- if (r->legacy_mode == 1)
- return (udb_legacy_result_prepare_result (r, prep_area,
- column_names, column_num));
-
- assert (r->legacy_mode == 0);
-
#define BAIL_OUT(status) \
prep_area->ds = NULL; \
sfree (prep_area->instances_pos); \
*/
int udb_query_create (udb_query_t ***ret_query_list, /* {{{ */
size_t *ret_query_list_len, oconfig_item_t *ci,
- udb_query_create_callback_t cb, int legacy_mode)
+ udb_query_create_callback_t cb)
{
udb_query_t **query_list;
size_t query_list_len;
int status;
int i;
- size_t legacy_position;
-
if ((ret_query_list == NULL) || (ret_query_list_len == NULL))
return (-EINVAL);
query_list = *ret_query_list;
return (-1);
}
memset (q, 0, sizeof (*q));
- q->legacy_mode = legacy_mode;
q->min_version = 0;
q->max_version = UINT_MAX;
- legacy_position = 0;
-
status = udb_config_set_string (&q->name, ci);
if (status != 0)
{
else if (strcasecmp ("MaxVersion", child->key) == 0)
status = udb_config_set_uint (&q->max_version, child);
- /* PostgreSQL compatibility code */
- else if ((strcasecmp ("Query", child->key) == 0)
- && (q->legacy_mode == 1))
- {
- WARNING ("db query utils: Query `%s': The `Query' option is "
- "deprecated. Please use `Statement' instead.",
- q->name);
- status = udb_config_set_string (&q->statement, child);
- }
- else if ((strcasecmp ("Column", child->key) == 0)
- && (q->legacy_mode == 1))
- {
- WARNING ("db query utils: Query `%s': The `Column' option is "
- "deprecated. Please use the new syntax instead.",
- q->name);
- status = udb_legacy_result_create (q->name, &q->results, child,
- legacy_position);
- legacy_position++;
- }
- else if ((strcasecmp ("MinPGVersion", child->key) == 0)
- && (q->legacy_mode == 1))
- {
- WARNING ("db query utils: Query `%s': The `MinPGVersion' option is "
- "deprecated. Please use `MinVersion' instead.",
- q->name);
- status = udb_config_set_uint (&q->min_version, child);
- }
- else if ((strcasecmp ("MaxPGVersion", child->key) == 0)
- && (q->legacy_mode == 1))
- {
- WARNING ("db query utils: Query `%s': The `MaxPGVersion' option is "
- "deprecated. Please use `MaxVersion' instead.",
- q->name);
- status = udb_config_set_uint (&q->max_version, child);
- }
-
/* Call custom callbacks */
else if (cb != NULL)
{
diff --git a/src/utils_db_query.h b/src/utils_db_query.h
index fa2b2885679c435245b836f4cbc4ccb01556c5db..846f81c291f8db86df780ee66d721a5c07aa8aea 100644 (file)
--- a/src/utils_db_query.h
+++ b/src/utils_db_query.h
*/
int udb_query_create (udb_query_t ***ret_query_list,
size_t *ret_query_list_len, oconfig_item_t *ci,
- udb_query_create_callback_t cb, int legacy_mode);
+ udb_query_create_callback_t cb);
void udb_query_free (udb_query_t **query_list, size_t query_list_len);
int udb_query_pick_from_list_by_name (const char *name,