X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Ftail.c;h=bcb157255fcd1a30a8048d7977271cb1dc46e027;hb=3d72fbba41444b82b65de1dcade553ba5a2f2a63;hp=01bf6292ac2d1583796d42d387a69b4080d6752f;hpb=0aad516f24e861109627f4b1dc5bfea3b1f621c1;p=collectd.git diff --git a/src/tail.c b/src/tail.c index 01bf6292..bcb15725 100644 --- a/src/tail.c +++ b/src/tail.c @@ -30,6 +30,7 @@ * Instance "exim" * * Regex "S=([1-9][0-9]*)" + * ExcludeRegex "U=root.*S=" * DSType "CounterAdd" * Type "ipt_bytes" * Instance "total" @@ -41,6 +42,7 @@ struct ctail_config_match_s { char *regex; + char *excluderegex; int flags; char *type; char *type_instance; @@ -50,22 +52,6 @@ typedef struct ctail_config_match_s ctail_config_match_t; cu_tail_match_t **tail_match_list = NULL; size_t tail_match_list_num = 0; -static int ctail_config_add_string (const char *name, char **dest, oconfig_item_t *ci) -{ - if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) - { - WARNING ("tail plugin: `%s' needs exactly one string argument.", name); - return (-1); - } - - sfree (*dest); - *dest = strdup (ci->values[0].value.string); - if (*dest == NULL) - return (-1); - - return (0); -} /* int ctail_config_add_string */ - static int ctail_config_add_match_dstype (ctail_config_match_t *cm, oconfig_item_t *ci) { @@ -101,6 +87,26 @@ static int ctail_config_add_match_dstype (ctail_config_match_t *cm, else cm->flags = 0; } + else if (strncasecmp ("Derive", ci->values[0].value.string, strlen ("Derive")) == 0) + { + cm->flags = UTILS_MATCH_DS_TYPE_DERIVE; + if (strcasecmp ("DeriveSet", ci->values[0].value.string) == 0) + cm->flags |= UTILS_MATCH_CF_DERIVE_SET; + else if (strcasecmp ("DeriveAdd", ci->values[0].value.string) == 0) + cm->flags |= UTILS_MATCH_CF_DERIVE_ADD; + else if (strcasecmp ("DeriveInc", ci->values[0].value.string) == 0) + cm->flags |= UTILS_MATCH_CF_DERIVE_INC; + else + cm->flags = 0; + } + else if (strncasecmp ("Absolute", ci->values[0].value.string, strlen ("Absolute")) == 0) + { + cm->flags = UTILS_MATCH_DS_TYPE_ABSOLUTE; + if (strcasecmp ("AbsoluteSet", ci->values[0].value.string) == 0) + cm->flags |= UTILS_MATCH_CF_ABSOLUTE_SET; + else + cm->flags = 0; + } else { cm->flags = 0; @@ -136,13 +142,15 @@ static int ctail_config_add_match (cu_tail_match_t *tm, oconfig_item_t *option = ci->children + i; if (strcasecmp ("Regex", option->key) == 0) - status = ctail_config_add_string ("Regex", &cm.regex, option); + status = cf_util_get_string (option, &cm.regex); + else if (strcasecmp ("ExcludeRegex", option->key) == 0) + status = cf_util_get_string (option, &cm.excluderegex); else if (strcasecmp ("DSType", option->key) == 0) status = ctail_config_add_match_dstype (&cm, option); else if (strcasecmp ("Type", option->key) == 0) - status = ctail_config_add_string ("Type", &cm.type, option); + status = cf_util_get_string (option, &cm.type); else if (strcasecmp ("Instance", option->key) == 0) - status = ctail_config_add_string ("Instance", &cm.type_instance, option); + status = cf_util_get_string (option, &cm.type_instance); else { WARNING ("tail plugin: Option `%s' not allowed here.", option->key); @@ -181,8 +189,8 @@ static int ctail_config_add_match (cu_tail_match_t *tm, if (status == 0) { - status = tail_match_add_match_simple (tm, cm.regex, cm.flags, - "tail", plugin_instance, cm.type, cm.type_instance); + status = tail_match_add_match_simple (tm, cm.regex, cm.excluderegex, + cm.flags, "tail", plugin_instance, cm.type, cm.type_instance); if (status != 0) { @@ -191,6 +199,7 @@ static int ctail_config_add_match (cu_tail_match_t *tm, } sfree (cm.regex); + sfree (cm.excluderegex); sfree (cm.type); sfree (cm.type_instance); @@ -233,7 +242,7 @@ static int ctail_config_add_file (oconfig_item_t *ci) status = 0; } else if (strcasecmp ("Instance", option->key) == 0) - status = ctail_config_add_string ("Instance", &plugin_instance, option); + status = cf_util_get_string (option, &plugin_instance); else { WARNING ("tail plugin: Option `%s' not allowed here.", option->key); @@ -305,7 +314,7 @@ static int ctail_init (void) static int ctail_read (void) { int success = 0; - int i; + size_t i; for (i = 0; i < tail_match_list_num; i++) { @@ -314,7 +323,7 @@ static int ctail_read (void) status = tail_match_read (tail_match_list[i]); if (status != 0) { - ERROR ("tail plugin: tail_match_read[%i] failed.", i); + ERROR ("tail plugin: tail_match_read[%zu] failed.", i); } else { @@ -329,7 +338,7 @@ static int ctail_read (void) static int ctail_shutdown (void) { - int i; + size_t i; for (i = 0; i < tail_match_list_num; i++) {