Merge remote-tracking branch 'amarx/collectd4' into next

This commit is contained in:
Michael Tremer
2015-02-02 23:56:18 +01:00
23 changed files with 1196 additions and 2 deletions

View File

@@ -25,7 +25,7 @@
include Config
PKG_NAME = collectd
VER = 4.10.7
VER = 4.10.9
THISAPP = collectd-$(VER)
DL_FILE = $(THISAPP).tar.bz2
@@ -46,7 +46,7 @@ objects = $(DL_FILE)
$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
$(DL_FILE)_MD5 = f4193fdb5002ddac8159c88032a726bc
$(DL_FILE)_MD5 = 980dd3387508f9ad209df04a6f7a126c
install : $(TARGET)
@@ -79,6 +79,28 @@ $(subst %,%_MD5,$(objects)) :
$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
@$(PREBUILD)
@rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE)
cd $(DIR_APP) && patch -p1 -i $(DIR_SRC)/src/patches/collectd/0001-src-utils_mount.h-Add-stdio.h.patch
cd $(DIR_APP) && patch -p1 -i $(DIR_SRC)/src/patches/collectd/0002-Don-t-notify-continuously-when-MySQL-slave-SQL-threa.patch
cd $(DIR_APP) && patch -p1 -i $(DIR_SRC)/src/patches/collectd/0003-curl_xml.c-avoid-using-uninitalized-variable-in-erro.patch
cd $(DIR_APP) && patch -p1 -i $(DIR_SRC)/src/patches/collectd/0004-interface.c-FreeBSD-10-support.patch
cd $(DIR_APP) && patch -p1 -i $(DIR_SRC)/src/patches/collectd/0005-Revert-curl_xml.c-avoid-using-uninitalized-variable-.patch
cd $(DIR_APP) && patch -p1 -i $(DIR_SRC)/src/patches/collectd/0006-network-set_thread_cbs-so-we-initialize-the-right-th.patch
cd $(DIR_APP) && patch -p1 -i $(DIR_SRC)/src/patches/collectd/0007-apache-plugin-Call-curl_global_init-from-the-init-fu.patch
cd $(DIR_APP) && patch -p1 -i $(DIR_SRC)/src/patches/collectd/0008-network-comment-libgcrypt-initalization-process.patch
cd $(DIR_APP) && patch -p1 -i $(DIR_SRC)/src/patches/collectd/0009-Call-curl_global_init-in-_init-of-plugins-using-curl.patch
cd $(DIR_APP) && patch -p1 -i $(DIR_SRC)/src/patches/collectd/0010-indent-wh_init-to-be-consistent-with-the-rest-of-the.patch
cd $(DIR_APP) && patch -p1 -i $(DIR_SRC)/src/patches/collectd/0011-Configparser-when-we-alocate-an-empty-list-we-also-n.patch
cd $(DIR_APP) && patch -p1 -i $(DIR_SRC)/src/patches/collectd/0012-don-t-assume-pkg-config-is-in-PATH.patch
cd $(DIR_APP) && patch -p1 -i $(DIR_SRC)/src/patches/collectd/0013-add-missing-backticks-which-broke-the-build.patch
cd $(DIR_APP) && patch -p1 -i $(DIR_SRC)/src/patches/collectd/0014-snmp-free-snmp_pdu-struct-allocated-by-snmp_pdu_crea.patch
cd $(DIR_APP) && patch -p1 -i $(DIR_SRC)/src/patches/collectd/0015-curl_xml-plugin-Fixed-tautological-pointer-compariso.patch
cd $(DIR_APP) && patch -p1 -i $(DIR_SRC)/src/patches/collectd/0016-Add-support-for-OpenVPN-2.3.0-status-files.patch
cd $(DIR_APP) && patch -p1 -i $(DIR_SRC)/src/patches/collectd/0017-openvpn-plugin-Don-t-signal-an-error-when-no-clients.patch
cd $(DIR_APP) && patch -p1 -i $(DIR_SRC)/src/patches/collectd/0018-openvpn-Remove-boguous-file-handler-check.patch
cd $(DIR_APP) && patch -p1 -i $(DIR_SRC)/src/patches/collectd/0019-openvpn-Ignore-not-fully-established-connections.patch
cd $(DIR_APP) && patch -p1 -i $(DIR_SRC)/src/patches/collectd/0020-openvpn-Make-read-functions-robust-like-in-8516f9abb.patch
cd $(DIR_APP) && patch -p1 -i $(DIR_SRC)/src/patches/collectd/0021-openvpn-Fix-copy-and-paste-error.patch
cd $(DIR_APP) && patch -p1 -i $(DIR_SRC)/src/patches/collectd/0022-openvpn-Change-data-type-from-COUNTER-to-DERIVE.patch
cd $(DIR_APP) && ./configure --prefix=/usr --localstatedir=/var \
--disable-{apple_sensors,csv,ipvs,mbmon,memcached,mysql} \
--disable-{netlink,nginx,nut,perl,serial,snmp,tape,vserver,xmms} \

View File

@@ -0,0 +1,28 @@
From 4bbfb2b9f391f273744163cfda7bec96671e9d9c Mon Sep 17 00:00:00 2001
From: Florian Forster <octo@collectd.org>
Date: Thu, 18 Apr 2013 06:25:58 +0200
Subject: [PATCH 01/22] src/utils_mount.h: Add <stdio.h>.
This is required on Solaris 10. Thanks to dannypoo@ for reporting this
problem.
Github: #306
---
src/utils_mount.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/utils_mount.h b/src/utils_mount.h
index 1f2403c..83f789b 100644
--- a/src/utils_mount.h
+++ b/src/utils_mount.h
@@ -26,6 +26,7 @@
#ifndef COLLECTD_UTILS_MOUNT_H
#define COLLECTD_UTILS_MOUNT_H 1
+#include <stdio.h>
#if HAVE_FS_INFO_H
# include <fs_info.h>
#endif
--
1.9.3

View File

