[rrd-users] More observations and questions on COUNTER

Simon Hobson linux at thehobsons.co.uk
Sun Oct 24 09:48:14 CEST 2010

Philip Peake wrote:

>2.	I now understand the "spike" - I assumed that any loss of 
>connection would mean that the data source was being re-started, and 
>that counters would start again from zero. What I must have seen 
>when I saw this occur "naturally" must have been a network problem, 
>which simply broke the connection, and the counters carried on 
>running. I need to try to account for that somehow ... hard to know 
>how really. I suppose I can store previous values, and when the DS 
>comes back online check to see if the value is less than the 
>recorded value, in which case assume a restart.

I did have a suspicion that might be your problem - hence why I 
wanted to see your input data. As it happens, once you saw it, you 
spotted it too.

What I would do is keep adding NaN rather than zero while the data 
source is unreadable. To my mind, it's more accurate - until you can 
read the source the data is unknown, not zero. If you do that, then 
the spike will disappear since the first true reading will simply set 
a base value to compute the next rate from.
If you really want to store zero, then you could :
update at t-1 with zero - this will a;most fill the previous slot with zero
update at t with Nan - close the previous slot, 29/30ths of which 
will be zero and so the result will be zero
update at t+1 with x

Your first computed reading will still be out by 1/30th because the 
update at t+1 will "lose" 1 second of your 30 second slot - making 
the rate calculation (x2 - x1) / 29 instead of (x2 - x1) / 30.

>3.	I really wanted the stored values to be the same as the input 
>values. They obviously are not, which seems odd since the sample 
>period is 30 seconds, and I take great care to ensure that the 
>values sampled as close to 30 seconds apart as I can, and then 
>entered with a time set to a 30 second boundary. I thought this 
>should ensure that the stored value would be precisely the 
>difference between the current and previous value.

Can you point out anomalies ? I've had a very quick look and the 
numbers seem about right to me. You do understand that RRD tool only 
ever stores rates don't you ?
Ie, updates of :

80741789 - 80740899 = 890
890 / 30 = 29.667

value stored :
1287866370: 2.9666666667e+01

Simon Hobson

Visit http://www.magpiesnestpublishing.co.uk/ for books by acclaimed
author Gladys Hobson. Novels - poetry - short stories - ideal as
Christmas stocking fillers. Some available as e-books.

More information about the rrd-users mailing list