Code

As some of you may know that I have created a patch for rrdtool 1.2 a few years...
authoroetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa>
Fri, 7 Nov 2008 14:07:53 +0000 (14:07 +0000)
committeroetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa>
Fri, 7 Nov 2008 14:07:53 +0000 (14:07 +0000)
values for graphing.

The patch has been mostly rewritten and the following changes have been made:

   * high dependency on mysql has been reduced by avoiding the
     temporary tables (which was bad for mysql replication)
   * The number of executed SQL-Statements for one CDEF has been
     reduced to 1 compared to 11 SQLs (including CREATE TEMPORARY
     TABLE) - for patch against version 1.2
   * All consolidation is done in rrdtool itself (MIN,MAX,AVERAGE)
   * Additional consolidation functions are COUNT and SIGMA, which give
     information on statistics on a per "time-bin" basis.
   * All these consolidation values are always returned as separate
     columns, that are returned by RRD and the consolidation function
     given as Argument is ignored.
     Main reason is that this way there is only one call to rrd_fetcht
     and thus the database even if we need to fetch for example min,
     avg and max. Compare this to 3 calls in case of different
     consolidation functions - and if you want to get SIGMA and COUNT
     as well it is still only one call to the backend and the database.
   * Some previous existing features have been taken out at the moment
     to allow for this reduced set of SQL queries.
         o prediction using the values from the last X days at the same
           time
         o the corresponding sigma calculation
   * The idea is to create generic CDEF's that will do the same thing,
     but that is also available when using RRD-files (similar to TREND,
     but with another scope)
     This will get posted as a separate patch.
   * Overall performance should be much better and the patch as a whole
     simpler.
   * The patch also includes modifications to the configuration
     infrastructure, to make libdbi support optional.

-- Martin Sperl

git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@1650 a5681a0c-68f1-0310-ab6d-d61299d08faa

CONTRIBUTORS
configure.ac
src/Makefile.am
src/rrd_fetch.c
src/rrd_tool.h

index 9b485a6a5dd148eb9e2300585b284175f8866eea..02b72a76f24f8a1935a1ba841530b5f08459e754 100644 (file)
@@ -77,7 +77,7 @@ Wim Heirman <wim.heirman elis.ugent.be> --units=si option
 Wolfgang Schrimm <wschrimm with uni-hd.de> xport function
 Wrolf Courtney <wrolf with wrolf.net> (HP-UX)
 hendrik visage <hvisage with is.co.za>
-Martin Sperl <rrdtool martin.sperl.org> (CDEF prediction functions)
+Martin Sperl <rrdtool martin.sperl.org> (CDEF prediction functions, libdbi)
 Philippe Simonet <philippe.simonet with swisscom.ch> (Windows Binaries)
 Alexander Lucke (lucke with dns-net.de) 
  of DNS:NET Internet Services (www.dns-net.de) http://rrdtool.org
index f08b4e97be8c369bef0e227197158ccdc2f953c7..224f013d5072ff74b55473576421165aafde39dc 100644 (file)
@@ -468,6 +468,25 @@ AC_LANG_POP(C)
 
 CONFIGURE_PART(Find 3rd-Party Libraries)
 
+AC_ARG_ENABLE(libdbi,[  --disable-libdbi        do not build in support for libdbi],[have_libdbi=no],[
+  XXX=$LIBS
+  LIBS="$LIBS -ldbi -ldl"
+  AC_MSG_CHECKING(for libdbi)
+  AC_LINK_IFELSE(
+    [AC_LANG_PROGRAM([[#include <dbi/dbi.h>]], 
+                     [[dbi_initialize(NULL)]]
+                    )
+    ],[AC_DEFINE(HAVE_LIBDBI,[1],[have got libdbi installed])
+       AC_MSG_RESULT([yes])
+       have_libdbi=yes
+    ],[LIBS=$XXX
+       AC_MSG_RESULT([no])
+       have_libdbi=no
+       exit 1
+    ]
+  )
+])
+AM_CONDITIONAL(BUILD_LIBDBI,[test $have_libdbi != no])
 
 AM_CONDITIONAL(BUILD_RRDCGI,[test $enable_rrdcgi != no])
 
@@ -926,6 +945,7 @@ echo " Build Python Bindings: $enable_python"
 echo "          Build rrdcgi: $enable_rrdcgi"
 echo "       Build librrd MT: $enable_pthread"
 echo "     Link with libintl: $enable_libintl"
+echo "           With libDBI: $have_libdbi"
 echo
 echo "             Libraries: $ALL_LIBS"
 echo
index 9c14263c40fdf1e498ad188c2c8df26251425d5d..8913e4add8b117833aab02121d5d74b8d23ca0be 100644 (file)
@@ -58,6 +58,10 @@ noinst_HEADERS = \
        fnv.h rrd_graph.h \
        rrd_is_thread_safe.h
 
+if BUILD_LIBDBI
+RRD_C_FILES += rrd_fetch_libdbi.c
+endif
+
 if BUILD_GETOPT
 noinst_HEADERS += rrd_getopt.h
 UPD_C_FILES += rrd_getopt.c rrd_getopt1.c
index d821dfaf89d6b6bf95347fc6de4b126c44a83aa7..83b0cf6fcc584334e0bfa0eb20b2e74615113fa3 100644 (file)
@@ -235,6 +235,15 @@ int rrd_fetch_fn(
             *start, *end, *step);
 #endif
 
+#ifdef HAVE_LIBDBI
+    /* handle libdbi datasources */
+    if (strncmp("sql",filename,3)==0) {
+      if (filename[3]==filename[4]) {
+       return rrd_fetch_fn_libdbi(filename,cf_idx,start,end,step,ds_cnt,ds_namv,data);
+      }
+    }
+#endif
+
     rrd_init(&rrd);
     rrd_file = rrd_open(filename, &rrd, RRD_READONLY);
     if (rrd_file == NULL)
index 43781da464783b56d6100a1eef71d9de06fa87c9..f58cd784264fecb93c391aa70a0667beefb9aa08 100644 (file)
@@ -92,6 +92,16 @@ extern    "C" {
             char ***ds_namv,
             rrd_value_t **data);
 
+
+#ifdef HAVE_LIBDBI
+int rrd_fetch_fn_libdbi(char *filename, enum cf_en cf_idx,
+                       time_t *start,time_t *end,
+                       unsigned long *step,
+                       unsigned long *ds_cnt,
+                       char        ***ds_namv,
+                       rrd_value_t **data);
+#endif
+
 #define RRD_READONLY    (1<<0)
 #define RRD_READWRITE   (1<<1)
 #define RRD_CREAT       (1<<2)