@@ -0,0 +1,27 @@
From f2391b9da6127e4acd5b54b7ae6c2d585df0e2a0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Joaqu=C3=ADn=20Cuenca=20Abela?= <e98cuenc@gmail.com>
Date: Wed, 29 May 2013 16:22:09 +0200
Subject: [PATCH 02/22] Don't notify continuously when MySQL slave SQL thread
is running
Signed-off-by: Florian Forster <octo@collectd.org>
---
src/mysql.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/mysql.c b/src/mysql.c
index 8b3cd21..f93a442 100644
--- a/src/mysql.c
+++ b/src/mysql.c
@@ -689,7 +689,7 @@ static int mysql_read_slave_stats (mysql_database_t *db, MYSQL *con)
ssnprintf (n.message, sizeof (n.message),
"slave SQL thread started");
plugin_dispatch_notification (&n);
- db->slave_sql_running = 0;
+ db->slave_sql_running = 1;
}
}
--
1.9.3

View File

@@ -0,0 +1,34 @@
From bbbf37d55a3959951604c4be482e9a705a0f86d9 Mon Sep 17 00:00:00 2001
From: Marc Fournier <marc.fournier@camptocamp.com>
Date: Tue, 7 Jan 2014 11:30:59 +0100
Subject: [PATCH 03/22] curl_xml.c: avoid using uninitalized variable in error
message
Thanks to @trtrmitya for reporting this. Fixes GH#507
---
src/curl_xml.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/curl_xml.c b/src/curl_xml.c
index 75f5cc3..77aee60 100644
--- a/src/curl_xml.c
+++ b/src/curl_xml.c
@@ -551,12 +551,12 @@ static int cx_curl_perform (cx_t *db, CURL *curl) /* {{{ */
char *ptr;
char *url;
- db->buffer_fill = 0;
+ db->buffer_fill = 0;
status = curl_easy_perform (curl);
if (status != CURLE_OK)
{
- ERROR ("curl_xml plugin: curl_easy_perform failed with status %i: %s (%s)",
- status, db->curl_errbuf, url);
+ ERROR ("curl_xml plugin: curl_easy_perform failed with status %i: %s",
+ status, db->curl_errbuf);
return (-1);
}
--
1.9.3

View File

@@ -0,0 +1,52 @@
From 645dadb3fcc466e8880fda4eb23b21ad433631fc Mon Sep 17 00:00:00 2001
From: Marc Fournier <marc.fournier@camptocamp.com>
Date: Tue, 7 Jan 2014 16:06:10 +0100
Subject: [PATCH 04/22] interface.c: FreeBSD-10 support
Quoting @trtrmitya in github issue #506 : "[...] it is broken on
FreeBSD-10, in which getifaddrs() returns not only link level stats for
a particular interface, but also entries for each IP configured on that
interface. As a result if_submit() is called several times for each
interface, which results in incorrect data being logged.
I am attaching a patch which fixes a problem on FreeBSD (9/10), but it
should work for every *BSD because [...] the getifaddrs implementation
first appeared in BSDi BSD/OS."
Many thanks to @trtrmitya for providing the patch !
---
src/interface.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/interface.c b/src/interface.c
index db998a3..9b566ea 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -213,18 +213,19 @@ static int interface_read (void)
for (if_ptr = if_list; if_ptr != NULL; if_ptr = if_ptr->ifa_next)
{
- if ((if_data = (struct IFA_DATA *) if_ptr->ifa_data) == NULL)
- continue;
+ if (if_ptr->ifa_addr != NULL && if_ptr->ifa_addr->sa_family == AF_LINK) {
+ if_data = (struct IFA_DATA *) if_ptr->ifa_data;
- if_submit (if_ptr->ifa_name, "if_octets",
+ if_submit (if_ptr->ifa_name, "if_octets",
if_data->IFA_RX_BYTES,
if_data->IFA_TX_BYTES);
- if_submit (if_ptr->ifa_name, "if_packets",
+ if_submit (if_ptr->ifa_name, "if_packets",
if_data->IFA_RX_PACKT,
if_data->IFA_TX_PACKT);
- if_submit (if_ptr->ifa_name, "if_errors",
+ if_submit (if_ptr->ifa_name, "if_errors",
if_data->IFA_RX_ERROR,
if_data->IFA_TX_ERROR);
+ }
}
freeifaddrs (if_list);
--
1.9.3

View File

@@ -0,0 +1,40 @@
From cde09b547abbeb7595d91259fcc628504d0f55a9 Mon Sep 17 00:00:00 2001
From: Marc Fournier <marc.fournier@camptocamp.com>
Date: Wed, 8 Jan 2014 18:05:40 +0100
Subject: [PATCH 05/22] Revert "curl_xml.c: avoid using uninitalized variable
in error message"
This reverts commit bbbf37d55a3959951604c4be482e9a705a0f86d9.
A different fix for this problem was commited to the collectd-5.4 branch
(8327ee64) and conflicts with this patch. Also, initializing url the
same way as 8327ee64 does it, to avoid a merge conflict.
---
src/curl_xml.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/curl_xml.c b/src/curl_xml.c
index 77aee60..b941f02 100644
--- a/src/curl_xml.c
+++ b/src/curl_xml.c
@@ -550,13 +550,14 @@ static int cx_curl_perform (cx_t *db, CURL *curl) /* {{{ */
long rc;
char *ptr;
char *url;
+ url = db->url;
- db->buffer_fill = 0;
+ db->buffer_fill = 0;
status = curl_easy_perform (curl);
if (status != CURLE_OK)
{
- ERROR ("curl_xml plugin: curl_easy_perform failed with status %i: %s",
- status, db->curl_errbuf);
+ ERROR ("curl_xml plugin: curl_easy_perform failed with status %i: %s (%s)",
+ status, db->curl_errbuf, url);
return (-1);
}
--
1.9.3

View File

@@ -0,0 +1,28 @@
From ddffda7a150cd3abdb6ec392b514a250e91e0c19 Mon Sep 17 00:00:00 2001
From: Chris Lundquist <chris.lundquist@github.com>
Date: Tue, 14 Jan 2014 18:33:13 -0800
Subject: [PATCH 06/22] [network] set_thread_cbs so we initialize the right
threading mode in gcry_check_version
Signed-off-by: Florian Forster <octo@collectd.org>
---
src/network.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/network.c b/src/network.c
index d0ff6bc..be82c6f 100644
--- a/src/network.c
+++ b/src/network.c
@@ -500,8 +500,8 @@ static void network_init_gcrypt (void) /* {{{ */
if (gcry_control (GCRYCTL_ANY_INITIALIZATION_P))
return;
- gcry_check_version (NULL); /* before calling any other functions */
gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
+ gcry_check_version (NULL); /* before calling *almost* any other functions */
gcry_control (GCRYCTL_INIT_SECMEM, 32768);
gcry_control (GCRYCTL_INITIALIZATION_FINISHED);
} /* }}} void network_init_gcrypt */
--
1.9.3

View File

@@ -0,0 +1,40 @@
From 5f2f969335757f31f42cd8bb7e38eb8c5fe5e56e Mon Sep 17 00:00:00 2001
From: Florian Forster <octo@collectd.org>
Date: Wed, 15 Jan 2014 23:47:33 +0100
Subject: [PATCH 07/22] apache plugin: Call curl_global_init() from the init
function.
This is a shot in the dark in trying to address #513. By calling this
from an init() callback, I hope to be initializing the curl and gcrypt
libraries before collectd becomes multi-threaded, avoiding the problems
described in the issue.
---
src/apache.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/apache.c b/src/apache.c
index 899c21e..23bba3e 100644
--- a/src/apache.c
+++ b/src/apache.c
@@ -702,9 +702,18 @@ static int apache_read_host (user_data_t *user_data) /* {{{ */
return (0);
} /* }}} int apache_read_host */
+static int apache_init (void) /* {{{ */
+{
+ /* Call this while collectd is still single-threaded to avoid
+ * initialization issues in libgcrypt. */
+ curl_global_init (CURL_GLOBAL_SSL);
+ return (0);
+} /* }}} int apache_init */
+
void module_register (void)
{
plugin_register_complex_config ("apache", config);
+ plugin_register_init ("apache", apache_init);
} /* void module_register */
/* vim: set sw=8 noet fdm=marker : */
--
1.9.3

View File

@@ -0,0 +1,33 @@
From 793c2046de1ac04689d541a5e83513fe8e62578c Mon Sep 17 00:00:00 2001
From: Marc Fournier <marc.fournier@camptocamp.com>
Date: Thu, 16 Jan 2014 00:30:42 +0100
Subject: [PATCH 08/22] network: comment libgcrypt initalization process
---
src/network.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/network.c b/src/network.c
index be82c6f..f379a5c 100644
--- a/src/network.c
+++ b/src/network.c
@@ -500,8 +500,15 @@ static void network_init_gcrypt (void) /* {{{ */
if (gcry_control (GCRYCTL_ANY_INITIALIZATION_P))
return;
+ /* http://www.gnupg.org/documentation/manuals/gcrypt/Multi_002dThreading.html
+ * To ensure thread-safety, it's important to set GCRYCTL_SET_THREAD_CBS
+ * *before* initalizing Libgcrypt with gcry_check_version(), which itself must
+ * be called before any other gcry_* function. GCRYCTL_ANY_INITIALIZATION_P
+ * above doesn't count, as it doesn't implicitly initalize Libgcrypt.
+ *
+ * tl;dr: keep all these gry_* statements in this exact order please. */
gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
- gcry_check_version (NULL); /* before calling *almost* any other functions */
+ gcry_check_version (NULL);
gcry_control (GCRYCTL_INIT_SECMEM, 32768);
gcry_control (GCRYCTL_INITIALIZATION_FINISHED);
} /* }}} void network_init_gcrypt */
--
1.9.3

