[clue] [tech] Calculate total bandwidth usage for an interface using rrdtool

David L. Anselmi anselmi at anselmi.us
Fri Jun 10 12:47:03 MDT 2011


Jim Ockers wrote:
> What I was thinking was, since we are allowed 5GB in a month, that I would figure out the total
> bandwidth used in the last 3 weeks, and if the total bandwidth was 3/4 * 5GB then I would start
> throttling down the available bandwidth on the interface using tc and traffic shaping.

> I'd like a 3 week time interval, and I want it to interpolate and use zero for NaNs, and give me
> the AVERAGE BANDWIDTH USAGE FOR THE LAST 3 WEEKS IN ONE NUMBER.

So you don't really want average bandwidth.  You want bytes transferred.  (You want a value, not a 
rate, and a total, not an average.)

What numbers are you getting from the interface?  If you're just using tx/rx_bytes what does rrdtool 
get you (since tx/rx_bytes is what you want)?

Seems to me that tx/rx_bytes have these problems:

They roll over eventually.  On a 32 bit system that might be before 5GB.

They can't be zeroed unless you reload the driver module (maybe things are different now but I 
didn't quickly find another way to reset them).

If you reset the counters at the beginning of the month you'll need a way to detect premature 
resets.  Maybe rrdtool can help with that.

rrdtool seems intent on thinking about your raw numbers in intervals and I don't think that's the 
problem you have.  But maybe there's an example of people using it to notice thresholds being 
crossed (running out of disk space or memory).

If you're just looking at the kernel counters, does SNMP offer a way to get the data differently?

Dave


More information about the clue mailing list