summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f02fb0e)
raw | patch | inline | side by side (parent: f02fb0e)
author | Florian Forster <octo@collectd.org> | |
Sun, 31 May 2015 20:54:47 +0000 (22:54 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Sun, 31 May 2015 20:54:47 +0000 (22:54 +0200) |
Previously, when multiple metrics were specified on one "Collect" line and one
didn't exist, all *following* metrics would be ignored. This patch changes this
to continue in this case and configure as many metrics as possible.
didn't exist, all *following* metrics would be ignored. This patch changes this
to continue in this case and configure as many metrics as possible.
src/tail_csv.c | patch | blob | history |
diff --git a/src/tail_csv.c b/src/tail_csv.c
index 4794f82eb542fb4c69392e3b53e1c37426c8cc2d..740095d6100c5c1a03fa37dc007d56828b234dc5 100644 (file)
--- a/src/tail_csv.c
+++ b/src/tail_csv.c
sfree(id);
}
-static int tcsv_config_add_instance_collect(instance_definition_t *id, oconfig_item_t *ci){
+static int tcsv_config_add_instance_collect(instance_definition_t *id, oconfig_item_t *ci) {
metric_definition_t *metric;
metric_definition_t **metric_list;
- int i,j,n;
+ size_t metric_list_size;
+ int i;
- if (ci->values_num < 1){
+ if (ci->values_num < 1) {
WARNING("tail_csv plugin: The `Collect' config option needs at least one argument.");
return (-1);
}
- /* Verify string arguments */
- for (i = 0; i < ci->values_num; ++i)
- if (ci->values[i].type != OCONFIG_TYPE_STRING){
- WARNING("tail_csv plugin: All arguments to `Collect' must be strings.");
- return (-1);
- }
-
- n = id->metric_list_len + ci->values_num;
- metric_list = (metric_definition_t **)realloc(id->metric_list, sizeof(metric_definition_t *) * n);
+ metric_list_size = id->metric_list_len + (size_t) ci->values_num;
+ metric_list = realloc (id->metric_list, sizeof (*id->metric_list) * metric_list_size);
if (metric_list == NULL)
return (-1);
-
id->metric_list = metric_list;
- for (i = id->metric_list_len, j=0; i < n; ++i, ++j){
+ for (i = 0; i < ci->values_num; i++) {
+ char *metric_name;
+
+ if (ci->values[i].type != OCONFIG_TYPE_STRING) {
+ WARNING("tail_csv plugin: All arguments to `Collect' must be strings.");
+ continue;
+ }
+ metric_name = ci->values[i].value.string;
+
for (metric = metric_head; metric != NULL; metric = metric->next)
- if (strcasecmp(ci->values[j].value.string, metric->name) == 0)
+ if (strcasecmp(metric_name, metric->name) == 0)
break;
- if (metric == NULL){
- WARNING("tail_csv plugin: `Collect' argument not found `%s'.", ci->values[j].value.string);
- return (-1);
+ if (metric == NULL) {
+ WARNING ("tail_csv plugin: `Collect' argument not found `%s'.", metric_name);
+ continue;
}
- id->metric_list[i] = metric;
+ id->metric_list[id->metric_list_len] = metric;
id->metric_list_len++;
}