[collectd] Double output in plugin-cvs

Bill Harris savoy9020 at texoma.net
Mon Sep 14 18:14:34 CEST 2009


Florian,

Thanks, now I have it working with choices...

The first is with %le, then I tried it with %g

1252942347,1.000000e-10
1252942357,3.000000e-07
1252942367,8.000000e-07
1252942377,3.000000e-07
1252942387,1.000000e-10
1252942938,1e-10
1252942948,2.1e-06
1252942958,9e-07
1252942968,3e-07
1252942978,8e-07

I guess the question is which is more palatable for other programs
like gnuplot, or other charting programs to plot?  Or does it matter?

Bill




On 9/14/09 10:19 AM, "Florian Forster" <octo at verplant.org> wrote:

> 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





More information about the collectd mailing list