From: Florian Forster Date: Fri, 22 May 2015 09:11:27 +0000 (+0200) Subject: src/collectd.h: Define GAUGE_FORMAT. X-Git-Tag: collectd-5.5.0~12^2~2 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=b6fbfb1b864be53e71d755fba59d633f5c30da7e;p=collectd.git src/collectd.h: Define GAUGE_FORMAT. This format is also used in format_values(), so exported gauges follow a common format. See also issue #1039 --- diff --git a/src/collectd.h b/src/collectd.h index 7cb405c0..1b1bc49e 100644 --- a/src/collectd.h +++ b/src/collectd.h @@ -287,6 +287,10 @@ typedef int _Bool; # endif #endif +#ifndef GAUGE_FORMAT +# define GAUGE_FORMAT "%.15g" +#endif + /* Type for time as used by "utils_time.h" */ typedef uint64_t cdtime_t; diff --git a/src/common.c b/src/common.c index 8a40792a..efd63c08 100644 --- a/src/common.c +++ b/src/common.c @@ -902,18 +902,17 @@ int format_values (char *ret, size_t ret_len, /* {{{ */ for (i = 0; i < ds->ds_num; i++) { if (ds->ds[i].type == DS_TYPE_GAUGE) - BUFFER_ADD (":%f", vl->values[i].gauge); + BUFFER_ADD (":"GAUGE_FORMAT, vl->values[i].gauge); else if (store_rates) { if (rates == NULL) rates = uc_get_rate (ds, vl); if (rates == NULL) { - WARNING ("format_values: " - "uc_get_rate failed."); + WARNING ("format_values: uc_get_rate failed."); return (-1); } - BUFFER_ADD (":%g", rates[i]); + BUFFER_ADD (":"GAUGE_FORMAT, rates[i]); } else if (ds->ds[i].type == DS_TYPE_COUNTER) BUFFER_ADD (":%llu", vl->values[i].counter); @@ -923,7 +922,7 @@ int format_values (char *ret, size_t ret_len, /* {{{ */ BUFFER_ADD (":%"PRIu64, vl->values[i].absolute); else { - ERROR ("format_values plugin: Unknown data source type: %i", + ERROR ("format_values: Unknown data source type: %i", ds->ds[i].type); sfree (rates); return (-1); diff --git a/src/utils_format_json.h b/src/utils_format_json.h index f8f5a355..7a4aa542 100644 --- a/src/utils_format_json.h +++ b/src/utils_format_json.h @@ -26,7 +26,7 @@ #include "plugin.h" #ifndef JSON_GAUGE_FORMAT -# define JSON_GAUGE_FORMAT "%.15g" +# define JSON_GAUGE_FORMAT GAUGE_FORMAT #endif int format_json_initialize (char *buffer,