summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8c25e77)
raw | patch | inline | side by side (parent: 8c25e77)
author | Florian Forster <octo@huhu.verplant.org> | |
Wed, 12 Sep 2007 07:14:45 +0000 (09:14 +0200) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Wed, 12 Sep 2007 07:14:45 +0000 (09:14 +0200) |
When receiving data from a host that has a clock that lacks behind the servers
clock, the newly created rrd-files had a timestamp that was ten seconds in the
past from the server's point of view. If the client was, for example, 10:00
minutes late, there would therefore be 9:50 minutes of invalid data which cause
warnings, empty graphs and overall missery. This commit changes this behavior
to not use the default `begin' time but set it explicitely based on the
client's time.
clock, the newly created rrd-files had a timestamp that was ten seconds in the
past from the server's point of view. If the client was, for example, 10:00
minutes late, there would therefore be 9:50 minutes of invalid data which cause
warnings, empty graphs and overall missery. This commit changes this behavior
to not use the default `begin' time but set it explicitely based on the
client's time.
src/rrdtool.c | patch | blob | history |
diff --git a/src/rrdtool.c b/src/rrdtool.c
index d20a8142e87b9a6ed9988c686ccc979b4343e549..820ccdc1e71a9cab966d7b95319be0bc678f925f 100644 (file)
--- a/src/rrdtool.c
+++ b/src/rrdtool.c
return (ds_num);
}
-static int rrd_create_file (char *filename, const data_set_t *ds)
+static int rrd_create_file (char *filename, const data_set_t *ds, const value_list_t *vl)
{
char **argv;
int argc;
int ds_num;
int i, j;
char stepsize_str[16];
+ char begin_str[16];
int status = 0;
if (check_create_dir (filename))
return (-1);
}
- argc = ds_num + rra_num + 4;
+ argc = ds_num + rra_num + 6;
if ((argv = (char **) malloc (sizeof (char *) * (argc + 1))) == NULL)
{
return (-1);
}
+ assert (vl->time > 10);
+ status = snprintf (begin_str, sizeof (begin_str),
+ "%llu", (unsigned long long) (vl->time - 10));
+ if ((status < 1) || (status >= sizeof (begin_str)))
+ {
+ ERROR ("rrdtool plugin: snprintf failed.");
+ return (-1);
+ }
+
argv[0] = "create";
argv[1] = filename;
- argv[2] = "-s";
- argv[3] = stepsize_str;
+ argv[2] = "-b";
+ argv[3] = begin_str;
+ argv[4] = "-s";
+ argv[5] = stepsize_str;
- j = 4;
+ j = 6;
for (i = 0; i < ds_num; i++)
argv[j++] = ds_def[i];
for (i = 0; i < rra_num; i++)
{
if (errno == ENOENT)
{
- if (rrd_create_file (filename, ds))
+ if (rrd_create_file (filename, ds, vl))
return (-1);
}
else