From d3db12b73a1c3c17a2dfc0ba96ec99490088c957 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Fri, 22 May 2015 11:25:01 +0200 Subject: [PATCH] Various plugins: Use the global GAUGE_FORMAT. This fixes the postgresql, rrdtool, target_notification, write_graphite and write_redis plugins to use the globally defined format for gauges. Issue #1039 --- src/postgresql.c | 2 +- src/rrdtool.c | 4 ++-- src/target_notification.c | 4 ++-- src/utils_format_graphite.c | 2 +- src/write_redis.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/postgresql.c b/src/postgresql.c index 1eaf6bd3..c240e543 100644 --- a/src/postgresql.c +++ b/src/postgresql.c @@ -775,7 +775,7 @@ static char *values_to_sqlarray (const data_set_t *ds, const value_list_t *vl, if (ds->ds[i].type == DS_TYPE_GAUGE) status = ssnprintf (str_ptr, str_len, - ",%f", vl->values[i].gauge); + ","GAUGE_FORMAT, vl->values[i].gauge); else if (store_rates) { if (rates == NULL) rates = uc_get_rate (ds, vl); diff --git a/src/rrdtool.c b/src/rrdtool.c index c795e265..bebf468c 100644 --- a/src/rrdtool.c +++ b/src/rrdtool.c @@ -227,7 +227,7 @@ static int value_list_to_string_multiple (char *buffer, int buffer_len, ":%llu", vl->values[i].counter); else if (ds->ds[i].type == DS_TYPE_GAUGE) status = ssnprintf (buffer + offset, buffer_len - offset, - ":%lf", vl->values[i].gauge); + ":"GAUGE_FORMAT, 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); @@ -262,7 +262,7 @@ static int value_list_to_string (char *buffer, int buffer_len, (unsigned) tt, vl->values[0].derive); break; case DS_TYPE_GAUGE: - status = ssnprintf (buffer, buffer_len, "%u:%lf", + status = ssnprintf (buffer, buffer_len, "%u:"GAUGE_FORMAT, (unsigned) tt, vl->values[0].gauge); break; case DS_TYPE_COUNTER: diff --git a/src/target_notification.c b/src/target_notification.c index cb68048b..b4654387 100644 --- a/src/target_notification.c +++ b/src/target_notification.c @@ -251,12 +251,12 @@ static int tn_invoke (const data_set_t *ds, value_list_t *vl, /* {{{ */ /* If this is a gauge value, use the current value. */ if (ds->ds[i].type == DS_TYPE_GAUGE) ssnprintf (value_str, sizeof (value_str), - "%g", (double) vl->values[i].gauge); + GAUGE_FORMAT, (double) vl->values[i].gauge); /* If it's a counter, try to use the current rate. This may fail, if the * value has been renamed. */ else if (rates != NULL) ssnprintf (value_str, sizeof (value_str), - "%g", (double) rates[i]); + GAUGE_FORMAT, (double) rates[i]); /* Since we don't know any better, use the string `unknown'. */ else sstrncpy (value_str, "unknown", sizeof (value_str)); diff --git a/src/utils_format_graphite.c b/src/utils_format_graphite.c index b7d4494d..e23d5d92 100644 --- a/src/utils_format_graphite.c +++ b/src/utils_format_graphite.c @@ -61,7 +61,7 @@ static int gr_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 (rates != NULL) BUFFER_ADD ("%f", rates[ds_num]); else if (ds->ds[ds_num].type == DS_TYPE_COUNTER) diff --git a/src/write_redis.c b/src/write_redis.c index 1d9ec27c..09aae702 100644 --- a/src/write_redis.c +++ b/src/write_redis.c @@ -90,7 +90,7 @@ static int wr_write (const data_set_t *ds, /* {{{ */ if (ds->ds[i].type == DS_TYPE_COUNTER) APPEND ("%llu", vl->values[i].counter); else if (ds->ds[i].type == DS_TYPE_GAUGE) - APPEND ("%g", vl->values[i].gauge); + APPEND (GAUGE_FORMAT, vl->values[i].gauge); else if (ds->ds[i].type == DS_TYPE_DERIVE) APPEND ("%"PRIi64, vl->values[i].derive); else if (ds->ds[i].type == DS_TYPE_ABSOLUTE) -- 2.30.2