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.
-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)
int ds_num;
int i, j;
char stepsize_str[16];
int ds_num;
int i, j;
char stepsize_str[16];
int status = 0;
if (check_create_dir (filename))
int status = 0;
if (check_create_dir (filename))
- argc = ds_num + rra_num + 4;
+ argc = ds_num + rra_num + 6;
if ((argv = (char **) malloc (sizeof (char *) * (argc + 1))) == NULL)
{
if ((argv = (char **) malloc (sizeof (char *) * (argc + 1))) == NULL)
{
+ 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[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;
for (i = 0; i < ds_num; i++)
argv[j++] = ds_def[i];
for (i = 0; i < rra_num; i++)
for (i = 0; i < ds_num; i++)
argv[j++] = ds_def[i];
for (i = 0; i < rra_num; i++)
- if (rrd_create_file (filename, ds))
+ if (rrd_create_file (filename, ds, vl))