X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Ftail.c;h=25cbcd4c1b5188df787e843c60aecb895aad5688;hb=8341769294c500d8b0aa8e689aa0cfc72a63a09b;hp=7d77e253a49d6a13d4c5a99a50cd666ce3b9266e;hpb=4aecad69a5640d208567d569636bfc2ddfed4b92;p=collectd.git diff --git a/src/tail.c b/src/tail.c index 7d77e253..25cbcd4c 100644 --- a/src/tail.c +++ b/src/tail.c @@ -30,7 +30,8 @@ * Instance "exim" * * Regex "S=([1-9][0-9]*)" - * DSType "CouterAdd" + * 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; @@ -92,15 +94,35 @@ static int ctail_config_add_match_dstype (ctail_config_match_t *cm, else if (strncasecmp ("Counter", ci->values[0].value.string, strlen ("Counter")) == 0) { cm->flags = UTILS_MATCH_DS_TYPE_COUNTER; - if (strcasecmp ("CouterSet", ci->values[0].value.string) == 0) + if (strcasecmp ("CounterSet", ci->values[0].value.string) == 0) cm->flags |= UTILS_MATCH_CF_COUNTER_SET; - else if (strcasecmp ("CouterAdd", ci->values[0].value.string) == 0) + else if (strcasecmp ("CounterAdd", ci->values[0].value.string) == 0) cm->flags |= UTILS_MATCH_CF_COUNTER_ADD; - else if (strcasecmp ("CouterInc", ci->values[0].value.string) == 0) + else if (strcasecmp ("CounterInc", ci->values[0].value.string) == 0) cm->flags |= UTILS_MATCH_CF_COUNTER_INC; 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; @@ -137,6 +159,9 @@ static int ctail_config_add_match (cu_tail_match_t *tm, if (strcasecmp ("Regex", option->key) == 0) status = ctail_config_add_string ("Regex", &cm.regex, option); + else if (strcasecmp ("ExcludeRegex", option->key) == 0) + status = ctail_config_add_string ("ExcludeRegex", &cm.excluderegex, + option); else if (strcasecmp ("DSType", option->key) == 0) status = ctail_config_add_match_dstype (&cm, option); else if (strcasecmp ("Type", option->key) == 0) @@ -181,8 +206,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 +216,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); @@ -305,7 +331,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 +340,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 +355,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++) {