From: Florian Forster Date: Sat, 28 Jan 2012 11:26:41 +0000 (+0100) Subject: Merge branch 'collectd-4.10' into collectd-5.0 X-Git-Tag: collectd-5.0.3~4 X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=4ecefb9fb8183eadee48538553615c0425e51f69;hp=a24bf968e72f9a103a354dcc833619a40849cfcd;p=collectd.git Merge branch 'collectd-4.10' into collectd-5.0 --- diff --git a/README b/README index 6badeecd..ac79ce50 100644 --- a/README +++ b/README @@ -632,7 +632,8 @@ Prerequisites * 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. * librabbitmq (optional; also called “rabbitmq-c”) diff --git a/configure.in b/configure.in index f0a189c5..8040193b 100644 --- a/configure.in +++ b/configure.in @@ -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".])], [ diff --git a/src/Makefile.am b/src/Makefile.am index 57281440..259a3816 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 diff --git a/src/collectd-python.pod b/src/collectd-python.pod index 267296cf..5fd1f4f9 100644 --- a/src/collectd-python.pod +++ b/src/collectd-python.pod @@ -21,7 +21,7 @@ collectd-python - Documentation of collectd's C ModulePath "/path/to/your/python/modules" LogTraces true - Interactive true + Interactive false Import "spam" diff --git a/src/common.c b/src/common.c index e1f204b9..0069a8b6 100644 --- a/src/common.c +++ b/src/common.c @@ -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) { diff --git a/src/ipvs.c b/src/ipvs.c index ab76f1eb..fa894897 100644 --- a/src/ipvs.c +++ b/src/ipvs.c @@ -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 +#elif HAVE_NET_IP_VS_H # include #elif HAVE_IP_VS_H # include diff --git a/src/oracle.c b/src/oracle.c index ec45996b..4415b489 100644 --- a/src/oracle.c +++ b/src/oracle.c @@ -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); } diff --git a/src/python.c b/src/python.c index ee673883..4a828b44 100644 --- a/src/python.c +++ b/src/python.c @@ -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; }