0

I am trying to calculate the total octets_in using python rrdtool. I have this but it's not giving me the correct output.

here is a data sample

[
   406.29947919463086
],
[
   433.0391666666667
],
[
   430.70380365448506
]

I want the total to be 1269

my def, cdef and vdef are

f'DEF:OCTETS_IN={self.file_name}:OCTETS_IN:AVERAGE'
'CDEF:octets_in=OCTETS_IN,PREV,ADDNAN',
'VDEF:out_octets_in_total=octets_in,AVERAGE'

The only operators I can use from rrdtool are AVERAGE, MINIMUM, MAXIMUM and PERCENT and they all give the wrong results.

Anybody know how to do this?

Jebanisa
  • 111
  • 2
  • 15

1 Answers1

0

If you want to calculate the total of a rate variable over the time period, then there is a useful VDEF function to calculate sum( var x stepsize )

For example,

DEF:octetspersec=file.rrd:IN:AVERAGE
VDEF:octetstotal=octetspersec,TOTAL

Now, octetstotal holds the total number of octets over the graph time window based on the rate held in the octetspersec variable.

If you have an older version of RRDTool, you may not have the TOTAL function. In this case, use AVERAGE, then multiply by STEPWIDTH and the pixel width of the graph.

Note that if your variable already holds the number of bytes for that interval, then you will not need to multiply by the step width. Since the TOTAL function does this (as it assumes the variable is a rate) you then need to divide the VDEF result by STEPWIDTH again.

For more details on using the RPN functions, see here

Steve Shipway
  • 3,754
  • 3
  • 22
  • 39