X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrdcached.c;h=5cf17c1efa6281e94df9c7afbbf2acc9f56fbd76;hb=fb0cc621d4357bbe4a9dc36c7f055f46257ce57c;hp=f78f4da2964bf85d8aa5e622cbd93ac1ed2124a9;hpb=79963d13c1884d1d92667cc502ad20758b084a12;p=collectd.git diff --git a/src/rrdcached.c b/src/rrdcached.c index f78f4da2..5cf17c1e 100644 --- a/src/rrdcached.c +++ b/src/rrdcached.c @@ -286,8 +286,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); @@ -295,13 +296,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)); @@ -337,9 +333,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; @@ -533,7 +529,3 @@ void module_register(void) { plugin_register_init("rrdcached", rc_init); plugin_register_shutdown("rrdcached", rc_shutdown); } /* void module_register */ - -/* - * vim: set sw=2 sts=2 et : - */