X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Frrdcached.c;h=6d45ac9fdf5287644edae598a4f2912a03686439;hp=0b9040536ecc165f0b9a85ea7bacd1d5866358d6;hb=8c5927c52f4eefebaad3a6ecadc253ee9007ebb5;hpb=9c962b99a3acd77f1d6e2499052b47356819511a diff --git a/src/rrdcached.c b/src/rrdcached.c index 0b904053..6d45ac9f 100644 --- a/src/rrdcached.c +++ b/src/rrdcached.c @@ -313,8 +313,9 @@ static int rc_read (void) rrdc_stats_t *head; _Bool retried = 0; - value_t values[1]; value_list_t vl = VALUE_LIST_INIT; + vl.values = &(value_t) { .gauge = NAN }; + vl.values_len = 1; if (daemon_address == NULL) return (-1); @@ -322,13 +323,8 @@ static int rc_read (void) if (!config_collect_stats) return (-1); - vl.values = values; - vl.values_len = 1; - - if ((strncmp ("unix:", daemon_address, strlen ("unix:")) == 0) - || (daemon_address[0] == '/')) - sstrncpy (vl.host, hostname_g, sizeof (vl.host)); - else + if ((strncmp ("unix:", daemon_address, strlen ("unix:")) != 0) + && (daemon_address[0] != '/')) sstrncpy (vl.host, daemon_address, sizeof (vl.host)); sstrncpy (vl.plugin, "rrdcached", sizeof (vl.plugin)); @@ -367,9 +363,9 @@ static int rc_read (void) for (rrdc_stats_t *ptr = head; ptr != NULL; ptr = ptr->next) { if (ptr->type == RRDC_STATS_TYPE_GAUGE) - values[0].gauge = (gauge_t) ptr->value.gauge; + vl.values[0].gauge = (gauge_t) ptr->value.gauge; else if (ptr->type == RRDC_STATS_TYPE_COUNTER) - values[0].counter = (counter_t) ptr->value.counter; + vl.values[0].counter = (counter_t) ptr->value.counter; else continue;