X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Ftail.c;h=5c74e3dfcfda2a9acbf07044f109e100dee36bec;hb=b24fe01f603e1422de29c2cf090eabb043df1965;hp=d5166b2a7a5d5c57857207aa18dab851ccc39367;hpb=8f4a48a804f9d95010cf5ad469e4729cebc3e0e9;p=collectd.git diff --git a/src/tail.c b/src/tail.c index d5166b2a..5c74e3df 100644 --- a/src/tail.c +++ b/src/tail.c @@ -80,6 +80,10 @@ static int ctail_config_add_match_dstype (ctail_config_match_t *cm, cm->flags |= UTILS_MATCH_CF_GAUGE_MAX; else if (strcasecmp ("GaugeLast", ci->values[0].value.string) == 0) cm->flags |= UTILS_MATCH_CF_GAUGE_LAST; + else if (strcasecmp ("GaugeInc", ci->values[0].value.string) == 0) + cm->flags |= UTILS_MATCH_CF_GAUGE_INC; + else if (strcasecmp ("GaugeAdd", ci->values[0].value.string) == 0) + cm->flags |= UTILS_MATCH_CF_GAUGE_ADD; else cm->flags = 0; } @@ -220,7 +224,6 @@ static int ctail_config_add_file (oconfig_item_t *ci) cdtime_t interval = 0; char *plugin_instance = NULL; int num_matches = 0; - int status; int i; if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) @@ -233,14 +236,14 @@ static int ctail_config_add_file (oconfig_item_t *ci) if (tm == NULL) { ERROR ("tail plugin: tail_match_create (%s) failed.", - ci->values[0].value.string); + ci->values[0].value.string); return (-1); } - status = 0; for (i = 0; i < ci->children_num; i++) { oconfig_item_t *option = ci->children + i; + int status = 0; if (strcasecmp ("Instance", option->key) == 0) status = cf_util_get_string (option, &plugin_instance); @@ -250,7 +253,7 @@ static int ctail_config_add_file (oconfig_item_t *ci) { status = ctail_config_add_match (tm, plugin_instance, option, interval); if (status == 0) - num_matches++; + num_matches++; /* Be mild with failed matches.. */ status = 0; } @@ -263,10 +266,12 @@ static int ctail_config_add_file (oconfig_item_t *ci) break; } /* for (i = 0; i < ci->children_num; i++) */ + sfree (plugin_instance); + if (num_matches == 0) { ERROR ("tail plugin: No (valid) matches found for file `%s'.", - ci->values[0].value.string); + ci->values[0].value.string); tail_match_destroy (tm); return (-1); } @@ -275,7 +280,7 @@ static int ctail_config_add_file (oconfig_item_t *ci) cu_tail_match_t **temp; temp = (cu_tail_match_t **) realloc (tail_match_list, - sizeof (cu_tail_match_t *) * (tail_match_list_num + 1)); + sizeof (cu_tail_match_t *) * (tail_match_list_num + 1)); if (temp == NULL) { ERROR ("tail plugin: realloc failed."); @@ -327,7 +332,6 @@ static int ctail_read (user_data_t *ud) static int ctail_init (void) { - struct timespec cb_interval; char str[255]; user_data_t ud; size_t i; @@ -338,12 +342,13 @@ static int ctail_init (void) return (-1); } + memset(&ud, '\0', sizeof(ud)); + for (i = 0; i < tail_match_list_num; i++) { ud.data = (void *)tail_match_list[i]; ssnprintf(str, sizeof(str), "tail-%zu", i); - CDTIME_T_TO_TIMESPEC (tail_match_list_intervals[i], &cb_interval); - plugin_register_complex_read (NULL, str, ctail_read, &cb_interval, &ud); + plugin_register_complex_read (NULL, str, ctail_read, tail_match_list_intervals[i], &ud); } return (0);