[rrd-users] CDEF / VDEF / PRINT / GRPRINT limitations & workarounds

Karl Fischer rrd-users at ficos.de
Sun Jul 6 12:08:03 CEST 2008


Hi all (perhaps more for the developers),

over the last couple of days I kept constantly fooling myself with
the current limitations of CDEF / VDEF / PRINT / GRPRINT ...

* CDEF needs at least one vname from DEF or CDEF (not VDEF)
* VDEF can't do rpn calculations
* PRINT / GRPINT / HRULE only accept vnames from VDEF, not CDEF

I always had to find some crazy workarounds, for example:

Monitoring disk space over time. With GPRINT I'd like to display
the FIRST and LAST value of the range and the delta:
(eg. over the past time period the disk usage has increased by xx GB)

DEF:dfUsed=some.rrd:used:LAST
VDEF:dfFirst=dfUsed,FIRST
VDEF:dfLast=dfUsed,LAST
CDEF:dfDelta=dfLast,dfFirst,-    # doesn't work
GRPINT:dfFirst:%8.3lf %sB
GRPINT:dfLast:%8.3lf %sB
GRPINT:dfD:%+9.3lf %sB

The above CDEF doesn't work, because it needs at least one vname
from DEF or CDEF, but both are from VDEF ...

A VDEF:dfDelta=dfLast,dfFirst,- doesn't work because VDEF doesn't
support rpn calculations (yet)

My kinda upgly workaround looks like this:

CDEF:zero=dfUsed,UN,0,0,IF     # always zero - equals to CDEF=0
CDEF:dfDelta=zero,dfLast,+,dfFirst,-    # this does work

or - a bit shortened - in one line:
CDEF:dfDelta=dfUsed,UN,dfLast,dfLast,IF,dfFirst,-

Now I have created a solution that has to calculate dfDelta for each
of the datapoints rather than once at the end - this is not what I
would call effictient, and still, now that the calculation is done,
the dfDelta still cannot be (G)PRINTed since it is a CDEF value :-(
So I need to have another workaround like this:

VDEF:dfD=dfDelta,LAST
GRPINT:dfD:%+9.3lf %sB


So the general question(s) is/are:

Why these limitations?
Are there better ways (than mine above) to do this?

Since CDEF *can* work with vnames from VDEF, why does it want to
have at least one (C)DEF vname? Could this be changed easily?
Why doesn't CDEF accept rpns without a (C)DEF vname?

Where does the limitation of not beeing able to do rpn calculations
with VDEF come from?

And last: if these workarounds are the only way to achieve this,
wouldn't they be worth a few lines in the documentation/examples?


Many thanks for clarification

- Karl



More information about the rrd-users mailing list