[rrd-users] Re: stuck building RRD
Alex van den Bogaerdt
alex at ergens.op.het.net
Wed Oct 26 15:16:47 MEST 2005
On Wed, Oct 26, 2005 at 08:57:49AM -0400, Craig Packard wrote:
> Ok, I think I understand this. Now as a fix I could 'run' the data collector
> every 2.5 minutes, that would pretty much make certain that at least one
> data point made it in time. I guess I could also raise my heartbeat up to
> 600 or even 900. My question is if the RRD gets two data points (1 every
> 2.5min) does it average them together or drop the second one? My
> understanding is it will average them since my RRA is AVERAGE but I'm not
> sure. I need each data point to be used.
If you need each data point, and if you measure every 300 seconds, why not
alter the timestamp slightly to match your RRD ? It seems to me you can
live with a difference of a second or so.
In stead of using "rrdtool update your.rrd N:$value", compute the timestamp,
make sure it is a whole multiple of 300, use that value:
"rrdtool update your.rrd $timestamp:$value"
You'd still have trouble if the schedular didn't fire for whatever reason.
That in itself is not the problem I guess, it's those few seconds away from
the exact time needed.
Your timestamp would be computed like this:
1) take the current time, as seconds since the unix epoch
for instance: perl -e 'print time();'
2) add 100 (any number less than 300, close to 0 for accuracy but
far enough away to actually work)
3) modulo 300, remove that
Using integer division, /300 followed by *300 does the trick.
"timestamp=int(timestamp/300)*300" for instance.
Or use "timestamp = timestamp - (timestamp%300)" or similar.
Whatever works for you, as long as the resulting timestamp is a whole multiple
of your step size, you'd be OK.
echo -n "$(date): "
echo -n "$(date -d 15:15): "
date -d 15:15 +%s
perl -e 'print "example perl script: " . int(time()/300)*300 . "\n";'
Wed Oct 26 15:15:56 CEST 2005: 1130332556
Wed Oct 26 15:15:00 CEST 2005: 1130332500
example perl script: 1130332500
Alex van den Bogaerdt
Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help mailto:rrd-users-request at list.ee.ethz.ch?subject=help
More information about the rrd-users