your patch does not apply ... have a look at

 https://svn.oetiker.ch/rrdtool (yes I set one up for you)


Thanks for that, I will try it from the office in the morning.

I've re-done the patch against r1605, attached


Index: src/rrd_create.c
===================================================================
--- src/rrd_create.c	(revision 1605)
+++ src/rrd_create.c	(working copy)
@@ -24,8 +24,6 @@
     const char *def,
     rrd_t *rrd,
     int ds_idx);
-long int  rra_random_row(
-    rra_def_t *);
 
 static void rrd_free2(
     rrd_t *rrd);        /* our onwn copy, immmune to mmap */
@@ -767,7 +765,7 @@
      * 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 = rra_random_row(&rrd->rra_def[i]);
+        rrd->rra_ptr->cur_row = rrd_select_initial_row(rrd_file_dn, i, &rrd->rra_def[i]);
         rrd_write(rrd_file_dn, rrd->rra_ptr, sizeof(rra_ptr_t));
     }
 
@@ -824,15 +822,3 @@
     free(rrd->rrd_value);
 }
 
-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;
-}
Index: src/rrd_update.c
===================================================================
--- src/rrd_update.c	(revision 1605)
+++ src/rrd_update.c	(working copy)
@@ -1962,6 +1962,8 @@
                 (rrd_file, rrd, rra_idx, scratch_idx,
                  pcdp_summary, rra_time) == -1)
                 return -1;
+
+            rrd_notify_row(rrd_file, rra_idx, rra_pos_new, rra_time);
         }
 
         rra_start += rra_def->row_cnt * ds_cnt * sizeof(rrd_value_t);
Index: src/rrd.h
===================================================================
--- src/rrd.h	(revision 1605)
+++ src/rrd.h	(working copy)
@@ -369,6 +369,18 @@
     int       rrd_lock(
     rrd_file_t *file)
               RRD_DEPRECATED;
+    void      rrd_notify_row(
+    rrd_file_t *rrd_file,
+    int rra_idx,
+    unsigned long rra_row,
+    time_t rra_time)
+              RRD_DEPRECATED;
+    unsigned long rrd_select_initial_row(
+    rrd_file_t *rrd_file,
+    int rra_idx,
+    rra_def_t *rra
+    )
+              RRD_DEPRECATED;
 #endif                  /* defined(_RRD_TOOL_H) || defined(RRD_EXPORT_DEPRECATED) */
 
 #endif                  /* _RRDLIB_H */
Index: src/rrd_open.c
===================================================================
--- src/rrd_open.c	(revision 1605)
+++ src/rrd_open.c	(working copy)
@@ -54,6 +54,10 @@
 #endif
 #endif
 
+long int  rra_random_row(
+    rra_def_t *);
+
+
 /* Open a database file, return its header and an open filehandle,
  * positioned to the first cdp in the first rra.
  * In the error path of rrd_open, only rrd_free(&rrd) has to be called
@@ -648,3 +652,46 @@
 {
     free(mem);
 }
+
+/*
+ * rra_update informs us about the RRAs being updated
+ * The low level storage API may use this information for
+ * aligning RRAs within stripes, or other performance enhancements
+ */
+void rrd_notify_row(
+    rrd_file_t *rrd_file,
+    int rra_idx,
+    unsigned long rra_row,
+    time_t rra_time)
+{
+}
+
+/*
+ * This function is called when creating a new RRD
+ * The storage implementation can use this opportunity to select
+ * a sensible starting row within the file.
+ * The default implementation is random, to ensure that all RRAs
+ * don't change to a new disk block at the same time
+ */
+unsigned long rrd_select_initial_row(
+    rrd_file_t *rrd_file,
+    int rra_idx,
+    rra_def_t *rra
+    )
+{
+    return rra_random_row(rra);
+}
+
+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;
+}
+
_______________________________________________
rrd-developers mailing list
[email protected]
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers

Reply via email to