Various plugins: Use the global GAUGE_FORMAT.
authorFlorian Forster <octo@collectd.org>
Fri, 22 May 2015 09:25:01 +0000 (11:25 +0200)
committerFlorian Forster <octo@collectd.org>
Fri, 22 May 2015 09:25:01 +0000 (11:25 +0200)
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
src/rrdtool.c
src/target_notification.c
src/utils_format_graphite.c
src/write_redis.c

index 1eaf6bd..c240e54 100644 (file)
@@ -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);
index c795e26..bebf468 100644 (file)
@@ -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:
index cb68048..b465438 100644 (file)
@@ -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));
index b7d4494..e23d5d9 100644 (file)
@@ -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)
index 1d9ec27..09aae70 100644 (file)
@@ -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)