summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 43aaf4a)
raw | patch | inline | side by side (parent: 43aaf4a)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Wed, 23 Jul 2008 15:03:43 +0000 (15:03 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Wed, 23 Jul 2008 15:03:43 +0000 (15:03 +0000) |
program/src/rrd_restore.c | patch | blob | history |
index 23f53bfb973c9082ba13def6a9b944e1450e8acd..d92210fd6e3f58f4fbbc9826f2a0a54dacce4545 100644 (file)
break;
}
- /* Set the RRA pointer to the last value in the archive */
- cur_rra_ptr->cur_row = cur_rra_def->row_cnt - 1;
+ /* Set the RRA pointer to a random location */
+ cur_rra_ptr->cur_row = random() % cur_rra_def->row_cnt;
return (status);
} /* int parse_tag_rra */
{
FILE *fh;
unsigned int i;
- unsigned int value_count;
+ unsigned int rra_offset;
if (strcmp("-", file_name) == 0)
fh = stdout;
fwrite(rrd->rra_ptr, sizeof(rra_ptr_t), rrd->stat_head->rra_cnt, fh);
/* calculate the number of rrd_values to dump */
- value_count = 0;
- for (i = 0; i < rrd->stat_head->rra_cnt; i++)
- value_count += (rrd->rra_def[i].row_cnt * rrd->stat_head->ds_cnt);
+ rra_offset=0;
+ for(i=0; i < rrd->stat_head->rra_cnt; i++)
+ {
+ unsigned long num_rows = rrd->rra_def[i].row_cnt;
+ unsigned long cur_row = rrd->rra_ptr[i].cur_row;
+ unsigned long ds_cnt = rrd->stat_head->ds_cnt;
- fwrite(rrd->rrd_value, sizeof(rrd_value_t), value_count, fh);
+ fwrite(rrd->rrd_value + (rra_offset + num_rows-1 - cur_row) * ds_cnt,
+ sizeof(rrd_value_t), (cur_row+1)*ds_cnt, fh);
+
+ fwrite(rrd->rrd_value + rra_offset * ds_cnt,
+ sizeof(rrd_value_t), (num_rows-1 - cur_row)*ds_cnt, fh);
+
+ rra_offset += num_rows;
+ }
/* lets see if we had an error */
if (ferror(fh)) {
{
rrd_t *rrd;
+ srandom((unsigned int)time(NULL) + (unsigned int)getpid());
/* init rrd clean */
optind = 0;
opterr = 0; /* initialize getopt */