View File

@@ -0,0 +1,99 @@
From 66b400ab01b8133e450bb002e175117a1ab6f9ae Mon Sep 17 00:00:00 2001
From: Jeremy Katz <jeremy@katzbox.net>
Date: Sun, 26 Jan 2014 20:43:19 -0500
Subject: [PATCH 09/22] Call curl_global_init() in _init of plugins using curl
Need to call curl_global_init() or curl_easy_init() during init
for plugins when we're still running single threaded. This
updates the remaining ones
---
src/curl.c | 1 +
src/curl_json.c | 9 +++++++++
src/curl_xml.c | 9 +++++++++
src/write_http.c | 9 +++++++++
4 files changed, 28 insertions(+)
diff --git a/src/curl.c b/src/curl.c
index 3899aaa..8d2893f 100644
--- a/src/curl.c
+++ b/src/curl.c
@@ -566,6 +566,7 @@ static int cc_init (void) /* {{{ */
INFO ("curl plugin: No pages have been defined.");
return (-1);
}
+ curl_global_init (CURL_GLOBAL_SSL);
return (0);
} /* }}} int cc_init */
diff --git a/src/curl_json.c b/src/curl_json.c
index 24e1df1..0948962 100644
--- a/src/curl_json.c
+++ b/src/curl_json.c
@@ -882,9 +882,18 @@ static int cj_read (user_data_t *ud) /* {{{ */
return cj_curl_perform (db, db->curl);
} /* }}} int cj_read */
+static int cj_init (void) /* {{{ */
+{
+ /* Call this while collectd is still single-threaded to avoid
+ * initialization issues in libgcrypt. */
+ curl_global_init (CURL_GLOBAL_SSL);
+ return (0);
+} /* }}} int cj_init */
+
void module_register (void)
{
plugin_register_complex_config ("curl_json", cj_config);
+ plugin_register_init ("curl_json", cj_init);
} /* void module_register */
/* vim: set sw=2 sts=2 et fdm=marker : */
diff --git a/src/curl_xml.c b/src/curl_xml.c
index b941f02..e31e73d 100644
--- a/src/curl_xml.c
+++ b/src/curl_xml.c
@@ -926,9 +926,18 @@ static int cx_config (oconfig_item_t *ci) /* {{{ */
return (0);
} /* }}} int cx_config */
+static int cx_init (void) /* {{{ */
+{
+ /* Call this while collectd is still single-threaded to avoid
+ * initialization issues in libgcrypt. */
+ curl_global_init (CURL_GLOBAL_SSL);
+ return (0);
+} /* }}} int cx_init */
+
void module_register (void)
{
plugin_register_complex_config ("curl_xml", cx_config);
+ plugin_register_init ("curl_xml", cx_init);
} /* void module_register */
/* vim: set sw=2 sts=2 et fdm=marker : */
diff --git a/src/write_http.c b/src/write_http.c
index 62c73b0..04c637b 100644
--- a/src/write_http.c
+++ b/src/write_http.c
@@ -656,9 +656,18 @@ static int wh_config (oconfig_item_t *ci) /* {{{ */
return (0);
} /* }}} int wh_config */
+static int wh_init (void) /* {{{ */
+{
+ /* Call this while collectd is still single-threaded to avoid
+ * initialization issues in libgcrypt. */
+ curl_global_init (CURL_GLOBAL_SSL);
+ return (0);
+} /* }}} int wh_init */
+
void module_register (void) /* {{{ */
{
plugin_register_complex_config ("write_http", wh_config);
+ plugin_register_init ("write_http", wh_init);
} /* }}} void module_register */
/* vim: set fdm=marker sw=8 ts=8 tw=78 et : */
--
1.9.3

View File

@@ -0,0 +1,32 @@
From 6bd48f2346c5072dc22da58c7b7cd8e8ceb83fc5 Mon Sep 17 00:00:00 2001
From: Marc Fournier <marc.fournier@camptocamp.com>
Date: Sat, 29 Mar 2014 13:37:36 +0100
Subject: [PATCH 10/22] indent wh_init() to be consistent with the rest of the
file
---
src/write_http.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/write_http.c b/src/write_http.c
index 04c637b..0a13444 100644
--- a/src/write_http.c
+++ b/src/write_http.c
@@ -658,10 +658,10 @@ static int wh_config (oconfig_item_t *ci) /* {{{ */
static int wh_init (void) /* {{{ */
{
- /* Call this while collectd is still single-threaded to avoid
- * initialization issues in libgcrypt. */
- curl_global_init (CURL_GLOBAL_SSL);
- return (0);
+ /* Call this while collectd is still single-threaded to avoid
+ * initialization issues in libgcrypt. */
+ curl_global_init (CURL_GLOBAL_SSL);
+ return (0);
} /* }}} int wh_init */
void module_register (void) /* {{{ */
--
1.9.3

View File

@@ -0,0 +1,41 @@
From 6207fce91a0933e852ec76fc31ca81ec00ffa04b Mon Sep 17 00:00:00 2001
From: Wilfried Goesgens <dothebart@citadel.org>
Date: Thu, 5 Jun 2014 20:04:13 +0200
Subject: [PATCH 11/22] Configparser: when we alocate an empty list, we also
need to reset the counter; else we will trip over this later. This fixes
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=750440
---
src/configfile.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/configfile.c b/src/configfile.c
index 0b7786f..983d995 100644
--- a/src/configfile.c
+++ b/src/configfile.c
@@ -414,6 +414,12 @@ static int cf_ci_replace_child (oconfig_item_t *dst, oconfig_item_t *src,
/* Resize the memory containing the children to be big enough to hold
* all children. */
+ if (dst->children_num + src->children_num - 1 == 0)
+ {
+ dst->children_num = 0;
+ return (0);
+ }
+
temp = (oconfig_item_t *) realloc (dst->children,
sizeof (oconfig_item_t)
* (dst->children_num + src->children_num - 1));
@@ -514,7 +520,8 @@ static int cf_include_all (oconfig_item_t *root, int depth)
continue;
/* Now replace the i'th child in `root' with `new'. */
- cf_ci_replace_child (root, new, i);
+ if (cf_ci_replace_child (root, new, i) < 0)
+ return (-1);
/* ... and go back to the new i'th child. */
--i;
--
1.9.3

View File

@@ -0,0 +1,86 @@
From c2ca2a46e617878dcff69de0b8940ea91d3401cc Mon Sep 17 00:00:00 2001
From: Lauri Tirkkonen <lotheac@iki.fi>
Date: Thu, 22 May 2014 14:05:40 +0300
Subject: [PATCH 12/22] don't assume pkg-config is in PATH
---
configure.in | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/configure.in b/configure.in
index 0b12630..7086800 100644
--- a/configure.in
+++ b/configure.in
@@ -1136,8 +1136,8 @@ AC_CHECK_LIB(hal,libhal_device_property_exists,
[with_libhal="no"])
if test "x$with_libhal" = "xyes"; then
if test "x$PKG_CONFIG" != "x"; then
- BUILD_WITH_LIBHAL_CFLAGS="`pkg-config --cflags hal`"
- BUILD_WITH_LIBHAL_LIBS="`pkg-config --libs hal`"
+ BUILD_WITH_LIBHAL_CFLAGS="`$PKG_CONFIG --cflags hal`"
+ BUILD_WITH_LIBHAL_LIBS="`$PKG_CONFIG --libs hal`"
AC_SUBST(BUILD_WITH_LIBHAL_CFLAGS)
AC_SUBST(BUILD_WITH_LIBHAL_LIBS)
fi
@@ -3434,8 +3434,8 @@ then
if $PKG_CONFIG --exists tokyotyrant
then
with_libtokyotyrant_cppflags="$with_libtokyotyrant_cppflags `$PKG_CONFIG --cflags tokyotyrant`"
- with_libtokyotyrant_ldflags="$with_libtokyotyrant_ldflags `pkg-config --libs-only-L tokyotyrant`"
- with_libtokyotyrant_libs="$with_libtokyotyrant_libs `pkg-config --libs-only-l tokyotyrant`"
+ with_libtokyotyrant_ldflags="$with_libtokyotyrant_ldflags `$PKG_CONFIG --libs-only-L tokyotyrant`"
+ with_libtokyotyrant_libs="$with_libtokyotyrant_libs `$PKG_CONFIG --libs-only-l tokyotyrant`"
fi
fi
@@ -3743,7 +3743,7 @@ with_libvirt_cflags=""
with_libvirt_ldflags=""
if test "x$PKG_CONFIG" != "x"
then
- pkg-config --exists 'libxml-2.0' 2>/dev/null
+ $PKG_CONFIG --exists 'libxml-2.0' 2>/dev/null
if test "$?" = "0"
then
with_libxml2="yes"
@@ -3751,7 +3751,7 @@ then
with_libxml2="no (pkg-config doesn't know library)"
fi
- pkg-config --exists libvirt 2>/dev/null
+ $PKG_CONFIG --exists libvirt 2>/dev/null
if test "$?" = "0"
then
with_libvirt="yes"
@@ -3761,12 +3761,12 @@ then
fi
if test "x$with_libxml2" = "xyes"
then
- with_libxml2_cflags="`pkg-config --cflags libxml-2.0`"
+ with_libxml2_cflags="`$PKG_CONFIG --cflags libxml-2.0`"
if test $? -ne 0
then
with_libxml2="no"
fi
- with_libxml2_ldflags="`pkg-config --libs libxml-2.0`"
+ with_libxml2_ldflags="$PKG_CONFIG --libs libxml-2.0`"
if test $? -ne 0
then
with_libxml2="no"
@@ -3806,12 +3806,12 @@ if test "x$with_libxml2" = "xyes"; then
fi
if test "x$with_libvirt" = "xyes"
then
- with_libvirt_cflags="`pkg-config --cflags libvirt`"
+ with_libvirt_cflags="$PKG_CONFIG --cflags libvirt`"
if test $? -ne 0
then
with_libvirt="no"
fi
- with_libvirt_ldflags="`pkg-config --libs libvirt`"
+ with_libvirt_ldflags="$PKG_CONFIG --libs libvirt`"
if test $? -ne 0
then
with_libvirt="no"
--
1.9.3

View File

@@ -0,0 +1,40 @@
From 497f5785e8b385f03b5fb5b15bdff8ba39e4699e Mon Sep 17 00:00:00 2001
From: Marc Fournier <marc.fournier@camptocamp.com>
Date: Mon, 23 Jun 2014 18:00:01 +0200
Subject: [PATCH 13/22] add missing backticks which broke the build
---
configure.in | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/configure.in b/configure.in
index 7086800..5dac543 100644
--- a/configure.in
+++ b/configure.in
@@ -3766,7 +3766,7 @@ then
then
with_libxml2="no"
fi
- with_libxml2_ldflags="$PKG_CONFIG --libs libxml-2.0`"
+ with_libxml2_ldflags="`$PKG_CONFIG --libs libxml-2.0`"
if test $? -ne 0
then
with_libxml2="no"
@@ -3806,12 +3806,12 @@ if test "x$with_libxml2" = "xyes"; then
fi
if test "x$with_libvirt" = "xyes"
then
- with_libvirt_cflags="$PKG_CONFIG --cflags libvirt`"
+ with_libvirt_cflags="`$PKG_CONFIG --cflags libvirt`"
if test $? -ne 0
then
with_libvirt="no"
fi
- with_libvirt_ldflags="$PKG_CONFIG --libs libvirt`"
+ with_libvirt_ldflags="`$PKG_CONFIG --libs libvirt`"
if test $? -ne 0
then
with_libvirt="no"
--
1.9.3

View File

@@ -0,0 +1,29 @@
From 0da910fb1bf2bd4982ca6541458c795ec296f398 Mon Sep 17 00:00:00 2001
From: Marc Fournier <marc.fournier@camptocamp.com>
Date: Fri, 8 Aug 2014 15:55:10 +0200
Subject: [PATCH 14/22] snmp: free snmp_pdu struct allocated by
snmp_pdu_create()
This should fix the leak reported in issue #610.
---
src/snmp.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/snmp.c b/src/snmp.c
index d440f7f..dacdede 100644
--- a/src/snmp.c
+++ b/src/snmp.c
@@ -1503,6 +1503,10 @@ static int csnmp_read_table (host_definition_t *host, data_definition_t *data)
snmp_free_pdu (res);
res = NULL;
+ if (req != NULL)
+ snmp_free_pdu (req);
+ req = NULL;
+
if (status == 0)
csnmp_dispatch_table (host, data, instance_list_head, value_list_head);
--
1.9.3

View File

@@ -0,0 +1,28 @@
From 0afea60611f115a28b8ec331aba610e3038c1ef2 Mon Sep 17 00:00:00 2001
From: Arthur Marble <arthur@info9.net>
Date: Sun, 17 Aug 2014 17:34:04 -0500
Subject: [PATCH 15/22] curl_xml plugin: Fixed tautological pointer comparison
error.
Fixes: http://bugs.debian.org/758481
Signed-off-by: Florian Forster <octo@collectd.org>
---
src/curl_xml.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/curl_xml.c b/src/curl_xml.c
index e31e73d..28b2ded 100644
--- a/src/curl_xml.c
+++ b/src/curl_xml.c
@@ -344,7 +344,7 @@ static int cx_handle_instance_xpath (xmlXPathContextPtr xpath_ctx, /* {{{ */
/* If the base xpath returns more than one block, the result is assumed to be
* a table. The `Instnce' option is not optional in this case. Check for the
* condition and inform the user. */
- if (is_table && (vl->type_instance == NULL))
+ if (is_table)
{
WARNING ("curl_xml plugin: "
"Base-XPath %s is a table (more than one result was returned), "
--
1.9.3

View File

@@ -0,0 +1,160 @@
From 9d065b401c2c393bef5a6e58b5deeda7d59d4f39 Mon Sep 17 00:00:00 2001
From: Ed Okerson <ed@okerson.com>
Date: Mon, 11 Feb 2013 15:46:10 -0600
Subject: [PATCH 16/22] Add support for OpenVPN 2.3.0 status files.
Fix a bug that breaks this module if a server is running multiple instances of OpenVPN and one instance does not have any clients connected.
---
src/openvpn.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 84 insertions(+), 6 deletions(-)
diff --git a/src/openvpn.c b/src/openvpn.c
index 2aca414..d2b6f17 100644
--- a/src/openvpn.c
+++ b/src/openvpn.c
@@ -32,6 +32,7 @@
#define V1STRING "Common Name,Real Address,Bytes Received,Bytes Sent,Connected Since\n"
#define V2STRING "HEADER,CLIENT_LIST,Common Name,Real Address,Virtual Address,Bytes Received,Bytes Sent,Connected Since,Connected Since (time_t)\n"
#define V3STRING "HEADER CLIENT_LIST Common Name Real Address Virtual Address Bytes Received Bytes Sent Connected Since Connected Since (time_t)\n"
+#define V4STRING "HEADER,CLIENT_LIST,Common Name,Real Address,Virtual Address,Bytes Received,Bytes Sent,Connected Since,Connected Since (time_t),Username\n"
#define VSSTRING "OpenVPN STATISTICS\n"
@@ -43,6 +44,7 @@ struct vpn_status_s
MULTI1 = 1, /* status-version 1 */
MULTI2, /* status-version 2 */
MULTI3, /* status-version 3 */
+ MULTI4, /* status-version 4 */
SINGLE = 10 /* currently no versions for single mode, maybe in the future */
} version;
char *name;
@@ -452,13 +454,77 @@ static int multi3_read (char *name, FILE *fh)
return (read);
} /* int multi3_read */
+/* for reading status version 4 */
+static int multi4_read (char *name, FILE *fh)
+{
+ char buffer[1024];
+ char *fields[11];
+ const int max_fields = STATIC_ARRAY_SIZE (fields);
+ int fields_num, read = 0;
+ long long sum_users = 0;
+
+ while (fgets (buffer, sizeof (buffer), fh) != NULL)
+ {
+ fields_num = openvpn_strsplit (buffer, fields, max_fields);
+
+ /* status file is generated by openvpn/multi.c:multi_print_status()
+ * http://svn.openvpn.net/projects/openvpn/trunk/openvpn/multi.c
+ *
+ * The line we're expecting has 9 fields. We ignore all lines
+ * with more or less fields.
+ */
+ if (fields_num != 9)
+ continue;
+
+
+ if (strcmp (fields[0], "CLIENT_LIST") != 0)
+ continue;
+
+
+ if (collect_user_count)
+ /* If so, sum all users, ignore the individuals*/
+ {
+ sum_users += 1;
+ }
+ if (collect_individual_users)
+ {
+ if (new_naming_schema)
+ {
+ /* plugin inst = file name, type inst = fields[1] */
+ iostats_submit (name, /* vpn instance */
+ fields[1], /* "Common Name" */
+ atoll (fields[4]), /* "Bytes Received" */
+ atoll (fields[5])); /* "Bytes Sent" */
+ }
+ else
+ {
+ /* plugin inst = fields[1], type inst = "" */
+ iostats_submit (fields[1], /* "Common Name" */
+ NULL, /* unused when in multimode */
+ atoll (fields[4]), /* "Bytes Received" */
+ atoll (fields[5])); /* "Bytes Sent" */
+ }
+ }
+
+ read = 1;
+ }
+
+ if (collect_user_count)
+ {
+ numusers_submit(name, name, sum_users);
+ read = 1;
+ }
+
+ return (read);
+} /* int multi4_read */
+
/* read callback */
static int openvpn_read (void)
{
FILE *fh;
- int i, read;
+ int i, vpn_read, read;
- read = 0;
+ vpn_read = read = 0;
/* call the right read function for every status entry in the list */
for (i = 0; i < vpn_num; i++)
@@ -476,23 +542,28 @@ static int openvpn_read (void)
switch (vpn_list[i]->version)
{
case SINGLE:
- read = single_read(vpn_list[i]->name, fh);
+ vpn_read = single_read(vpn_list[i]->name, fh);
break;
case MULTI1:
- read = multi1_read(vpn_list[i]->name, fh);
+ vpn_read = multi1_read(vpn_list[i]->name, fh);
break;
case MULTI2:
- read = multi2_read(vpn_list[i]->name, fh);
+ vpn_read = multi2_read(vpn_list[i]->name, fh);
break;
case MULTI3:
- read = multi3_read(vpn_list[i]->name, fh);
+ vpn_read = multi3_read(vpn_list[i]->name, fh);
+ break;
+
+ case MULTI4:
+ vpn_read = multi4_read(vpn_list[i]->name, fh);
break;
}
fclose (fh);
+ read += vpn_read;
}
return (read ? 0 : -1);
@@ -549,6 +620,13 @@ static int version_detect (const char *filename)
version = MULTI3;
break;
}
+ /* searching for multi version 4 */
+ else if (strcmp (buffer, V4STRING) == 0)
+ {
+ DEBUG ("openvpn plugin: found status file version MULTI4");
+ version = MULTI4;
+ break;
+ }
}
if (version == 0)
--
1.9.3

