PREV Function CDEF not working...

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
brucepac
Posts: 17
Joined: Tue Mar 10, 2015 4:49 pm

PREV Function CDEF not working...

Post by brucepac »

Guys, i am trying to get the value of the previous data read with a "PREV" CDEF function, but it is not working. Is it a known bug? Any suggestion? I cannot get any graphic with this function.


RRDTool Command:
/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title='Flexi NG - PDP Stats - apn Internet2' \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit='0' \
--vertical-label='PDP Contexts2' \
--slope-mode \
--font TITLE:10: \
--font AXIS:7: \
--font LEGEND:8: \
--font UNIT:7: \
DEF:a='/var/www/html/cacti/rra/flexi_ng_pdpfailinter2_2867.rrd':'pdpfailInter2':AVERAGE \
CDEF:cdefa='PREV,a' \
LINE1:cdefa#FF5576FF:'PDP' \
GPRINT:a:LAST:'Current\:%8.0lf' \
GPRINT:a:AVERAGE:'Average\:%8.0lf' \
GPRINT:a:MAX:'Max\:%8.0lf'
RRDTool Says:
ERROR: RPN final stack size != 1
brucepac
Posts: 17
Joined: Tue Mar 10, 2015 4:49 pm

Re: PREV Function CDEF not working...

Post by brucepac »

I also used a different structure for the PREV function, but still not working:

RRDTool Command:
/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title='Flexi NG - PDP Stats - apn Internet2' \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit='0' \
--vertical-label='PDP Contexts2' \
--slope-mode \
--font TITLE:10: \
--font AXIS:7: \
--font LEGEND:8: \
--font UNIT:7: \
DEF:a='/var/www/html/cacti/rra/flexi_ng_pdpfailinter2_2867.rrd':'pdpfailInter2':AVERAGE \
CDEF:cdefa='a,PREV' \
LINE1:cdefa#FF5576FF:'PDP' \
GPRINT:a:LAST:'Current\:%8.0lf' \
GPRINT:a:AVERAGE:'Average\:%8.0lf' \
GPRINT:a:MAX:'Max\:%8.0lf'
RRDTool Says:
ERROR: RPN final stack size != 1
brucepac
Posts: 17
Joined: Tue Mar 10, 2015 4:49 pm

Re: PREV Function CDEF not working...

Post by brucepac »

does anybody else have this issue? somebody solved it? Thanks in advance for your help...
cigamit
Developer
Posts: 3367
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Re: PREV Function CDEF not working...

Post by cigamit »

The error itself is telling you that your CDEF is formatted wrong. You basically have 2 parameters in it, but no operator.
brucepac
Posts: 17
Joined: Tue Mar 10, 2015 4:49 pm

Re: PREV Function CDEF not working...

Post by brucepac »

Well, i also added operators (-), specifically I created this formula: "(Current Data) - PREV(Current Data)"

and still the same problem. Any example or suggestions?

I just need to get the delta (difference) between the actual data value and previous data value.

Thanks in advance
porzech
Posts: 23
Joined: Sat Apr 14, 2012 5:02 am

Re: PREV Function CDEF not working...

Post by porzech »

well not sure if this will be of any help to You

here is an example from rrdtool page

MEDIAN FILTER: filters shot noise

Code: Select all

    DEF:var=database.rrd:traffic:AVERAGE
    CDEF:prev1=PREV(var)
    CDEF:prev2=PREV(prev1)
    CDEF:prev3=PREV(prev2)
    CDEF:median=prev1,prev2,prev3,+,+,3,/
    LINE3:median#000077:filtered
    LINE1:prev2#007700:'raw data'
And here some snippets from old thread in rrdtoll discussion group

You always need some "if (unknown) then this else that" logic in your
CDEFs when using prev or prev().

(n.b. the following examples will probably not work because they
don't use another CDEF or a DEF)

"CDEF:x=PREV,UN,0,PREV,1,+,IF" would look at the previous value. If this
is unknown, result is 0, else result is one more than the previous value.
Result for n intervals: 0,1,2,3,4,5,6,7,8,9,....,n-1

"CDEF:x=PREV,UN,0,UNKN,IF" would alternate between zero and unknown.
--edit--
I also found this bug report regarding prev in cacti 0.8.6f (its fixed) but it contais some usage examples
http://bugs.cacti.net/view.php?id=612
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests