0

The following data comes from a mobile phone provider, it's a list of kb's downloaded at a certain time, usually on a per minute basis.

It's not the average, not the max, but the total of that time interval, which allows to track the data consumption precisely. These graphs were made with PIL, and instead of showing spikes to indicate a large data consumption, large steps can be seen, which is much more revealing, because it doesn't just tell "much happened here", but "exactly this much happened here". For example second graph Sat 10 at night 100mb. A rate-change graph wouldn't be as informative.

I'm also trying to find a way to do this with rrd.

I was mislead when using the COUNTER to track my networks data usage into thinking that I would be able to precisely compute the monthly/weekly accumulated data usage, but now it turned out to be a wrong assumption.

How I store my data in rrd in order to be able to easily generate graphs like below? Would that be by using ABSOLUTE and before updating it I would subtract the previous insertion value? Would that be precise down to the byte when checking the monthly usage?

User 1

User 2

2 Answers 2

2

You can add up all the value in your chart quite easily:

CDEF:sum=data,$step_width,*,PREV,ADDNAN

if your chart covers just one month, that should be all you have todo. If you want to have it cover multiple months, you will have to use a combination of IF and TIME operators to reset the line to 0 at the start of the month.

Version 1.5.4 will contain an additional operator called STEPWIDTH, which pushes the step width onto the stack, making this even simpler.

1
  • Thanks. I'm now saving the ifHCIn/OutOctets in parallel as a GAUGE, to be able to compare. My worst problem was that at a given point in time I decreased the sampling rate to 1 minute without noticing that my step was of 60 seconds, so I have tons of NaN's stored, heartbeat was/is 0. :( No wonder things weren't adding up.
    – Daniel F
    Aug 5, 2015 at 13:05
1

This is a common question which very few answers online but I first encountered a method to do this with RRD in 2009.

The DS type to use is a GAUGE and in your update script manually handle resetting the GAUGE to 0 at the start of the month for monthly usage graphs.

Then came along RRDTool's ' mrtg-traffic-sum ' package. More recently I've had to monitor both traffic bandwidth and traffic volume so I created a standard RRD for that first and confirmed that was working.

So with the bandwidth being sampled (captured to the RRD), then use the mrtg-traffic-sum tool to generate the stat's needed as in the example below then pump them into another RRD created with just the GAUGE DS type and just LAST (no need for MIN/AVG/MAX).

This allows using RRDs to collect both traffic bandwidth as well as monthly traffic volumes / traffic quota limits.

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 mrtg-traffic-sum just write up a script that will populate your 2nd rrd with these values & presto you have a traffic volume / quota graph also.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.