View File

@@ -0,0 +1,56 @@
From 8516f9abb625fa7b9321e62307305aa6499be4e8 Mon Sep 17 00:00:00 2001
From: Florian Forster <octo@collectd.org>
Date: Sun, 14 Sep 2014 19:28:05 +0200
Subject: [PATCH 17/22] openvpn plugin: Don't signal an error when no clients
are connected.
In the multi1_read() function, an error (zero) was returned when no
clients were currently connected to the OpenVPN server, because the
"read" variable was initialized to zero and the while loop exited before
it was set to one. This is not the intended behavior.
Thanks to @srix for reporting this issue!
Fixes: #731
---
src/openvpn.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/src/openvpn.c b/src/openvpn.c
index d2b6f17..7d4e4a0 100644
--- a/src/openvpn.c
+++ b/src/openvpn.c
@@ -267,7 +267,7 @@ static int multi1_read (char *name, FILE *fh)
{
char buffer[1024];
char *fields[10];
- int fields_num, read = 0, found_header = 0;
+ int fields_num, found_header = 0;
long long sum_users = 0;
/* read the file until the "ROUTING TABLE" line is found (no more info after) */
@@ -314,17 +314,15 @@ static int multi1_read (char *name, FILE *fh)
atoll (fields[3])); /* "Bytes Sent" */
}
}
-
- read = 1;
}
+ if (ferror (fh))
+ return (0);
+
if (collect_user_count)
- {
numusers_submit(name, name, sum_users);
- read = 1;
- }
- return (read);
+ return (1);
} /* int multi1_read */
/* for reading status version 2 */
--
1.9.3

