[rrd-developers] Re: Implementing TOTAL
Mark Mills
mark at xodiax.com
Thu Jul 26 21:57:31 MEST 2001
> -----Original Message-----
> From: Alex van den Bogaerdt [mailto:alex at slot.hollandcasino.nl]
> Subject: Re: [rrd-developers] Re: Implementing TOTAL
> > > 1) average(all rates)*timespan(graph)
> > > 2) sum(for each defined interval:(rate*stepsize))
> > > The difference would be the unknown intervals. In the first case
> > > unknown intervals are assumed to be at the average rate, in the
> > > second case unknown intervals are assumed to be zero.
> >
> > Do both? TOTALSUM, TOTALAVG are really ugly suggestions for
> names. =)
>
> They're not clear to me and this is within context :)
Ouch. I did say they were ugly names. ;) In any case, TOTAL
should be "TOTAL" and leave unknown treated as zero. If you
want to make up data it isn't a TOTAL but an adjusted total
and your next problem will be what KIND of adjustments to
make. Some people might want an interpreted adjustment rather
than presuming a raw average for the unknowns.
If nothing else, maybe TOTAL and ADJUSTED would do?
Would thse work for TOTAL and ADJUSTED? (No dev box yet *sniff*)
case VDEF_TOTAL: {
double sum=DNAN;
for (step=0;step<steps;step++) {
if (finite(data[step*src->ds_cnt]) &&
!isnan(data[step*src->ds_cnt]))
sum += data[step*src->ds_cnt];
}
if (!isnan(sum)) {
dst->vf.val = sum*src->step;
dst->vf.when = 0; /* no time component */
} else {
dst->vf.val = DNAN;
dst->vf.when = 0;
}
}
break;
case VDEF_ADJUSTED: {
int cnt=0;
double sum=0.0;
for (step=0;step<steps;step++) {
if (finite(data[step*src->ds_cnt]) &&
!isnan(data[step*src->ds_cnt])) {
sum += data[step*src->ds_cnt];
cnt ++;
}
}
if (cnt) {
dst->vf.val = sum/cnt*steps*src->step;
dst->vf.when = 0; /* no time component */
} else {
dst->vf.val = DNAN;
dst->vf.when = 0;
}
}
break;
Hey, since I'm cut-n-pasting your code around, why does AVERAGE
have step++ in it twice??? I took it outta mine because it looked
like a holdover from the while(){} loop style you had in much of
the other VDEF_ cases.
case VDEF_AVERAGE: {
int cnt=0;
double sum=0.0;
for (step=0;step<steps;step++) { /* ++ here ? */
if (finite(data[step*src->ds_cnt])) {
sum += data[step*src->ds_cnt];
cnt ++;
}
step++; /* and ++ here too? */
}
if (cnt) {
dst->vf.val = sum/cnt;
dst->vf.when = 0; /* no time component */
} else {
dst->vf.val = DNAN;
dst->vf.when = 0;
}
}
break;
> > Or alternately make TOTAL a raw sum and supply a COUNT and
> STEPS so we
> > can calculate it manually?
>
> We could have "preset" VDEFs such as timespan (number of
> seconds graphed).
> This could then be multiplied by the calculated average and
> thus provide
> the total as calculated using option 1 above.
> VDEF:total=ds,AVERAGE,timespan,*
> This requires being able to use real RPN in VDEF commands, something
> that needs to be done anyway but it is currently not implemented.
>
> Option 2 could be implemented by doing
> VDEF:total=ds,TOTAL
>
> Apart from calculating the total, is there any other need to know how
> many intervals were unknown or not?
>
> Thanks for the input, I really appreciate it.
> --
> __________________________________________________________________
> / alex at slot.hollandcasino.nl
> alex at ergens.op.het.net \
> | work
> private |
> | My employer is capable of speaking therefore I speak only
> for myself |
> +-------------------------------------------------------------
> ---------+
> | Technical questions sent directly to me will be nuked. Use
> the list. |
> +-------------------------------------------------------------
> ---------+
> | http://faq.mrtg.org/
> |
> | http://rrdtool.eu.org --> tutorial
> |
> +-------------------------------------------------------------
> ---------+
>
--
Unsubscribe mailto:rrd-developers-request at list.ee.ethz.ch?subject=unsubscribe
Help mailto:rrd-developers-request at list.ee.ethz.ch?subject=help
Archive http://www.ee.ethz.ch/~slist/rrd-developers
WebAdmin http://www.ee.ethz.ch/~slist/lsg2.cgi
More information about the rrd-developers
mailing list