[rrd-users] DERIVE vs COUNTER
Alex van den Bogaerdt
alex at ergens.op.het.net
Fri Mar 21 16:12:34 CET 2008
On Sat, Mar 22, 2008 at 01:49:16AM +1100, Jean-Yves Avenard wrote:
> I want to measure the amount of traffic going through my ADSL link.
> The data will be fetched using snmp every minute.
> One issue is that the snmp server on my ADSL modem only supports 32
> bits counter. So it is possible for the counter to reset due to an
That's no reset. Don't think of it that way, it will just confuse you.
> Another issue is that if there's a connection drop-out (and this can
> happen several times a day on my DSL connection) the modem when it
> re-establishes the connection reset the counter I am reading.
This should be detectable. A suggestion follows below.
> In the past I used mrtg for measuring the bandwidth. Unfortunately,
> often after a reset of the counter that wasn't due to an overflow,
> mrtg recorded the value as if an overflow did happen and it would mess
> up my graphs and the scale used (the remaining of the traffic would
> look like a flat line close to 0).
> My DSL modem is syncing at 12mbit/s, so an overflow can not happen
> within a 1 or even 5 minutes interval.
And, perhaps more important, the rate computed cannot be more than
12mbps. Use this knowledge, that's why rrdtool know about a minimum
and maximum rate.
But use this only as a safe-guard to detect the most obvious problems.
It won't detect a reset which happens when the counter was at
> The RRD documentation describes the difference between the type
> COUNTER and DERIVE.
> Which type of data should I use when using rrdtool create?
Using DERIVE, together with a minimum rate of zero, is a trick to
ignore *any* counter value which is lower than the previous one.
So, the question you need to ask yourself is: do you want to take
a few shortcuts at the expense of loosing a little bit of information.
If yes: go for derive + minimum_rate==0
If no: go for counter, and detect resets
> is there a way for rrd to always determine if a reset is a due to a
> reset of the modem or due to an overflow?
No, not in rrdtool. That is a front-end responsibility.
As a start: you can probably find uptime in snmp. If this is lower
than the previous time assume a reset has happened.
Update with "U" at time "$time-1"
Update with the current counter value at time "$time"
Or, if you want:
find out how long the device is running since the reset -> boottime
Update with "U" at time "$boottime-1"
Update with zero at time "$boottime"
Update with the current counter value at time "$currenttime"
In either case, your front-end (the script calling rrdtool) should
keep track of that uptime variable. Either keep a daemon running,
or fetch and store the uptime each time your script runs.
Alex van den Bogaerdt
More information about the rrd-users