Turns out commit
03aa50c69 didn't fix the drifting problem
completely. It is still possible that acquiring the data takes
arbitrarily long time and we end up inserting the data in the middle
of the database update interval, which will cause rrdtool to
interpolate the data point with previous or next entry.
Fix it by taking the timestamp before we start the update procedure
and using that time as we feed in the data.
Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
static int do_rrdtool_update_data(struct rrd_database *rrd)
{
- char data[RRD_DATA_MAX_LEN + 3]; /* 3 == "N:" + NULL termination */
+ char data[RRD_DATA_MAX_LEN + 12]; /* 12 == "%s:" + NULL termination */
char cmd[] = RRDTOOL_CMD;
// char cmd[] = "echo";
char *const cmdline[] = {
int l;
bzero(data, sizeof(data));
- l = sprintf(data, "N:");
+ l = sprintf(data, "%zd:", time(NULL));
if (rrd->parser && rrd->parser->parse) {
rrd->parser->parse(data + l, rrd->parser_data,