How to create a DS to store the accumulated result of another DS with rrdtool

StackOverflow https://stackoverflow.com/questions/20900191

  •  23-09-2022
  •  | 
  •  

Domanda

I want to create a rrd file with two data souces incouded. One stores the original value the data, name it 'dc'. The other stores the accumulated result of 'dc', name it 'total'. The expected formula is current(total) = previous(total) + current(dc). For example, If I update the data sequence (2, 3, 5, 4, 9) to the rrd file, I want 'dc' is (2, 3, 5, 4, 9) and 'total' is (2, 5, 15, 19, 28).

I tried to create the rrd file with the command line below. The command fails and says that the PREV are not supported with DS COMPUTE.

rrdtool create test.rrd --start 920804700 --step 300 \
  DS:dc:GAUGE:600:0:U \
  DS:total:COMPUTE:PREV,dc,ADDNAN \
  RRA:AVERAGE:0.5:1:1200 \
  RRA:MIN:0.5:12:2400 \
  RRA:MAX:0.5:12:2400 \
  RRA:AVERAGE:0.5:12:2400

Is there an alternative manner to define the DS 'total' (DS:total:COMPUTE:PREV,dc,ADDNAN) ?

È stato utile?

Soluzione

rrdtool does not store 'original' values ... it rather samples to signal you provide via the update command at the rate you defined when you setup the database ... in your case 1/300 Hz

that said, a total does not make much sense ...

what you can do with a single DS though, is build the average value over a time range and multiply the result with the number of seconds in the time range and thus arrive at the 'total'.

Altri suggerimenti

Sorry a bit late but may be helpful for someone else.

Better to use RRDtool's ' mrtg-traffic-sum ' package which when I'm using an rrd with GAUGE DS & LAST a the RRA's so it's allowing me to collect monthly traffic volumes & quota limits.

eg: Here is a basic Traffic chart with no traffic quota.

root@server:~# /usr/bin/mrtg-traffic-sum --range=current --units=MB /etc/mrtg/R4.cfg 
Subject: Traffic total for '/etc/mrtg/R4.cfg' (1.9) 2022/02

Start: Tue Feb  1 01:00:00 2022
End:   Tue Mar  1 00:59:59 2022
Interface                                    In+Out in MB
------------------------------------------------------------------------------
eth0                                                    0
eth1                                                14026
eth2                                                 5441
eth3                                                    0
eth4                                                15374
switch0.5                                           12024
switch0.19                                            151
switch0.49                                              1
switch0.51                                              0
switch0.92                                           2116
root@server:~# 

From this you can then write up a script that will generate a new rrd which stores these values & presto you have a traffic volume / quota graph.

Example fixed traffic volume chart using GAUGE

This thread reminded me to fix this collector that had stopped & just got around to posting ;)

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top