From: Marc Fournier Date: Fri, 26 Jul 2013 13:24:37 +0000 (+0200) Subject: statsd plugin: add TimerSum option X-Git-Tag: collectd-5.4.0~9 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=9c7fee6fa1c83bd76b39d16fe5376cfb6ef192e4;p=collectd.git statsd plugin: add TimerSum option --- diff --git a/src/statsd.c b/src/statsd.c index 1045aeaa..731a6e8c 100644 --- a/src/statsd.c +++ b/src/statsd.c @@ -81,6 +81,7 @@ static size_t conf_timer_percentile_num = 0; static _Bool conf_timer_lower = 0; static _Bool conf_timer_upper = 0; +static _Bool conf_timer_sum = 0; /* Must hold metrics_lock when calling this function. */ static statsd_metric_t *statsd_metric_lookup_unsafe (char const *name, /* {{{ */ @@ -632,6 +633,8 @@ static int statsd_config (oconfig_item_t *ci) /* {{{ */ cf_util_get_boolean (child, &conf_timer_lower); else if (strcasecmp ("TimerUpper", child->key) == 0) cf_util_get_boolean (child, &conf_timer_upper); + else if (strcasecmp ("TimerSum", child->key) == 0) + cf_util_get_boolean (child, &conf_timer_sum); else if (strcasecmp ("TimerPercentile", child->key) == 0) statsd_config_timer_percentile (child); else @@ -749,6 +752,14 @@ static int statsd_metric_submit_unsafe (char const *name, /* {{{ */ plugin_dispatch_values (&vl); } + if (conf_timer_sum) { + ssnprintf (vl.type_instance, sizeof (vl.type_instance), + "%s-sum", name); + values[0].gauge = CDTIME_T_TO_DOUBLE ( + latency_counter_get_sum (metric->latency)); + plugin_dispatch_values (&vl); + } + for (i = 0; i < conf_timer_percentile_num; i++) { ssnprintf (vl.type_instance, sizeof (vl.type_instance), diff --git a/src/utils_latency.c b/src/utils_latency.c index 01c8b5c2..4a250c33 100644 --- a/src/utils_latency.c +++ b/src/utils_latency.c @@ -110,6 +110,13 @@ cdtime_t latency_counter_get_max (latency_counter_t *lc) /* {{{ */ return (lc->max); } /* }}} cdtime_t latency_counter_get_max */ +cdtime_t latency_counter_get_sum (latency_counter_t *lc) /* {{{ */ +{ + if (lc == NULL) + return (0); + return (lc->sum); +} /* }}} cdtime_t latency_counter_get_sum */ + cdtime_t latency_counter_get_average (latency_counter_t *lc) /* {{{ */ { double average; diff --git a/src/utils_latency.h b/src/utils_latency.h index 3da23082..352a4ec3 100644 --- a/src/utils_latency.h +++ b/src/utils_latency.h @@ -38,6 +38,7 @@ void latency_counter_reset (latency_counter_t *lc); cdtime_t latency_counter_get_min (latency_counter_t *lc); cdtime_t latency_counter_get_max (latency_counter_t *lc); +cdtime_t latency_counter_get_sum (latency_counter_t *lc); cdtime_t latency_counter_get_average (latency_counter_t *lc); cdtime_t latency_counter_get_percentile (latency_counter_t *lc, double percent);