**/
#include "collectd.h"
+
#include "plugin.h"
#include "common.h"
#include "utils_rrdcreate.h"
{
int offset;
int status;
- int i;
time_t t;
assert (0 == strcmp (ds->type, vl->type));
return (-1);
offset = status;
- for (i = 0; i < ds->ds_num; i++)
+ for (size_t i = 0; i < ds->ds_num; i++)
{
if ((ds->ds[i].type != DS_TYPE_COUNTER)
&& (ds->ds[i].type != DS_TYPE_GAUGE)
status = ssnprintf (buffer + offset, buffer_len - offset,
":%llu", vl->values[i].counter);
}
- else if (ds->ds[i].type == DS_TYPE_GAUGE)
+ else if (ds->ds[i].type == DS_TYPE_GAUGE)
{
status = ssnprintf (buffer + offset, buffer_len - offset,
":%f", vl->values[i].gauge);
else /* if (ds->ds[i].type == DS_TYPE_ABSOLUTE) */ {
status = ssnprintf (buffer + offset, buffer_len - offset,
":%"PRIu64, vl->values[i].absolute);
-
+
}
if ((status < 1) || (status >= (buffer_len - offset)))
static int rc_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 const *child = ci->children + i;
const char *key = child->key;
{
int status;
rrdc_stats_t *head;
- rrdc_stats_t *ptr;
- 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);
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));
return (-1);
}
- for (ptr = head; ptr != NULL; ptr = ptr->next)
+ 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;