[collectd] Double output in plugin-cvs

Florian Forster octo at verplant.org
Mon Sep 14 17:19:25 CEST 2009


Hi Bill,

On Mon, Sep 14, 2009 at 09:30:13AM -0500, Bill Harris wrote:
> However, cvs, is only outputting the following for vber
> 1252938080,0.000000
> 1252938090,0.000000
> 1252938100,0.000001
> 
> 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
"%10le".

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
  #ifndef CSV_DOUBLE_FORMAT
  #  define CSV_DOUBLE_FORMAT "%10g"
  #endif
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
 DoubleWidth 10
-- >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 --

Regards,
—octo
-- 
Florian octo Forster
Hacker in training
GnuPG: 0x91523C3D
http://verplant.org/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20090914/79e73d5c/attachment.pgp 


More information about the collectd mailing list