View File

@@ -0,0 +1,26 @@
From 5dbc1cfb4baff831f950b3c9de8c332bc9aa2b6e Mon Sep 17 00:00:00 2001
From: Michael Tremer <michael.tremer@ipfire.org>
Date: Wed, 17 Sep 2014 11:25:17 +0200
Subject: [PATCH 18/22] openvpn: Remove boguous file handler check
---
src/openvpn.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/src/openvpn.c b/src/openvpn.c
index 7d4e4a0..9598abc 100644
--- a/src/openvpn.c
+++ b/src/openvpn.c
@@ -316,9 +316,6 @@ static int multi1_read (char *name, FILE *fh)
}
}
- if (ferror (fh))
- return (0);
-
if (collect_user_count)
numusers_submit(name, name, sum_users);
--
1.9.3

View File

@@ -0,0 +1,59 @@
From a45710a5a887d25ab0e04ce1553bb268013ef780 Mon Sep 17 00:00:00 2001
From: Michael Tremer <michael.tremer@ipfire.org>
Date: Tue, 16 Sep 2014 14:44:42 +0200
Subject: [PATCH 19/22] openvpn: Ignore not fully established connections
---
src/openvpn.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/src/openvpn.c b/src/openvpn.c
index 9598abc..6a0ffbd 100644
--- a/src/openvpn.c
+++ b/src/openvpn.c
@@ -292,6 +292,10 @@ static int multi1_read (char *name, FILE *fh)
if (fields_num < 4)
continue;
+ // Ignore not yet fully established connections
+ if (strcmp(fields[1], "UNDEF") == 0)
+ continue;
+
if (collect_user_count)
/* If so, sum all users, ignore the individuals*/
{
@@ -347,6 +351,10 @@ static int multi2_read (char *name, FILE *fh)
if (strcmp (fields[0], "CLIENT_LIST") != 0)
continue;
+ // Ignore not yet fully established connections
+ if (strcmp(fields[0], "UNDEF") == 0)
+ continue;
+
if (collect_user_count)
/* If so, sum all users, ignore the individuals*/
{
@@ -412,6 +420,10 @@ static int multi3_read (char *name, FILE *fh)
if (strcmp (fields[0], "CLIENT_LIST") != 0)
continue;
+ // Ignore not yet fully established connections
+ if (strcmp(fields[0], "UNDEF") == 0)
+ continue;
+
if (collect_user_count)
/* If so, sum all users, ignore the individuals*/
{
@@ -475,6 +487,9 @@ static int multi4_read (char *name, FILE *fh)
if (strcmp (fields[0], "CLIENT_LIST") != 0)
continue;
+ // Ignore not yet fully established connections
+ if (strcmp(fields[0], "UNDEF") == 0)
+ continue;
if (collect_user_count)
/* If so, sum all users, ignore the individuals*/
--
1.9.3

View File

@@ -0,0 +1,102 @@
From 46e716ee8d4208924d10f57f9ed97c99674a6ef4 Mon Sep 17 00:00:00 2001
From: Michael Tremer <michael.tremer@ipfire.org>
Date: Wed, 17 Sep 2014 11:31:13 +0200
Subject: [PATCH 20/22] openvpn: Make read functions robust like in
8516f9abb625fa7b9321e62307305aa6499be4e8
---
src/openvpn.c | 21 ++++++---------------
1 file changed, 6 insertions(+), 15 deletions(-)
diff --git a/src/openvpn.c b/src/openvpn.c
index 6a0ffbd..f686721 100644
--- a/src/openvpn.c
+++ b/src/openvpn.c
@@ -332,7 +332,7 @@ static int multi2_read (char *name, FILE *fh)
char buffer[1024];
char *fields[10];
const int max_fields = STATIC_ARRAY_SIZE (fields);
- int fields_num, read = 0;
+ int fields_num;
long long sum_users = 0;
while (fgets (buffer, sizeof (buffer), fh) != NULL)
@@ -379,17 +379,14 @@ static int multi2_read (char *name, FILE *fh)
atoll (fields[5])); /* "Bytes Sent" */
}
}
-
- read = 1;
}
if (collect_user_count)
{
numusers_submit(name, name, sum_users);
- read = 1;
}
- return (read);
+ return (1);
} /* int multi2_read */
/* for reading status version 3 */
@@ -398,7 +395,7 @@ static int multi3_read (char *name, FILE *fh)
char buffer[1024];
char *fields[15];
const int max_fields = STATIC_ARRAY_SIZE (fields);
- int fields_num, read = 0;
+ int fields_num;
long long sum_users = 0;
while (fgets (buffer, sizeof (buffer), fh) != NULL)
@@ -447,18 +444,15 @@ static int multi3_read (char *name, FILE *fh)
atoll (fields[5])); /* "Bytes Sent" */
}
}
-
- read = 1;
}
}
if (collect_user_count)
{
numusers_submit(name, name, sum_users);
- read = 1;
}
- return (read);
+ return (1);
} /* int multi3_read */
/* for reading status version 4 */
@@ -467,7 +461,7 @@ static int multi4_read (char *name, FILE *fh)
char buffer[1024];
char *fields[11];
const int max_fields = STATIC_ARRAY_SIZE (fields);
- int fields_num, read = 0;
+ int fields_num;
long long sum_users = 0;
while (fgets (buffer, sizeof (buffer), fh) != NULL)
@@ -515,17 +509,14 @@ static int multi4_read (char *name, FILE *fh)
atoll (fields[5])); /* "Bytes Sent" */
}
}
-
- read = 1;
}
if (collect_user_count)
{
numusers_submit(name, name, sum_users);
- read = 1;
}
- return (read);
+ return (1);
} /* int multi4_read */
/* read callback */
--
1.9.3

