1

I have 3 rrd file (File1.rrd, File2.rdd and File3.rrd). I am getting MAX, MIN and LAST values from three files. To illustrate more on this, File1.rrd have 3 output (max, min & current) similarly File2.rrd and File3.rrd will have 3 each total (9) variable as output. I am trying to sum all three min, max, and current values and store it into three separate variables but it's generating error every time. An error like, "invalid rpn expression in a variable name, RPN final stack size != 1, rpn expressions without DEF or CDEF variables are not supported. All the error generate in different scenarios when I tried to fix it. Below is code snippet for your reference.

 rrdfile1  = file1.rrd
 rrdfile2 = file2.rrd
 rrdfile3 =  file3.rrd
cmdline = cmdline + 'DEF:used_file1=file1:license_out:MAX:step=' + step_value + ' ' + \
cmdline = cmdline + \
  VDEF: 'min_file1 = used_file1,MINIMUM' + \
  VDEF: 'max_file1 = used_file1,MAXIMUM' + \
  VDEF: 'cur_file1 = used_file1,LAST' + \
  VDEF: 'min_file2 = used_file2,MINIMUM' + \
  VDEF: 'max_file2 = used_file2,MAXIMUM' + \
  VDEF: 'cur_file2 = used_file2,LAST' + \
  VDEF: 'min_file3 = used_file3,MINIMUM' + \
  VDEF: 'max_file3 = used_file3,MAXIMUM' + \
  VDEF: 'cur_file3 = used_file3,LAST' + \  

I tried to sum like this :

cmdline = cmdline + 'CDEF:Total_min = min_file1,min_file2, min_file3, +, +, + ' '
cmdline = cmdline + 'CDEF:Total_max = max_file1,max_file2, max_file3, +, +, + ' '
cmdline = cmdline + 'CDEF:Total_cur = cur_file1,cur_file2, cur_file3, +, +, + ' '

Also, tired different method but nothing worked, I know that we cannot sum like this we should pass DEF variable in CDEF but not getting how to do that. Could you please help me out. The above mention code is not actual code just for your reference.

Thank you in advance.

1 Answers1

0
"invalid rpn expression in a variable name, RPN final stack size != 1, rpn expressions without DEF or CDEF variables are not supported"

This error message is telling you the problem; your RPN function (probably in a CDEF) is formatted incorrectly. The reason is that you need to have a DEF or CDEF variable in there, and you are using VDEF variables.

What is the difference?

Well, a DEF or a CDEF is a series of values, that can potentially be graphed. A VDEF on the other hand is a single value summary over the whole time series.

Your DEF is a set of values straight from your RRD file, with a selected resolution (time step) and consolodation factor (AVG, MAX, MIN).

Your CDEF is a calculated set of values, working on at least one DEF or CDEF set.

Your VDEF, though, takes a set of values (from either DEF or CDEF) and summarises them. This is how you get the value for average over the whole day when your graph shows the averages over 5-min intervals.

So, how to do what you want to do?

What you need is to use a DEF to pull out the multiple time series with the correct Consolodation Factors from the RRD; then use a CDEF to total them. You might want to also use a VDEF ot get a single value for the text in the footer.

Example:

DEF:lasta=file.rrd:a:LAST
DEF:lastb=file.rrd:b:LAST
CDEF:lasttotal=lasta,lastb,+
DEF:maxa=file.rrd:a:MAXIMUM
DEF:maxb=file.rrd:b:MAXIMUM
CDEF:maxtotal=maxa,maxb,+
LINE:lasttotal#ff0000:"Last
LINE:maxtotal#00ff00:"Maximum for this interval"
VDEF:overallmaxtotal=maxtotal,MAXIMUM
PRINT:overallmaxtotal:"The maximum for the whole graph is %lf"

However, you also have another problem.

As your granulatity decreases - and you move to larger time windows - the calculation of the total becomes more and more inaccurate. This is because max(a+b) <> max(a)+max(b) as the summation interval increases. This is true for both MAX and MIN, though not for LAST or AVG. The only way to get proper accuracy is to do the summation before storing in the RRD.

Also, it is likely that you would be better using AVERAGE than using LAST, as AVERAGE properly consolodates values as you move to a lower granularity.

There is a lot of information on the RRDTool website that can help you understand.

Steve Shipway
  • 3,754
  • 3
  • 22
  • 39
  • Well, thanks for your response. After changing it's working but now I am getting a strange output from CDEF variables. For example, I have values of maxa = 114, maxb = 1 and maxc = 5. and I am trying to sum but it is not returning accurate output and every time return maximum values as result. `CDEF:maxtotal=maxa,maxb,maxc,+,+` maxtotal return 114 as output. However, When I pass static values and sum it's worked. I don't know what exact problem it. `CDEF:maxtotal=maxa,maxb,100,+,+` output got 214, changed number and found that everytime it's sum with max only. – Md Mushtaque Ansari Sep 14 '18 at 13:04
  • You need to remember that a CDEF and a DEF are _not_ single values; they are time series. A VDEF is a single value. The 'MAX' on a DEF specifies the consolodation function to use as you summarise each interval; the MAX on a VDEF specifies how you consolodate the entire series. The sum of the maxima is not equal to the maxima of the sum unless they all peak at the same time! – Steve Shipway Sep 16 '18 at 22:24
  • Example: if maxa=(1,3,5) and maxb=(3,2,1) then maxtotal=(4,5,6). Then, your VDEF shows the max for A as 5, for B as 4; but the overall maxtotal is 6, not 9. – Steve Shipway Sep 16 '18 at 22:33