X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrdcached.c;h=665e2c87abedb4f1797d6efaa4fa8a2ba24b0259;hb=2e4ad4405df783aff6b4599c75f564e4a9bf4a19;hp=4efb1f0cdc0b480bca0ce33ff641711fdb807081;hpb=5ff74d56067ac64db801df5184eb8b97f4b2b645;p=collectd.git diff --git a/src/rrdcached.c b/src/rrdcached.c index 4efb1f0c..665e2c87 100644 --- a/src/rrdcached.c +++ b/src/rrdcached.c @@ -26,9 +26,9 @@ #include "collectd.h" -#include "common.h" #include "plugin.h" -#include "utils_rrdcreate.h" +#include "utils/common/common.h" +#include "utils/rrdcreate/rrdcreate.h" #undef HAVE_CONFIG_H #include @@ -37,29 +37,25 @@ /* * Private variables */ -static char *datadir = NULL; -static char *daemon_address = NULL; -static _Bool config_create_files = 1; -static _Bool config_collect_stats = 1; -static rrdcreate_config_t rrdcreate_config = { - /* stepsize = */ 0, - /* heartbeat = */ 0, - /* rrarows = */ 1200, - /* xff = */ 0.1, - - /* timespans = */ NULL, - /* timespans_num = */ 0, - - /* consolidation_functions = */ NULL, - /* consolidation_functions_num = */ 0, - - /* async = */ 0}; +static char *datadir; +static char *daemon_address; +static bool config_create_files = true; +static bool config_collect_stats = true; +static rrdcreate_config_t rrdcreate_config = {.stepsize = 0, + .heartbeat = 0, + .rrarows = 1200, + .xff = 0.1, + .timespans = NULL, + .timespans_num = 0, + .consolidation_functions = NULL, + .consolidation_functions_num = 0, + .async = 0}; /* * Prototypes. */ static int rc_write(const data_set_t *ds, const value_list_t *vl, - user_data_t __attribute__((unused)) * user_data); + __attribute__((unused)) user_data_t *ud); static int rc_flush(__attribute__((unused)) cdtime_t timeout, const char *identifier, __attribute__((unused)) user_data_t *ud); @@ -75,7 +71,7 @@ static int value_list_to_string(char *buffer, int buffer_len, memset(buffer, '\0', buffer_len); t = CDTIME_T_TO_TIME_T(vl->time); - status = ssnprintf(buffer, buffer_len, "%lu", (unsigned long)t); + status = snprintf(buffer, buffer_len, "%lu", (unsigned long)t); if ((status < 1) || (status >= buffer_len)) return -1; offset = status; @@ -88,17 +84,17 @@ static int value_list_to_string(char *buffer, int buffer_len, return -1; if (ds->ds[i].type == DS_TYPE_COUNTER) { - status = ssnprintf(buffer + offset, buffer_len - offset, ":%llu", - vl->values[i].counter); + status = snprintf(buffer + offset, buffer_len - offset, ":%" PRIu64, + (uint64_t)vl->values[i].counter); } else if (ds->ds[i].type == DS_TYPE_GAUGE) { - status = ssnprintf(buffer + offset, buffer_len - offset, ":%f", - vl->values[i].gauge); + status = snprintf(buffer + offset, buffer_len - offset, ":%f", + vl->values[i].gauge); } else if (ds->ds[i].type == DS_TYPE_DERIVE) { - status = ssnprintf(buffer + offset, buffer_len - offset, ":%" PRIi64, - vl->values[i].derive); + status = snprintf(buffer + offset, buffer_len - offset, ":%" PRIi64, + vl->values[i].derive); } else /* if (ds->ds[i].type == DS_TYPE_ABSOLUTE) */ { - status = ssnprintf(buffer + offset, buffer_len - offset, ":%" PRIu64, - vl->values[i].absolute); + status = snprintf(buffer + offset, buffer_len - offset, ":%" PRIu64, + vl->values[i].absolute); } if ((status < 1) || (status >= (buffer_len - offset))) @@ -284,7 +280,7 @@ static int try_reconnect(void) { static int rc_read(void) { int status; rrdc_stats_t *head; - _Bool retried = 0; + bool retried = false; value_list_t vl = VALUE_LIST_INIT; vl.values = &(value_t){.gauge = NAN}; @@ -320,7 +316,7 @@ static int rc_read(void) { break; if (!retried) { - retried = 1; + retried = true; if (try_reconnect() == 0) continue; /* else: report the error and fail */ @@ -392,7 +388,7 @@ static int rc_write(const data_set_t *ds, const value_list_t *vl, char values[512]; char *values_array[2]; int status; - _Bool retried = 0; + bool retried = false; if (daemon_address == NULL) { ERROR("rrdcached plugin: daemon_address == NULL."); @@ -424,9 +420,7 @@ static int rc_write(const data_set_t *ds, const value_list_t *vl, status = stat(filename, &statbuf); if (status != 0) { if (errno != ENOENT) { - char errbuf[1024]; - ERROR("rrdcached plugin: stat (%s) failed: %s", filename, - sstrerror(errno, errbuf, sizeof(errbuf))); + ERROR("rrdcached plugin: stat (%s) failed: %s", filename, STRERRNO); return -1; } @@ -457,7 +451,7 @@ static int rc_write(const data_set_t *ds, const value_list_t *vl, break; if (!retried) { - retried = 1; + retried = true; if (try_reconnect() == 0) continue; /* else: report the error and fail */ @@ -476,15 +470,15 @@ static int rc_flush(__attribute__((unused)) cdtime_t timeout, /* {{{ */ __attribute__((unused)) user_data_t *ud) { char filename[PATH_MAX + 1]; int status; - _Bool retried = 0; + bool retried = false; if (identifier == NULL) return EINVAL; if (datadir != NULL) - ssnprintf(filename, sizeof(filename), "%s/%s.rrd", datadir, identifier); + snprintf(filename, sizeof(filename), "%s/%s.rrd", datadir, identifier); else - ssnprintf(filename, sizeof(filename), "%s.rrd", identifier); + snprintf(filename, sizeof(filename), "%s.rrd", identifier); rrd_clear_error(); status = rrdc_connect(daemon_address); @@ -504,7 +498,7 @@ static int rc_flush(__attribute__((unused)) cdtime_t timeout, /* {{{ */ break; if (!retried) { - retried = 1; + retried = true; if (try_reconnect() == 0) continue; /* else: report the error and fail */