From: Andre Ferraz Date: Thu, 24 Jul 2014 16:02:32 +0000 (-0300) Subject: Including DStypes GaugeInc and GaugeAdd for tail plugin X-Git-Tag: collectd-5.5.0~249^2~1 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=47d95c8a005b3ad470116055ebf1d20355748cc4;p=collectd.git Including DStypes GaugeInc and GaugeAdd for tail plugin --- diff --git a/src/tail.c b/src/tail.c index 20f2a9b4..b2d52268 100644 --- a/src/tail.c +++ b/src/tail.c @@ -75,6 +75,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; } diff --git a/src/utils_match.c b/src/utils_match.c index 062bcfe3..44eaece2 100644 --- a/src/utils_match.c +++ b/src/utils_match.c @@ -80,6 +80,13 @@ 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); @@ -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!"); diff --git a/src/utils_match.h b/src/utils_match.h index 36abe30c..d32178a4 100644 --- a/src/utils_match.h +++ b/src/utils_match.h @@ -37,6 +37,8 @@ #define UTILS_MATCH_CF_GAUGE_MIN 0x02 #define UTILS_MATCH_CF_GAUGE_MAX 0x04 #define UTILS_MATCH_CF_GAUGE_LAST 0x08 +#define UTILS_MATCH_CF_GAUGE_INC 0x09 +#define UTILS_MATCH_CF_GAUGE_ADD 0x10 #define UTILS_MATCH_CF_COUNTER_SET 0x01 #define UTILS_MATCH_CF_COUNTER_ADD 0x02