* rrd_create.c creates new rrds
*****************************************************************************/
+#include <stdlib.h>
+#include <time.h>
#include <locale.h>
#include "rrd_tool.h"
const char *def,
rrd_t *rrd,
int ds_idx);
+long int rra_random_row(
+ rra_def_t *);
int rrd_create(
int argc,
* would occur for cur_row = 1 because rrd_update increments
* the pointer a priori. */
for (i = 0; i < rrd->stat_head->rra_cnt; i++) {
- rrd->rra_ptr->cur_row = rrd->rra_def[i].row_cnt - 1;
+ rrd->rra_ptr->cur_row = rra_random_row(&rrd->rra_def[i]);
write(rrd_file, rrd->rra_ptr, sizeof(rra_ptr_t));
}
rrd_close(rrd_file_dn);
return (0);
}
+
+static int rand_init = 0;
+
+long int
+rra_random_row(rra_def_t *rra)
+{
+ if (!rand_init)
+ {
+ srandom((unsigned int)time(NULL) + (unsigned int)getpid());
+ rand_init++;
+ }
+
+ return random() % rra->row_cnt;
+}