From 599e3edb4905c6be61c0fc66a62be1d69a4833b3 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Fri, 22 May 2015 11:48:17 +0200 Subject: [PATCH] write_sensu, write_tsdb plugins: Use GAUGE_FORMAT. Issue #1039 --- src/write_sensu.c | 6 ++---- src/write_tsdb.c | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/write_sensu.c b/src/write_sensu.c index cb0c2fe2..7a3e4f40 100644 --- a/src/write_sensu.c +++ b/src/write_sensu.c @@ -468,16 +468,14 @@ static char *sensu_value_to_json(struct sensu_host const *host, /* {{{ */ // calculate the value and set to a string if (ds->ds[index].type == DS_TYPE_GAUGE) { - double tmp_v = (double) vl->values[index].gauge; - res = asprintf(&value_str, "%.8f", tmp_v); + res = asprintf(&value_str, GAUGE_FORMAT, vl->values[index].gauge); if (res == -1) { free(ret_str); ERROR("write_sensu plugin: Unable to alloc memory"); return NULL; } } else if (rates != NULL) { - double tmp_v = (double) rates[index]; - res = asprintf(&value_str, "%.8f", tmp_v); + res = asprintf(&value_str, GAUGE_FORMAT, rates[index]); if (res == -1) { free(ret_str); ERROR("write_sensu plugin: Unable to alloc memory"); diff --git a/src/write_tsdb.c b/src/write_tsdb.c index 9008a67b..27ea4738 100644 --- a/src/write_tsdb.c +++ b/src/write_tsdb.c @@ -308,7 +308,7 @@ static int wt_format_values(char *ret, size_t ret_len, } while (0) if (ds->ds[ds_num].type == DS_TYPE_GAUGE) - BUFFER_ADD("%f", vl->values[ds_num].gauge); + BUFFER_ADD(GAUGE_FORMAT, vl->values[ds_num].gauge); else if (store_rates) { if (rates == NULL) @@ -319,7 +319,7 @@ static int wt_format_values(char *ret, size_t ret_len, "uc_get_rate failed."); return -1; } - BUFFER_ADD("%f", rates[ds_num]); + BUFFER_ADD(GAUGE_FORMAT, rates[ds_num]); } else if (ds->ds[ds_num].type == DS_TYPE_COUNTER) BUFFER_ADD("%llu", vl->values[ds_num].counter); -- 2.11.0