Code

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 1eaf6bd3877570a56c0e50c045b7e90cc888cda2..c240e5438297b28e29e7b04d7f1180dd102a979b 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 c795e2656502685ca353937ddda2b9defcd3a518..bebf468c3c83ce8158a082207c7c950382bf0352 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 cb68048b6a8f7c042cdd37bbf7dc3c77a24bd754..b465438705709df64c02aca9241dcc5a5f95ab9e 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 b7d4494d3ed0fda8d6ad9a17cca5193ffdae911b..e23d5d92c65599fecc29ac575ca48c68af2b3369 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 1d9ec27c0b60bf43900e9504e4271ce12a623a70..09aae7028d24505a6f3cb372860b8eafb8d20a1e 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)