[collectd] Double output in plugin-cvs
octo at verplant.org
Mon Sep 14 17:19:25 CEST 2009
On Mon, Sep 14, 2009 at 09:30:13AM -0500, Bill Harris wrote:
> However, cvs, is only outputting the following for vber
> I¹m sure it¹s a printf precision, I need to increase, but I need a
> suggestion where to look?
the precision is hard-coded in „src/csv.c”, around line 72. It's
currently simply "%lf".
I think using the “scientific” notation there would improve the
precision a lot with minimal effort. Simply use "%le" or something like
A possible alternative would be to use the "%g" conversion: It uses the
scientific notation for very big and very small numbers and the easier
to read “normal” notation for reasonably small numbers. A problem I
could picture here is that the precision may depend even more on the
size of the numbers than it does already.
I'd like to avoid a config option that lets the user set this format
string in the config file. We could use something like
# define CSV_DOUBLE_FORMAT "%10g"
which would allow users that care about this feature to configure this
as compile time. If runtime configuration is preferred, I'd rather go
with something like:
-- 8< --
DoubleFormat Decimal|Scientific|Auto # corresponds to %f, %e, and %g
-- >8 --
This would then look in code somewhat like this:
-- 8< --
dbl_format = "%*g";
if conf_dbl_format = "decimal"
dbl_format = "%*f";
else if conf_dbl_format = "scientific"
dbl_format = "%*e";
fprintf (fh, dbl_format, conf_dbl_width, value);
-- >8 --
Florian octo Forster
Hacker in training
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20090914/79e73d5c/attachment.pgp
More information about the collectd