author | Florian Forster <octo@collectd.org> | |
Sat, 28 Jan 2012 11:26:41 +0000 (12:26 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Sat, 28 Jan 2012 11:26:41 +0000 (12:26 +0100) |
README | patch | blob | history | |
configure.in | patch | blob | history | |
src/Makefile.am | patch | blob | history | |
src/collectd-python.pod | patch | blob | history | |
src/common.c | patch | blob | history | |
src/ipvs.c | patch | blob | history | |
src/oracle.c | patch | blob | history | |
src/python.c | patch | blob | history |
index 6badeecd5b4b837c9c19115923d2521780d14f96..ac79ce509429a68caf581ba57ddbecbc25e399a2 100644 (file)
--- a/README
+++ b/README
<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”)
diff --git a/configure.in b/configure.in
index f0a189c56c6d2868da46fa205bcf8f88b6c96a2f..8040193ba83670f8a0b774b5a3aebdd42261852c 100644 (file)
--- a/configure.in
+++ b/configure.in
])
# 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, [], [],
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
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 5728144055b3dc1b3d026360bf65400332ddcf89..259a3816e6eeb873ddf614f2c0cb65891a5a75c0 100644 (file)
--- a/src/Makefile.am
+++ b/src/Makefile.am
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 267296cfd6009a82904198f3b999b3dfe5aa3ab7..5fd1f4f934e58228f99796ce9f30876bf7f85a7e 100644 (file)
--- a/src/collectd-python.pod
+++ b/src/collectd-python.pod
<Plugin python>
ModulePath "/path/to/your/python/modules"
LogTraces true
- Interactive true
+ Interactive false
Import "spam"
<Module spam>
diff --git a/src/common.c b/src/common.c
index e1f204b9824ce05ca44a6a1861324bfcfe08747c..0069a8b6508691b4fd2270642d10452428606fc4 100644 (file)
--- a/src/common.c
+++ b/src/common.c
}
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 ab76f1eb8638d2517dd1e56ddb981148d17ed556..fa894897bae658b532e9af4f692d3bd802e6f4b6 100644 (file)
--- a/src/ipvs.c
+++ b/src/ipvs.c
#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>
diff --git a/src/oracle.c b/src/oracle.c
index ec45996bdebfdda8e8a27d54eb125b8544d0afc7..4415b489e6d55c0712840f1313b65be5af11072c 100644 (file)
--- a/src/oracle.c
+++ b/src/oracle.c
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],
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
{
(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;",
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 ee673883e49b120512d855aef6e4266a793967d6..4a828b44c6352c6a3be8c5757b2cc6ddebafb96f 100644 (file)
--- a/src/python.c
+++ b/src/python.c
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;
}
#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 */
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;
WARNING("python plugin: Ignoring unknown config key \"%s\".", item->key);
}
}
- Py_DECREF(sys_path);
return 0;
}