X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Futils_match.c;h=44eaece201f6234a57bb3c449927c9c6b46ecf32;hb=ef6a236ecbfbea57871e74bc8cda4ca2609d9a6d;hp=0f87bc0c56d7810908320296e7b6f97c2ef2b338;hpb=5f3702fcc67d68d428708e9cf5e5897ad2578925;p=collectd.git diff --git a/src/utils_match.c b/src/utils_match.c index 0f87bc0c..44eaece2 100644 --- a/src/utils_match.c +++ b/src/utils_match.c @@ -80,10 +80,17 @@ static int default_callback (const char __attribute__((unused)) *str, gauge_t value; char *endptr = NULL; + if (data->ds_type & UTILS_MATCH_CF_GAUGE_INC) + { + data->value.gauge = isnan (data->value.gauge) ? 1 : data->value.gauge + 1; + data->values_num++; + return(0); + } + if (matches_num < 2) return (-1); - value = strtod (matches[1], &endptr); + value = (gauge_t) strtod (matches[1], &endptr); if (matches[1] == endptr) return (-1); @@ -108,6 +115,10 @@ static int default_callback (const char __attribute__((unused)) *str, if (data->value.gauge < value) data->value.gauge = value; } + else if (data->ds_type & UTILS_MATCH_CF_GAUGE_ADD) + { + data->value.gauge += value; + } else { ERROR ("utils_match: default_callback: obj->ds_type is invalid!"); @@ -131,7 +142,7 @@ static int default_callback (const char __attribute__((unused)) *str, if (matches_num < 2) return (-1); - value = strtoll (matches[1], &endptr, 0); + value = (counter_t) strtoull (matches[1], &endptr, 0); if (matches[1] == endptr) return (-1); @@ -162,7 +173,7 @@ static int default_callback (const char __attribute__((unused)) *str, if (matches_num < 2) return (-1); - value = strtoll (matches[1], &endptr, 0); + value = (derive_t) strtoll (matches[1], &endptr, 0); if (matches[1] == endptr) return (-1); @@ -186,7 +197,7 @@ static int default_callback (const char __attribute__((unused)) *str, if (matches_num < 2) return (-1); - value = strtoll (matches[1], &endptr, 0); + value = (absolute_t) strtoull (matches[1], &endptr, 0); if (matches[1] == endptr) return (-1); @@ -228,7 +239,7 @@ cu_match_t *match_create_callback (const char *regex, const char *excluderegex, return (NULL); memset (obj, '\0', sizeof (cu_match_t)); - status = regcomp (&obj->regex, regex, REG_EXTENDED); + status = regcomp (&obj->regex, regex, REG_EXTENDED | REG_NEWLINE); if (status != 0) { ERROR ("Compiling the regular expression \"%s\" failed.", regex);