View File

@@ -0,0 +1,25 @@
From 41253b68808deade2a1866f0c24f4bbc029a92c2 Mon Sep 17 00:00:00 2001
From: Michael Tremer <michael.tremer@ipfire.org>
Date: Wed, 24 Sep 2014 14:38:04 +0200
Subject: [PATCH 21/22] openvpn: Fix copy-and-paste error
---
src/openvpn.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/openvpn.c b/src/openvpn.c
index f686721..2db3677 100644
--- a/src/openvpn.c
+++ b/src/openvpn.c
@@ -293,7 +293,7 @@ static int multi1_read (char *name, FILE *fh)
continue;
// Ignore not yet fully established connections
- if (strcmp(fields[1], "UNDEF") == 0)
+ if (strcmp(fields[0], "UNDEF") == 0)
continue;
if (collect_user_count)
--
1.9.3

View File

@@ -0,0 +1,107 @@
From 3458d610e8b99eb88c2f06ad576b4f46e0169877 Mon Sep 17 00:00:00 2001
From: Michael Tremer <michael.tremer@ipfire.org>
Date: Fri, 26 Sep 2014 12:02:27 +0200
Subject: [PATCH 22/22] openvpn: Change data type from COUNTER to DERIVE
COUNTER is not what we want here, so we will use DERIVE.
---
src/openvpn.c | 26 +++++++++++++-------------
src/types.db | 2 ++
2 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/src/openvpn.c b/src/openvpn.c
index 2db3677..d446e99 100644
--- a/src/openvpn.c
+++ b/src/openvpn.c
@@ -116,13 +116,13 @@ static void numusers_submit (char *pinst, char *tinst, gauge_t value)
} /* void numusers_submit */
/* dispatches stats about traffic (TCP or UDP) generated by the tunnel per single endpoint */
-static void iostats_submit (char *pinst, char *tinst, counter_t rx, counter_t tx)
+static void iostats_submit (char *pinst, char *tinst, derive_t rx, derive_t tx)
{
value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
- values[0].counter = rx;
- values[1].counter = tx;
+ values[0].derive = rx;
+ values[1].derive = tx;
/* NOTE ON THE NEW NAMING SCHEMA:
* using plugin_instance to identify each vpn config (and
@@ -137,7 +137,7 @@ static void iostats_submit (char *pinst, char *tinst, counter_t rx, counter_t tx
if (pinst != NULL)
sstrncpy (vl.plugin_instance, pinst,
sizeof (vl.plugin_instance));
- sstrncpy (vl.type, "if_octets", sizeof (vl.type));
+ sstrncpy (vl.type, "if_octets_derive", sizeof (vl.type));
if (tinst != NULL)
sstrncpy (vl.type_instance, tinst, sizeof (vl.type_instance));
@@ -146,13 +146,13 @@ static void iostats_submit (char *pinst, char *tinst, counter_t rx, counter_t tx
/* dispatches stats about data compression shown when in single mode */
static void compression_submit (char *pinst, char *tinst,
- counter_t uncompressed, counter_t compressed)
+ derive_t uncompressed, derive_t compressed)
{
value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
- values[0].counter = uncompressed;
- values[1].counter = compressed;
+ values[0].derive = uncompressed;
+ values[1].derive = compressed;
vl.values = values;
vl.values_len = STATIC_ARRAY_SIZE (values);
@@ -161,7 +161,7 @@ static void compression_submit (char *pinst, char *tinst,
if (pinst != NULL)
sstrncpy (vl.plugin_instance, pinst,
sizeof (vl.plugin_instance));
- sstrncpy (vl.type, "compression", sizeof (vl.type));
+ sstrncpy (vl.type, "compression_dervice", sizeof (vl.type));
if (tinst != NULL)
sstrncpy (vl.type_instance, tinst, sizeof (vl.type_instance));
@@ -175,11 +175,11 @@ static int single_read (char *name, FILE *fh)
const int max_fields = STATIC_ARRAY_SIZE (fields);
int fields_num, read = 0;
- counter_t link_rx, link_tx;
- counter_t tun_rx, tun_tx;
- counter_t pre_compress, post_compress;
- counter_t pre_decompress, post_decompress;
- counter_t overhead_rx, overhead_tx;
+ derive_t link_rx, link_tx;
+ derive_t tun_rx, tun_tx;
+ derive_t pre_compress, post_compress;
+ derive_t pre_decompress, post_decompress;
+ derive_t overhead_rx, overhead_tx;
link_rx = 0;
link_tx = 0;
diff --git a/src/types.db b/src/types.db
index ad54240..03ec75b 100644
--- a/src/types.db
+++ b/src/types.db
@@ -18,6 +18,7 @@ cache_result value:COUNTER:0:4294967295
cache_size value:GAUGE:0:4294967295
charge value:GAUGE:0:U
compression uncompressed:COUNTER:0:U, compressed:COUNTER:0:U
+compression_derive uncompressed:DERIVE:0:U, compressed:DERIVE:0:U
compression_ratio value:GAUGE:0:2
connections value:COUNTER:0:U
conntrack entropy:GAUGE:0:4294967295
@@ -74,6 +75,7 @@ if_dropped rx:COUNTER:0:4294967295, tx:COUNTER:0:4294967295
if_errors rx:COUNTER:0:4294967295, tx:COUNTER:0:4294967295
if_multicast value:COUNTER:0:4294967295
if_octets rx:COUNTER:0:4294967295, tx:COUNTER:0:4294967295
+if_octets_derive rx:DERIVE:0:U, tx:DERIVE:0:U
if_packets rx:COUNTER:0:4294967295, tx:COUNTER:0:4294967295
if_rx_errors value:COUNTER:0:4294967295
if_tx_errors value:COUNTER:0:4294967295
--
1.9.3