[rrd-developers] Discuss regarding Ticket 263

Jean-Edouard Babin radius at gmail.com
Mon May 24 19:19:02 CEST 2010


On Thu, May 20, 2010 at 9:46 AM, Alex van den Bogaerdt
<alex at vandenbogaerdt.nl> wrote:
>
>> Hello,
>>
>> Yesterday I opened a new ticked
>> http://oss.oetiker.ch/rrdtool-trac/ticket/263 because I got a wrong
>> output when printing time of an empty VDEF. (time is 1st Jan 1970)
>
> It seems to me your problem is different. It is the actual printing which
> should not happen or be altered, you would benefit more from a conditional
> (G)PRINT.

Yes, conditional (G)PRINT would be better, but rrdtool set a "false"
default time to the VDEF result anyway.

> VDEF itself is fine, your program flow tries to do something RRDtool
> currently is not able to.
>
>> I just find out why, in function vdef_calc of rrd_graph.c, cases
>> (VDEF_MAXIMUM, VDEF_AVERAGE, VDEF_FIRST, ...) set dst->vf.when to 0 if
>> value is unknow (which is my case).
>
> Using 0 was a design choice.
>
>> I would be happy to try to do a patch, but I would like to discuss how
>> to do it before doing something. (I don't want to do something that
>> will not be commited because it's not a proper solution)
>>
>> vdef struct is currently as follow:
>>
>> typedef struct vdef_t {
>>    enum vdef_op_en op;
>>    double    param;    /* parameter for function, if applicable */
>>    double    val;      /* resulting value */
>>    time_t    when;     /* timestamp, if applicable */
>> } vdef_t;
>>
>> My idea would be to add a new 'isnull' boolean variable to the struct,
>> so that in print_calc I could add some test on isnull be able to run
>> something else that strftime (let's say fct1()) when isnull is true.
>
> I don't think time 0 will ever be valid, so instead of adding something to
> this struct, why not simply if (vdef->when==0) printf("none"); else
> {...whatever is done now...}

Imagine someone doing statistic and importing data from 1970 to 2010,
with one value per month and the fewest one on 1st Jan 1970.
If he wants to print the first value and use a VDEF for that, he would
not get it's result even if in his case 0 is the correct value.
>From my point of view adding 'never' flag is better as it can't break something

> ? Instead of "none", it could be "-" repeated, so that if the user requests
> a certain field width it complies with that.

Yes, I could print many '-' for some %X like %d which is alway on 2 chars

> Or, given what I write in the first line of my response, have a test for 0
> and somehow be able to
>
> if time==0 GPRINT:... some comment
> else GPRINT:... the current parameters
>
> That last is more work but could also be used in more cases.
>
> Just my 2ct
>
> _______________________________________________
> rrd-developers mailing list
> rrd-developers at lists.oetiker.ch
> https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers
>



-- 
Jean-Edouard Babin



More information about the rrd-developers mailing list