X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fstatsd.c;h=d12cb0d5b83d5677f0ba8125c7d29250e7db3353;hb=b4cc5c7399adf79198aea816d44a42df25431d15;hp=5b0bdd693de71088f8ec47f3560b29c4c87f79f5;hpb=79593ed5e0a3def8e91be5b1de15a536af2d4a92;p=collectd.git diff --git a/src/statsd.c b/src/statsd.c index 5b0bdd69..d12cb0d5 100644 --- a/src/statsd.c +++ b/src/statsd.c @@ -562,6 +562,7 @@ static int statsd_network_init (struct pollfd **ret_fds, /* {{{ */ if (tmp == NULL) { ERROR ("statsd plugin: realloc failed."); + close (fd); continue; } fds = tmp; @@ -851,8 +852,19 @@ static int statsd_metric_submit_unsafe (char const *name, /* {{{ */ else values[0].gauge = (gauge_t) c_avl_size (metric->set); } - else - values[0].derive = (derive_t) metric->value; + else { /* STATSD_COUNTER */ + /* + * Expand a single value to two metrics: + * + * - The absolute counter, as a gauge + * - A derived rate for this counter + */ + values[0].derive = (derive_t) metric->value; + plugin_dispatch_values(&vl); + + sstrncpy(vl.type, "gauge", sizeof (vl.type)); + values[0].gauge = (gauge_t) metric->value; + } return (plugin_dispatch_values (&vl)); } /* }}} int statsd_metric_submit_unsafe */ @@ -942,7 +954,7 @@ static int statsd_shutdown (void) /* {{{ */ while (c_avl_pick (metrics_tree, &key, &value) == 0) { sfree (key); - sfree (value); + statsd_metric_free (value); } c_avl_destroy (metrics_tree); metrics_tree = NULL;