summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cdc0d1f)
raw | patch | inline | side by side (parent: cdc0d1f)
author | Florian Forster <octo@collectd.org> | |
Fri, 22 May 2015 09:11:27 +0000 (11:11 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Fri, 22 May 2015 09:11:34 +0000 (11:11 +0200) |
This format is also used in format_values(), so exported gauges follow a common
format.
See also issue #1039
format.
See also issue #1039
src/collectd.h | patch | blob | history | |
src/common.c | patch | blob | history | |
src/utils_format_json.h | patch | blob | history |
diff --git a/src/collectd.h b/src/collectd.h
index 7cb405c04bd43d25ec6b807f730419cbf39a93bb..1b1bc49e1bfefaef7fe706d58fc96c0fe0f0788e 100644 (file)
--- a/src/collectd.h
+++ b/src/collectd.h
# endif
#endif
+#ifndef GAUGE_FORMAT
+# define GAUGE_FORMAT "%.15g"
+#endif
+
/* Type for time as used by "utils_time.h" */
typedef uint64_t cdtime_t;
diff --git a/src/common.c b/src/common.c
index 8a40792ad0c35f15d2e39d499a9aa0d0d1ffa57a..efd63c085452f7ba238247e1caade93d4bb35ac0 100644 (file)
--- a/src/common.c
+++ b/src/common.c
for (i = 0; i < ds->ds_num; i++)
{
if (ds->ds[i].type == DS_TYPE_GAUGE)
- BUFFER_ADD (":%f", vl->values[i].gauge);
+ BUFFER_ADD (":"GAUGE_FORMAT, vl->values[i].gauge);
else if (store_rates)
{
if (rates == NULL)
rates = uc_get_rate (ds, vl);
if (rates == NULL)
{
- WARNING ("format_values: "
- "uc_get_rate failed.");
+ WARNING ("format_values: uc_get_rate failed.");
return (-1);
}
- BUFFER_ADD (":%g", rates[i]);
+ BUFFER_ADD (":"GAUGE_FORMAT, rates[i]);
}
else if (ds->ds[i].type == DS_TYPE_COUNTER)
BUFFER_ADD (":%llu", vl->values[i].counter);
BUFFER_ADD (":%"PRIu64, vl->values[i].absolute);
else
{
- ERROR ("format_values plugin: Unknown data source type: %i",
+ ERROR ("format_values: Unknown data source type: %i",
ds->ds[i].type);
sfree (rates);
return (-1);
index f8f5a355791d437e31e72f83ab1d4fca2d2695b5..7a4aa542e9b5e077ae91a8ae9b9de91881d61328 100644 (file)
--- a/src/utils_format_json.h
+++ b/src/utils_format_json.h
#include "plugin.h"
#ifndef JSON_GAUGE_FORMAT
-# define JSON_GAUGE_FORMAT "%.15g"
+# define JSON_GAUGE_FORMAT GAUGE_FORMAT
#endif
int format_json_initialize (char *buffer,