]> git.itanic.dy.fi Git - rrdd/commitdiff
rrdtool: Stop update times from drifting
authorTimo Kokkonen <timo.t.kokkonen@iki.fi>
Sun, 25 Aug 2019 12:30:58 +0000 (15:30 +0300)
committerTimo Kokkonen <timo.t.kokkonen@iki.fi>
Fri, 13 Sep 2019 09:46:31 +0000 (12:46 +0300)
With rrdtool, database updates should rather take place evenly at the
beginning of each update interval. If it happens at random places
within the interval, rrdtool will try to interpolate the data to make
it "fit better" within the data points. This causes unexpected data
values to be generated into the database.

Make each updates happen consitently at the beginning of the window to
ensure the graphs contain as good raw samples as possible.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
rrdtool.c

index c92dee186c56c9a28951d10aa089ab47f0816419..6748c39af5c937dced74c00f1fe6c1f128074bb4 100644 (file)
--- a/rrdtool.c
+++ b/rrdtool.c
@@ -315,7 +315,13 @@ static int do_rrdtool_update_data(struct rrd_database *rrd)
 
 int rrdtool_update_data(struct rrd_database *rrd)
 {
-       rrd->last_update = time(0);
+       time_t now = time(0);
+
+       /*
+        * This will put our last update slightly into past, but
+        * ensures our update interval will not drift over time.
+        */
+       rrd->last_update = now - now % rrd->interval;
 
        return queue_work(WORK_PRIORITY_HIGH, "rrdtool_update_data",
                        (work_fn_t *)do_rrdtool_update_data, rrd);