Merge branch 'collectd-4.10' into collectd-5.0
authorFlorian Forster <octo@collectd.org>
Sat, 28 Jan 2012 11:26:41 +0000 (12:26 +0100)
committerFlorian Forster <octo@collectd.org>
Sat, 28 Jan 2012 11:26:41 +0000 (12:26 +0100)
README
configure.in
src/Makefile.am
src/collectd-python.pod
src/common.c
src/ipvs.c
src/oracle.c
src/python.c

diff --git a/README b/README
index 6badeec..ac79ce5 100644 (file)
--- a/README
+++ b/README
@@ -632,7 +632,8 @@ Prerequisites
     <http://code.google.com/p/protobuf-c/>
 
   * libpython (optional)
-    Used by the `python' plugin. Currently, only 2.3 ≦ Python < 3 is supported.
+    Used by the `python' plugin. Currently, Python 2.3 and later and Python 3
+    are supported.
     <http://www.python.org/>
 
   * librabbitmq (optional; also called “rabbitmq-c”)
index f0a189c..8040193 100644 (file)
@@ -389,18 +389,36 @@ AC_CHECK_HEADERS(linux/netdevice.h, [], [],
 ])
 
 # For ipvs module
+have_linux_ip_vs_h="no"
 have_net_ip_vs_h="no"
 have_ip_vs_h="no"
+ip_vs_h_needs_kernel_cflags="no"
 if test "x$ac_system" = "xLinux"
 then
-       SAVE_CFLAGS="$CFLAGS"
-       CFLAGS="$CFLAGS $KERNEL_CFLAGS"
-
+       AC_CHECK_HEADERS(linux/ip_vs.h, [have_linux_ip_vs_h="yes"])
        AC_CHECK_HEADERS(net/ip_vs.h, [have_net_ip_vs_h="yes"])
        AC_CHECK_HEADERS(ip_vs.h, [have_ip_vs_h="yes"])
 
-       CFLAGS="$SAVE_CFLAGS"
+       if test "x$have_linux_ip_vs_h$have_net_ip_vs_h$have_ip_vs_h" = "xnonono" && test -d "$KERNEL_DIR"
+       then
+               SAVE_CFLAGS="$CFLAGS"
+               CFLAGS="$CFLAGS $KERNEL_CFLAGS"
+
+               AC_MSG_NOTICE([Did not find ip_vs.h. Trying again using headers from $KERNEL_DIR.])
+
+               AC_CHECK_HEADERS(linux/ip_vs.h, [have_linux_ip_vs_h="yes"])
+               AC_CHECK_HEADERS(net/ip_vs.h, [have_net_ip_vs_h="yes"])
+               AC_CHECK_HEADERS(ip_vs.h, [have_ip_vs_h="yes"])
+
+               if test "x$have_linux_ip_vs_h" = "xyes" || test "x$have_net_ip_vs_h" = "xyes" || test "x$have_ip_vs_h" = "xyes"
+               then
+                       ip_vs_h_needs_kernel_cflags="yes"
+               fi
+
+               CFLAGS="$SAVE_CFLAGS"
+       fi
 fi
