From: Florian Forster Date: Fri, 22 May 2015 08:25:35 +0000 (+0200) Subject: src/utils_format_json.[ch]: Export gauges with 15 decimal places of precision. X-Git-Tag: collectd-5.5.0~12^2~3 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=cdc0d1f300c1c6870a29a20a3245c746674f5159;p=collectd.git src/utils_format_json.[ch]: Export gauges with 15 decimal places of precision. Fixes: #1039 --- diff --git a/src/utils_format_json.c b/src/utils_format_json.c index 898b1725..48aa4fc6 100644 --- a/src/utils_format_json.c +++ b/src/utils_format_json.c @@ -108,7 +108,7 @@ static int values_to_json (char *buffer, size_t buffer_size, /* {{{ */ if (ds->ds[i].type == DS_TYPE_GAUGE) { if(isfinite (vl->values[i].gauge)) - BUFFER_ADD ("%g", vl->values[i].gauge); + BUFFER_ADD (JSON_GAUGE_FORMAT, vl->values[i].gauge); else BUFFER_ADD ("null"); } @@ -124,7 +124,7 @@ static int values_to_json (char *buffer, size_t buffer_size, /* {{{ */ } if(isfinite (rates[i])) - BUFFER_ADD ("%g", rates[i]); + BUFFER_ADD (JSON_GAUGE_FORMAT, rates[i]); else BUFFER_ADD ("null"); } diff --git a/src/utils_format_json.h b/src/utils_format_json.h index c902e272..f8f5a355 100644 --- a/src/utils_format_json.h +++ b/src/utils_format_json.h @@ -25,6 +25,10 @@ #include "collectd.h" #include "plugin.h" +#ifndef JSON_GAUGE_FORMAT +# define JSON_GAUGE_FORMAT "%.15g" +#endif + int format_json_initialize (char *buffer, size_t *ret_buffer_fill, size_t *ret_buffer_free); int format_json_value_list (char *buffer,