projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
src/daemon/common_test.c: Avoid nesting composite literals.
[collectd.git]
/
src
/
statsd.c
diff --git
a/src/statsd.c
b/src/statsd.c
index
8acd9fd
..
491fe42
100644
(file)
--- a/
src/statsd.c
+++ b/
src/statsd.c
@@
-25,9
+25,9
@@
*/
#include "collectd.h"
*/
#include "collectd.h"
+
#include "plugin.h"
#include "common.h"
#include "plugin.h"
#include "common.h"
-#include "configfile.h"
#include "utils_avltree.h"
#include "utils_latency.h"
#include "utils_avltree.h"
#include "utils_latency.h"
@@
-501,7
+501,6
@@
static int statsd_network_init (struct pollfd **ret_fds, /* {{{ */
size_t fds_num = 0;
struct addrinfo *ai_list;
size_t fds_num = 0;
struct addrinfo *ai_list;
- struct addrinfo *ai_ptr;
int status;
char const *node = (conf_node != NULL) ? conf_node : STATSD_DEFAULT_NODE;
int status;
char const *node = (conf_node != NULL) ? conf_node : STATSD_DEFAULT_NODE;
@@
-522,7
+521,7
@@
static int statsd_network_init (struct pollfd **ret_fds, /* {{{ */
return (status);
}
return (status);
}
- for (ai_ptr = ai_list; ai_ptr != NULL; ai_ptr = ai_ptr->ai_next)
+ for (
struct addrinfo *
ai_ptr = ai_list; ai_ptr != NULL; ai_ptr = ai_ptr->ai_next)
{
int fd;
struct pollfd *tmp;
{
int fd;
struct pollfd *tmp;
@@
-589,7
+588,6
@@
static void *statsd_network_thread (void *args) /* {{{ */
struct pollfd *fds = NULL;
size_t fds_num = 0;
int status;
struct pollfd *fds = NULL;
size_t fds_num = 0;
int status;
- size_t i;
status = statsd_network_init (&fds, &fds_num);
if (status != 0)
status = statsd_network_init (&fds, &fds_num);
if (status != 0)
@@
-613,7
+611,7
@@
static void *statsd_network_thread (void *args) /* {{{ */
break;
}
break;
}
- for (i = 0; i < fds_num; i++)
+ for (
size_t
i = 0; i < fds_num; i++)
{
if ((fds[i].revents & (POLLIN | POLLPRI)) == 0)
continue;
{
if ((fds[i].revents & (POLLIN | POLLPRI)) == 0)
continue;
@@
-624,7
+622,7
@@
static void *statsd_network_thread (void *args) /* {{{ */
} /* while (!network_thread_shutdown) */
/* Clean up */
} /* while (!network_thread_shutdown) */
/* Clean up */
- for (i = 0; i < fds_num; i++)
+ for (
size_t
i = 0; i < fds_num; i++)
close (fds[i].fd);
sfree (fds);
close (fds[i].fd);
sfree (fds);
@@
-664,9
+662,7
@@
static int statsd_config_timer_percentile (oconfig_item_t *ci) /* {{{ */
static int statsd_config (oconfig_item_t *ci) /* {{{ */
{
static int statsd_config (oconfig_item_t *ci) /* {{{ */
{
- int i;
-
- for (i = 0; i < ci->children_num; i++)
+ for (int i = 0; i < ci->children_num; i++)
{
oconfig_item_t *child = ci->children + i;
{
oconfig_item_t *child = ci->children + i;
@@
-756,12
+752,10
@@
static int statsd_metric_clear_set_unsafe (statsd_metric_t *metric) /* {{{ */
/* Must hold metrics_lock when calling this function. */
static int statsd_metric_submit_unsafe (char const *name, statsd_metric_t *metric) /* {{{ */
{
/* Must hold metrics_lock when calling this function. */
static int statsd_metric_submit_unsafe (char const *name, statsd_metric_t *metric) /* {{{ */
{
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
value_list_t vl = VALUE_LIST_INIT;
- vl.values =
values
;
+ vl.values =
&(value_t) { .gauge = NAN }
;
vl.values_len = 1;
vl.values_len = 1;
- sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "statsd", sizeof (vl.plugin));
if (metric->type == STATSD_GAUGE)
sstrncpy (vl.plugin, "statsd", sizeof (vl.plugin));
if (metric->type == STATSD_GAUGE)
@@
-776,10
+770,9
@@
static int statsd_metric_submit_unsafe (char const *name, statsd_metric_t *metri
sstrncpy (vl.type_instance, name, sizeof (vl.type_instance));
if (metric->type == STATSD_GAUGE)
sstrncpy (vl.type_instance, name, sizeof (vl.type_instance));
if (metric->type == STATSD_GAUGE)
- values[0].gauge = (gauge_t) metric->value;
+ v
l.v
alues[0].gauge = (gauge_t) metric->value;
else if (metric->type == STATSD_TIMER)
{
else if (metric->type == STATSD_TIMER)
{
- size_t i;
_Bool have_events = (metric->updates_num > 0);
/* Make sure all timer metrics share the *same* timestamp. */
_Bool have_events = (metric->updates_num > 0);
/* Make sure all timer metrics share the *same* timestamp. */
@@
-787,7
+780,7
@@
static int statsd_metric_submit_unsafe (char const *name, statsd_metric_t *metri
ssnprintf (vl.type_instance, sizeof (vl.type_instance),
"%s-average", name);
ssnprintf (vl.type_instance, sizeof (vl.type_instance),
"%s-average", name);
- values[0].gauge = have_events
+ v
l.v
alues[0].gauge = have_events
? CDTIME_T_TO_DOUBLE (latency_counter_get_average (metric->latency))
: NAN;
plugin_dispatch_values (&vl);
? CDTIME_T_TO_DOUBLE (latency_counter_get_average (metric->latency))
: NAN;
plugin_dispatch_values (&vl);
@@
-795,7
+788,7
@@
static int statsd_metric_submit_unsafe (char const *name, statsd_metric_t *metri
if (conf_timer_lower) {
ssnprintf (vl.type_instance, sizeof (vl.type_instance),
"%s-lower", name);
if (conf_timer_lower) {
ssnprintf (vl.type_instance, sizeof (vl.type_instance),
"%s-lower", name);
- values[0].gauge = have_events
+ v
l.v
alues[0].gauge = have_events
? CDTIME_T_TO_DOUBLE (latency_counter_get_min (metric->latency))
: NAN;
plugin_dispatch_values (&vl);
? CDTIME_T_TO_DOUBLE (latency_counter_get_min (metric->latency))
: NAN;
plugin_dispatch_values (&vl);
@@
-804,7
+797,7
@@
static int statsd_metric_submit_unsafe (char const *name, statsd_metric_t *metri
if (conf_timer_upper) {
ssnprintf (vl.type_instance, sizeof (vl.type_instance),
"%s-upper", name);
if (conf_timer_upper) {
ssnprintf (vl.type_instance, sizeof (vl.type_instance),
"%s-upper", name);
- values[0].gauge = have_events
+ v
l.v
alues[0].gauge = have_events
? CDTIME_T_TO_DOUBLE (latency_counter_get_max (metric->latency))
: NAN;
plugin_dispatch_values (&vl);
? CDTIME_T_TO_DOUBLE (latency_counter_get_max (metric->latency))
: NAN;
plugin_dispatch_values (&vl);
@@
-813,17
+806,17
@@
static int statsd_metric_submit_unsafe (char const *name, statsd_metric_t *metri
if (conf_timer_sum) {
ssnprintf (vl.type_instance, sizeof (vl.type_instance),
"%s-sum", name);
if (conf_timer_sum) {
ssnprintf (vl.type_instance, sizeof (vl.type_instance),
"%s-sum", name);
- values[0].gauge = have_events
+ v
l.v
alues[0].gauge = have_events
? CDTIME_T_TO_DOUBLE (latency_counter_get_sum (metric->latency))
: NAN;
plugin_dispatch_values (&vl);
}
? CDTIME_T_TO_DOUBLE (latency_counter_get_sum (metric->latency))
: NAN;
plugin_dispatch_values (&vl);
}
- for (i = 0; i < conf_timer_percentile_num; i++)
+ for (
size_t
i = 0; i < conf_timer_percentile_num; i++)
{
ssnprintf (vl.type_instance, sizeof (vl.type_instance),
"%s-percentile-%.0f", name, conf_timer_percentile[i]);
{
ssnprintf (vl.type_instance, sizeof (vl.type_instance),
"%s-percentile-%.0f", name, conf_timer_percentile[i]);
- values[0].gauge = have_events
+ v
l.v
alues[0].gauge = have_events
? CDTIME_T_TO_DOUBLE (latency_counter_get_percentile (metric->latency, conf_timer_percentile[i]))
: NAN;
plugin_dispatch_values (&vl);
? CDTIME_T_TO_DOUBLE (latency_counter_get_percentile (metric->latency, conf_timer_percentile[i]))
: NAN;
plugin_dispatch_values (&vl);
@@
-835,7
+828,7
@@
static int statsd_metric_submit_unsafe (char const *name, statsd_metric_t *metri
sstrncpy (vl.type, "gauge", sizeof (vl.type));
ssnprintf (vl.type_instance, sizeof (vl.type_instance),
"%s-count", name);
sstrncpy (vl.type, "gauge", sizeof (vl.type));
ssnprintf (vl.type_instance, sizeof (vl.type_instance),
"%s-count", name);
- values[0].gauge = latency_counter_get_num (metric->latency);
+ v
l.v
alues[0].gauge = latency_counter_get_num (metric->latency);
plugin_dispatch_values (&vl);
}
plugin_dispatch_values (&vl);
}
@@
-845,9
+838,9
@@
static int statsd_metric_submit_unsafe (char const *name, statsd_metric_t *metri
else if (metric->type == STATSD_SET)
{
if (metric->set == NULL)
else if (metric->type == STATSD_SET)
{
if (metric->set == NULL)
- values[0].gauge = 0.0;
+ v
l.v
alues[0].gauge = 0.0;
else
else
- values[0].gauge = (gauge_t) c_avl_size (metric->set);
+ v
l.v
alues[0].gauge = (gauge_t) c_avl_size (metric->set);
}
else { /* STATSD_COUNTER */
gauge_t delta = nearbyint (metric->value);
}
else { /* STATSD_COUNTER */
gauge_t delta = nearbyint (metric->value);
@@
-859,7
+852,7
@@
static int statsd_metric_submit_unsafe (char const *name, statsd_metric_t *metri
if (conf_counter_sum)
{
sstrncpy (vl.type, "count", sizeof (vl.type));
if (conf_counter_sum)
{
sstrncpy (vl.type, "count", sizeof (vl.type));
- values[0].gauge = delta;
+ v
l.v
alues[0].gauge = delta;
plugin_dispatch_values (&vl);
/* restore vl.type */
plugin_dispatch_values (&vl);
/* restore vl.type */
@@
-871,7
+864,7
@@
static int statsd_metric_submit_unsafe (char const *name, statsd_metric_t *metri
metric->value -= delta;
metric->counter += (derive_t) delta;
metric->value -= delta;
metric->counter += (derive_t) delta;
- values[0].derive = metric->counter;
+ v
l.v
alues[0].derive = metric->counter;
}
return (plugin_dispatch_values (&vl));
}
return (plugin_dispatch_values (&vl));
@@
-885,7
+878,6
@@
static int statsd_read (void) /* {{{ */
char **to_be_deleted = NULL;
size_t to_be_deleted_num = 0;
char **to_be_deleted = NULL;
size_t to_be_deleted_num = 0;
- size_t i;
pthread_mutex_lock (&metrics_lock);
pthread_mutex_lock (&metrics_lock);
@@
-920,7
+912,7
@@
static int statsd_read (void) /* {{{ */
}
c_avl_iterator_destroy (iter);
}
c_avl_iterator_destroy (iter);
- for (i = 0; i < to_be_deleted_num; i++)
+ for (
size_t
i = 0; i < to_be_deleted_num; i++)
{
int status;
{
int status;