+AM_CONDITIONAL(IP_VS_H_NEEDS_KERNEL_CFLAGS, test "x$ip_vs_h_needs_kernel_cflags" = "xyes")
 
 # For quota module
 AC_CHECK_HEADERS(sys/ucred.h, [], [],
@@ -4383,7 +4401,7 @@ then
        plugin_vserver="yes"
        plugin_wireless="yes"
 
-       if test "x$have_net_ip_vs_h" = "xyes" || test "x$have_ip_vs_h" = "xyes"
+       if test "x$have_linux_ip_vs_h" = "xyes" || test "x$have_net_ip_vs_h" = "xyes" || test "x$have_ip_vs_h" = "xyes"
        then
                plugin_ipvs="yes"
        fi
@@ -4802,11 +4820,16 @@ AC_SUBST(LOAD_PLUGIN_CSV)
 
 dnl ip_vs.h
 if test "x$ac_system" = "xLinux" \
-       && test "x$have_net_ip_vs_h$have_ip_vs_h" = "xnono"
+       && test "x$have_linux_ip_vs_h$have_net_ip_vs_h$have_ip_vs_h" = "xnonono"
 then
        enable_ipvs="$enable_ipvs (ip_vs.h not found)"
 fi
 
+if test "x$ip_vs_h_needs_kernel_cflags" = "xyes"
+then
+       enable_ipvs="$enable_ipvs (needs $KERNEL_CFLAGS)"
+fi
+
 dnl Perl bindings
 AC_ARG_WITH(perl-bindings, [AS_HELP_STRING([--with-perl-bindings@<:@=OPTIONS@:>@], [Options passed to "perl Makefile.PL".])],
 [
index 5728144..259a381 100644 (file)
@@ -463,7 +463,9 @@ endif
 if BUILD_PLUGIN_IPVS
 pkglib_LTLIBRARIES += ipvs.la
 ipvs_la_SOURCES = ipvs.c
+if IP_VS_H_NEEDS_KERNEL_CFLAGS
 ipvs_la_CFLAGS = $(AM_CFLAGS) $(KERNEL_CFLAGS)
+endif
 ipvs_la_LDFLAGS = -module -avoid-version
 collectd_LDADD += "-dlopen" ipvs.la
 collectd_DEPENDENCIES += ipvs.la
index 267296c..5fd1f4f 100644 (file)
@@ -21,7 +21,7 @@ collectd-python - Documentation of collectd's C<python plugin>
   <Plugin python>
     ModulePath "/path/to/your/python/modules"
     LogTraces true
-    Interactive true
+    Interactive false
     Import "spam"
 
     <Module spam>
index e1f204b..0069a8b 100644 (file)
@@ -543,7 +543,8 @@ int check_create_dir (const char *file_orig)
                }
 
                while (42) {
-                       if (stat (dir, &statbuf) == -1)
+                       if ((stat (dir, &statbuf) == -1)
+                                       && (lstat (dir, &statbuf) == -1))
                        {
                                if (errno == ENOENT)
                                {
index ab76f1e..fa89489 100644 (file)
@@ -45,7 +45,9 @@
 #endif /* HAVE_NETINET_IN_H */
 
 /* this can probably only be found in the kernel sources */
-#if HAVE_NET_IP_VS_H
+#if HAVE_LINUX_IP_VS_H
+# include <linux/ip_vs.h>
+#elif HAVE_NET_IP_VS_H
 # include <net/ip_vs.h>
 #elif HAVE_IP_VS_H
 # include <ip_vs.h>
index ec45996..4415b48 100644 (file)
@@ -91,15 +91,16 @@ static void o_report_error (const char *where, /* {{{ */
   char buffer[2048];
   sb4 error_code;
   int status;
+  unsigned int record_number;
 
   /* An operation may cause / return multiple errors. Loop until we have
-   * handled all errors available. */
-  while (42)
+   * handled all errors available (with a fail-save limit of 16). */
+  for (record_number = 1; record_number <= 16; record_number++)
   {
     memset (buffer, 0, sizeof (buffer));
     error_code = -1;
 
-    status = OCIErrorGet (eh, /* record number = */ 1,
+    status = OCIErrorGet (eh, (ub4) record_number,
         /* sqlstate = */ NULL,
         &error_code,
         (text *) &buffer[0],
@@ -121,8 +122,7 @@ static void o_report_error (const char *where, /* {{{ */
         buffer[buffer_length] = 0;
       }
 
-      ERROR ("oracle plugin: %s: %s failed: %s",
-          where, what, buffer);
+      ERROR ("oracle plugin: %s: %s failed: %s", where, what, buffer);
     }
     else
     {
@@ -700,7 +700,7 @@ static int o_read_database (o_database_t *db) /* {{{ */
         (OraText *) db->username, (ub4) strlen (db->username),
         (OraText *) db->password, (ub4) strlen (db->password),
         (OraText *) db->connect_id, (ub4) strlen (db->connect_id));
-    if (status != OCI_SUCCESS)
+    if ((status != OCI_SUCCESS) && (status != OCI_SUCCESS_WITH_INFO))
     {
       o_report_error ("o_read_database", "OCILogon", oci_error);
       DEBUG ("oracle plugin: OCILogon (%s): db->oci_service_context = %p;",
@@ -708,6 +708,10 @@ static int o_read_database (o_database_t *db) /* {{{ */
       db->oci_service_context = NULL;
       return (-1);
     }
+    else if (status == OCI_SUCCESS_WITH_INFO)
+    {
+      /* TODO: Print NOTIFY message. */
+    }
     assert (db->oci_service_context != NULL);
   }
 
index ee67388..4a828b4 100644 (file)
@@ -217,7 +217,7 @@ static int do_interactive = 0;
 
 static PyThreadState *state;
 
-static PyObject *cpy_format_exception;
+static PyObject *sys_path, *cpy_format_exception;
 
 static cpy_callback_t *cpy_config_callbacks;
 static cpy_callback_t *cpy_init_callbacks;
@@ -976,19 +976,10 @@ PyMODINIT_FUNC PyInit_collectd(void) {
 }
 #endif
 
-static int cpy_config(oconfig_item_t *ci) {
-       int i;
+static int cpy_init_python() {
        char *argv = "";
-       PyObject *sys, *tb;
-       PyObject *sys_path;
+       PyObject *sys;
        PyObject *module;
-       
-       /* Ok in theory we shouldn't do initialization at this point
-        * but we have to. In order to give python scripts a chance
-        * to register a config callback we need to be able to execute
-        * python code during the config callback so we have to start
-        * the interpreter here. */
-       /* Do *not* use the python "thread" module at this point! */
 
 #ifdef IS_PY3K
        /* Add a builtin module, before Py_Initialize */
@@ -1039,6 +1030,22 @@ static int cpy_config(oconfig_item_t *ci) {
        PyModule_AddIntConstant(module, "NOTIF_FAILURE", NOTIF_FAILURE);
        PyModule_AddIntConstant(module, "NOTIF_WARNING", NOTIF_WARNING);
        PyModule_AddIntConstant(module, "NOTIF_OKAY", NOTIF_OKAY);
+       return 0;
+}
+
+static int cpy_config(oconfig_item_t *ci) {
+       int i;
+       PyObject *tb;
+
+       /* Ok in theory we shouldn't do initialization at this point
+        * but we have to. In order to give python scripts a chance
+        * to register a config callback we need to be able to execute
+        * python code during the config callback so we have to start
+        * the interpreter here. */
+       /* Do *not* use the python "thread" module at this point! */
+
+       if (!Py_IsInitialized() && cpy_init_python()) return 1;
+
        for (i = 0; i < ci->children_num; ++i) {
                oconfig_item_t *item = ci->children + i;
                
@@ -1138,7 +1145,6 @@ static int cpy_config(oconfig_item_t *ci) {
                        WARNING("python plugin: Ignoring unknown config key \"%s\".", item->key);
                }
        }
-       Py_DECREF(sys_path);
        return 0;
 }