Merge pull request #446 from bugsduggan/feature/tail_plugin_interval_per_file
authorPierre-Yves Ritschard <pyr@spootnik.org>
Thu, 27 Mar 2014 15:49:08 +0000 (16:49 +0100)
committerPierre-Yves Ritschard <pyr@spootnik.org>
Thu, 27 Mar 2014 15:49:08 +0000 (16:49 +0100)
Allow Interval per File block for tail plugin

38 files changed:
README
configure.ac [new file with mode: 0644]
configure.in [deleted file]
contrib/collection.cgi
contrib/collection3/etc/collection.conf
contrib/redhat/collectd.spec
src/Makefile.am
src/aquaero.c
src/cgroups.c
src/collectd-snmp.pod
src/collectd.c
src/collectd.conf.in
src/collectd.conf.pod
src/common.c
src/common.h
src/conntrack.c
src/cpu.c
src/curl.c
src/curl_json.c
src/curl_xml.c
src/interface.c
src/load.c
src/memory.c
src/netlink.c
src/plugin.c
src/plugin.h
src/redis.c
src/snmp.c
src/swap.c
src/target_replace.c
src/target_set.c
src/types.db
src/utils_cache.c
src/utils_format_graphite.c
src/utils_mount.c
src/write_graphite.c
src/write_riemann.c
src/zfs_arc.c

diff --git a/README b/README
index c0d7036..fa88f38 100644 (file)
--- a/README
+++ b/README
@@ -565,7 +565,7 @@ Prerequisites
 
   * A POSIX-threads (pthread) implementation.
     Since gathering some statistics is slow (network connections, slow devices,
-    etc) the collectd is parallelized. The POSIX threads interface is being
+    etc) collectd is parallelized. The POSIX threads interface is being
     used and should be found in various implementations for hopefully all
     platforms.
 
diff --git a/configure.ac b/configure.ac
new file mode 100644 (file)
index 0000000..f1c7b8a
--- /dev/null
@@ -0,0 +1,5586 @@
+dnl Process this file with autoconf to produce a configure script.
+AC_INIT([collectd],[m4_esyscmd(./version-gen.sh)])
+AC_CONFIG_SRCDIR(src/collectd.c)
+AC_CONFIG_HEADERS(src/config.h)
+AC_CONFIG_AUX_DIR([libltdl/config])
+
+m4_ifdef([LT_PACKAGE_VERSION],
+       # libtool >= 2.2
+       [
+        LT_CONFIG_LTDL_DIR([libltdl])
+        LT_INIT([dlopen])
+        LTDL_INIT([convenience])
+        AC_DEFINE(LIBTOOL_VERSION, 2, [Define to used libtool version.])
+       ]
+,
+       # libtool <= 1.5
+       [
+        AC_LIBLTDL_CONVENIENCE
+        AC_SUBST(LTDLINCL)
+        AC_SUBST(LIBLTDL)
+        AC_LIBTOOL_DLOPEN
+        AC_CONFIG_SUBDIRS(libltdl)
+        AC_DEFINE(LIBTOOL_VERSION, 1, [Define to used libtool version.])
+       ]
+)
+
+AM_INIT_AUTOMAKE([tar-pax dist-bzip2 foreign])
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+AC_LANG(C)
+
+AC_PREFIX_DEFAULT("/opt/collectd")
+
+AC_SYS_LARGEFILE
+
+#
+# Checks for programs.
+#
+AC_PROG_CC
+AC_PROG_CPP
+AC_PROG_INSTALL
+AC_PROG_LN_S
+AC_PROG_MAKE_SET
+AM_PROG_CC_C_O
+AM_CONDITIONAL(COMPILER_IS_GCC, test "x$GCC" = "xyes")
+
+AC_DISABLE_STATIC
+AC_PROG_LIBTOOL
+AC_PROG_LEX
+AC_PROG_YACC
+PKG_PROG_PKG_CONFIG
+
+AC_CHECK_PROG([have_protoc_c], [protoc-c], [yes], [no])
+AC_CHECK_HEADERS([google/protobuf-c/protobuf-c.h],
+                 [have_protobuf_c_h="yes"],
+                 [have_protobuf_c_h="no"])
+if test "x$have_protoc_c" = "xyes" && test "x$have_protobuf_c_h" != "xyes"
+then
+       have_protoc_c="no (unable to find <google/protobuf-c/protobuf-c.h>)"
+fi
+AM_CONDITIONAL(HAVE_PROTOC_C, test "x$have_protoc_c" = "xyes")
+
+AC_MSG_CHECKING([for kernel type ($host_os)])
+case $host_os in
+       *linux*)
+       AC_DEFINE([KERNEL_LINUX], 1, [True if program is to be compiled for a Linux kernel])
+       ac_system="Linux"
+       ;;
+       *solaris*)
+       AC_DEFINE([KERNEL_SOLARIS], 1, [True if program is to be compiled for a Solaris kernel])
+       ac_system="Solaris"
+       ;;
+       *darwin*)
+       ac_system="Darwin"
+       ;;
+       *openbsd*)
+       ac_system="OpenBSD"
+       ;;
+       *aix*)
+       AC_DEFINE([KERNEL_AIX], 1, [True if program is to be compiled for a AIX kernel])
+       ac_system="AIX"
+       ;;
+       *freebsd*)
+       AC_DEFINE([KERNEL_FREEBSD], 1, [True if program is to be compiled for a FreeBSD kernel])
+       ac_system="FreeBSD"
+       ;;
+       *)
+       ac_system="unknown"
+esac
+AC_MSG_RESULT([$ac_system])
+
+if test "x$ac_system" = "xLinux"
+then
+       AC_ARG_VAR([KERNEL_DIR], [path to Linux kernel sources])
+       if test -z "$KERNEL_DIR"
+       then
+               KERNEL_DIR="/lib/modules/`uname -r`/source"
+       fi
+
+       KERNEL_CFLAGS="-I$KERNEL_DIR/include"
+       AC_SUBST(KERNEL_CFLAGS)
+fi
+
+if test "x$ac_system" = "xSolaris"
+then
+       AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1, [Define to enforce POSIX thread semantics under Solaris.])
+       AC_DEFINE(_REENTRANT,               1, [Define to enable reentrancy interfaces.])
+fi
+if test "x$ac_system" = "xAIX"
+then
+       AC_DEFINE(_THREAD_SAFE_ERRNO, 1, [Define to use the thread-safe version of errno under AIX.])
+fi
+
+# Where to install .pc files.
+pkgconfigdir="${libdir}/pkgconfig"
+AC_SUBST(pkgconfigdir)
+
+# Check for standards compliance mode
+AC_ARG_ENABLE(standards,
+             AS_HELP_STRING([--enable-standards], [Enable standards compliance mode]),
+             [enable_standards="$enableval"],
+             [enable_standards="no"])
+if test "x$enable_standards" = "xyes"
+then
+       AC_DEFINE(_ISOC99_SOURCE,        1, [Define to enforce ISO C99 compliance.])
+       AC_DEFINE(_POSIX_C_SOURCE, 200809L, [Define to enforce POSIX.1-2008 compliance.])
+       AC_DEFINE(_XOPEN_SOURCE,       700, [Define to enforce X/Open 7 (XSI) compliance.])
+       AC_DEFINE(_REENTRANT,            1, [Define to enable reentrancy interfaces.])
+       if test "x$GCC" = "xyes"
+       then
+               CFLAGS="$CFLAGS -std=c99"
+       fi
+fi
+AM_CONDITIONAL(BUILD_FEATURE_STANDARDS, test "x$enable_standards" = "xyes")
+
+#
+# Checks for header files.
+#
+AC_HEADER_STDC
+AC_HEADER_SYS_WAIT
+AC_HEADER_DIRENT
+AC_HEADER_STDBOOL
+
+AC_CHECK_HEADERS(stdio.h errno.h math.h stdarg.h syslog.h fcntl.h signal.h assert.h sys/types.h sys/socket.h sys/select.h poll.h netdb.h arpa/inet.h sys/resource.h sys/param.h kstat.h regex.h sys/ioctl.h endian.h sys/isa_defs.h fnmatch.h libgen.h)
+
+# For ping library
+AC_CHECK_HEADERS(netinet/in_systm.h, [], [],
+[#if HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+])
+AC_CHECK_HEADERS(netinet/in.h, [], [],
+[#if HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_NETINET_IN_SYSTM_H
+# include <netinet/in_systm.h>
+#endif
+])
+AC_CHECK_HEADERS(netinet/ip.h, [], [],
+[#if HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_NETINET_IN_SYSTM_H
+# include <netinet/in_systm.h>
+#endif
+#if HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
+])
+AC_CHECK_HEADERS(netinet/ip_icmp.h, [], [],
+[#if HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_NETINET_IN_SYSTM_H
+# include <netinet/in_systm.h>
+#endif
+#if HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
+#if HAVE_NETINET_IP_H
+# include <netinet/ip.h>
+#endif
+])
+AC_CHECK_HEADERS(netinet/ip_var.h, [], [],
+[#if HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_NETINET_IN_SYSTM_H
+# include <netinet/in_systm.h>
+#endif
+#if HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
+#if HAVE_NETINET_IP_H
+# include <netinet/ip.h>
+#endif
+])
+AC_CHECK_HEADERS(netinet/ip6.h, [], [],
+[#if HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_NETINET_IN_SYSTM_H
+# include <netinet/in_systm.h>
+#endif
+#if HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
+])
+AC_CHECK_HEADERS(netinet/icmp6.h, [], [],
+[#if HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_NETINET_IN_SYSTM_H
+# include <netinet/in_systm.h>
+#endif
+#if HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
+#if HAVE_NETINET_IP6_H
+# include <netinet/ip6.h>
+#endif
+])
+AC_CHECK_HEADERS(netinet/tcp.h, [], [],
+[#if HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_NETINET_IN_SYSTM_H
+# include <netinet/in_systm.h>
+#endif
+#if HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
+#if HAVE_NETINET_IP_H
+# include <netinet/ip.h>
+#endif
+])
+AC_CHECK_HEADERS(netinet/udp.h, [], [],
+[#if HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_NETINET_IN_SYSTM_H
+# include <netinet/in_systm.h>
+#endif
+#if HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
+#if HAVE_NETINET_IP_H
+# include <netinet/ip.h>
+#endif
+])
+
+# For cpu modules
+AC_CHECK_HEADERS(sys/dkstat.h)
+if test "x$ac_system" = "xDarwin"
+then
+       AC_CHECK_HEADERS(mach/mach_init.h mach/host_priv.h mach/mach_error.h mach/mach_host.h mach/mach_port.h mach/mach_types.h mach/message.h mach/processor_set.h mach/processor.h mach/processor_info.h mach/task.h mach/thread_act.h mach/vm_region.h mach/vm_map.h mach/vm_prot.h mach/vm_statistics.h mach/kern_return.h)
+       AC_CHECK_HEADERS(CoreFoundation/CoreFoundation.h IOKit/IOKitLib.h IOKit/IOTypes.h IOKit/ps/IOPSKeys.h IOKit/IOBSD.h IOKit/storage/IOBlockStorageDriver.h)
+       # For the battery plugin
+       AC_CHECK_HEADERS(IOKit/ps/IOPowerSources.h, [], [],
+[
+#if HAVE_IOKIT_IOKITLIB_H
+#  include <IOKit/IOKitLib.h>
+#endif
+#if HAVE_IOKIT_IOTYPES_H
+#  include <IOKit/IOTypes.h>
+#endif
+])
+
+fi
+
+AC_CHECK_HEADERS(sys/sysctl.h, [], [],
+[
+#if HAVE_SYS_TYPES_H
+#  include <sys/types.h>
+#endif
+#if HAVE_SYS_PARAM_H
+# include <sys/param.h>
+#endif
+])
+
+AC_MSG_CHECKING([for sysctl kern.cp_times])
+if test -x /sbin/sysctl
+then
+       /sbin/sysctl kern.cp_times 2>/dev/null
+       if test $? -eq 0
+       then
+               AC_MSG_RESULT([yes])
+               AC_DEFINE(HAVE_SYSCTL_KERN_CP_TIMES, 1,
+               [Define if sysctl supports kern.cp_times])
+       else
+               AC_MSG_RESULT([no])
+       fi
+else
+       AC_MSG_RESULT([no])
+fi
+
+# For hddtemp module
+AC_CHECK_HEADERS(linux/major.h)
+
+# For md module (Linux only)
+if test "x$ac_system" = "xLinux"
+then
+       AC_CHECK_HEADERS(linux/raid/md_u.h,
+                        [have_linux_raid_md_u_h="yes"],
+                        [have_linux_raid_md_u_h="no"],
+[
+#include <sys/ioctl.h>
+#include <linux/major.h>
+#include <linux/types.h>
+])
+else
+       have_linux_raid_md_u_h="no"
+fi
+
+# For the swap module
+have_linux_wireless_h="no"
+if test "x$ac_system" = "xLinux"
+then
+  AC_CHECK_HEADERS(linux/wireless.h,
+                  [have_linux_wireless_h="yes"],
+                  [have_linux_wireless_h="no"],
+[
+#include <dirent.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+])
+fi
+
+# For the swap module
+have_sys_swap_h="yes"
+AC_CHECK_HEADERS(sys/swap.h vm/anon.h, [], [have_sys_swap_h="no"],
+[
+#undef _FILE_OFFSET_BITS
+#undef _LARGEFILE64_SOURCE
+#if HAVE_SYS_TYPES_H
+#  include <sys/types.h>
+#endif
+#if HAVE_SYS_PARAM_H
+# include <sys/param.h>
+#endif
+])
+
+if test "x$have_sys_swap_h$ac_system" = "xnoSolaris"
+then
+       hint_64=""
+       if test "x$GCC" = "xyes"
+       then
+               hint_64="CFLAGS='-m64'"
+       else
+               hint_64="CFLAGS='-xarch=v9'"
+       fi
+       AC_MSG_NOTICE([Solaris detected and sys/swap.h not usable. Try building a 64-bit binary ($hint_64 ./configure).])
+fi
+
+# For load module
+# For the processes plugin
+# For users module
+AC_CHECK_HEADERS(sys/loadavg.h linux/config.h utmp.h utmpx.h)
+
+# For interface plugin
+AC_CHECK_HEADERS(ifaddrs.h)
+AC_CHECK_HEADERS(net/if.h, [], [],
+[
+#if HAVE_SYS_TYPES_H
+#  include <sys/types.h>
+#endif
+#if HAVE_SYS_SOCKET_H
+#  include <sys/socket.h>
+#endif
+])
+AC_CHECK_HEADERS(linux/if.h, [], [],
+[
+#if HAVE_SYS_TYPES_H
+#  include <sys/types.h>
+#endif
+#if HAVE_SYS_SOCKET_H
+#  include <sys/socket.h>
+#endif
+])
+AC_CHECK_HEADERS(linux/netdevice.h, [], [],
+[
+#if HAVE_SYS_TYPES_H
+#  include <sys/types.h>
+#endif
+#if HAVE_SYS_SOCKET_H
+#  include <sys/socket.h>
+#endif
+#if HAVE_LINUX_IF_H
+# include <linux/if.h>
+#endif
+])
+
+# For ethstat module
+AC_CHECK_HEADERS(linux/sockios.h,
+    [have_linux_sockios_h="yes"],
+    [have_linux_sockios_h="no"],
+    [
+#if HAVE_SYS_IOCTL_H
+# include <sys/ioctl.h>
+#endif
+#if HAVE_NET_IF_H
+# include <net/if.h>
+#endif
+    ])
+AC_CHECK_HEADERS(linux/ethtool.h,
+    [have_linux_ethtool_h="yes"],
+    [have_linux_ethtool_h="no"],
+    [
+#if HAVE_SYS_IOCTL_H
+# include <sys/ioctl.h>
+#endif
+#if HAVE_NET_IF_H
+# include <net/if.h>
+#endif
+#if HAVE_LINUX_SOCKIOS_H
+# include <linux/sockios.h>
+#endif
+    ])
+
+# 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
+       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$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, [], [],
+[
+#if HAVE_SYS_TYPES_H
+#  include <sys/types.h>
+#endif
+#if HAVE_SYS_PARAM_H
+# include <sys/param.h>
+#endif
+])
+
+# For mount interface
+AC_CHECK_HEADERS(sys/mount.h, [], [],
+[
+#if HAVE_SYS_TYPES_H
+#  include <sys/types.h>
+#endif
+#if HAVE_SYS_PARAM_H
+# include <sys/param.h>
+#endif
+])
+
+# For the email plugin
+AC_CHECK_HEADERS(linux/un.h, [], [],
+[
+#if HAVE_SYS_SOCKET_H
+#      include <sys/socket.h>
+#endif
+])
+
+AC_CHECK_HEADERS(pwd.h grp.h sys/un.h ctype.h limits.h xfs/xqm.h fs_info.h fshelp.h paths.h mntent.h mnttab.h sys/fstyp.h sys/fs_types.h sys/mntent.h sys/mnttab.h sys/statfs.h sys/statvfs.h sys/vfs.h sys/vfstab.h kvm.h wordexp.h)
+
+# For the dns plugin
+AC_CHECK_HEADERS(arpa/nameser.h)
+AC_CHECK_HEADERS(arpa/nameser_compat.h, [], [],
+[
+#if HAVE_ARPA_NAMESER_H
+# include <arpa/nameser.h>
+#endif
+])
+
+AC_CHECK_HEADERS(net/if_arp.h, [], [],
+[#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+])
+AC_CHECK_HEADERS(net/ppp_defs.h)
+AC_CHECK_HEADERS(net/if_ppp.h, [], [],
+[#if HAVE_NET_PPP_DEFS_H
+# include <net/ppp_defs.h>
+#endif
+])
+AC_CHECK_HEADERS(netinet/if_ether.h, [], [],
+[#if HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+#if HAVE_NET_IF_H
+# include <net/if.h>
+#endif
+#if HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
+])
+
+AC_CHECK_HEADERS(netinet/ip_compat.h)
+
+have_net_pfvar_h="no"
+AC_CHECK_HEADERS(net/pfvar.h,
+               [have_net_pfvar_h="yes"],
+               [have_net_pfvar_h="no"],
+[
+#if HAVE_SYS_IOCTL_H
+# include <sys/ioctl.h>
+#endif
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+#if HAVE_NET_IF_H
+# include <net/if.h>
+#endif
+])
+
+# For the multimeter plugin
+have_termios_h="no"
+AC_CHECK_HEADERS(termios.h, [have_termios_h="yes"])
+
+#
+# Checks for typedefs, structures, and compiler characteristics.
+#
+AC_C_CONST
+AC_TYPE_PID_T
+AC_TYPE_SIZE_T
+AC_TYPE_UID_T
+AC_HEADER_TIME
+
+#
+# Checks for library functions.
+#
+AC_PROG_GCC_TRADITIONAL
+AC_CHECK_FUNCS(gettimeofday select strdup strtol getaddrinfo getnameinfo strchr memcpy strstr strcmp strncmp strncpy strlen strncasecmp strcasecmp openlog closelog sysconf setenv if_indextoname)
+
+AC_FUNC_STRERROR_R
+
+SAVE_CFLAGS="$CFLAGS"
+# Emulate behavior of src/Makefile.am
+if test "x$GCC" = "xyes"
+then
+       CFLAGS="$CFLAGS -Wall -Werror"
+fi
+
+AC_CACHE_CHECK([for strtok_r],
+  [c_cv_have_strtok_r_default],
+  AC_LINK_IFELSE(
+    [AC_LANG_PROGRAM(
+[[[
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+]]],
+[[[
+      char buffer[] = "foo,bar,baz";
+      char *token;
+      char *dummy;
+      char *saveptr;
+
+      dummy = buffer;
+      saveptr = NULL;
+      while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
+      {
+        dummy = NULL;
+        printf ("token = %s;\n", token);
+      }
+]]]
+    )],
+    [c_cv_have_strtok_r_default="yes"],
+    [c_cv_have_strtok_r_default="no"]
+  )
+)
+
+if test "x$c_cv_have_strtok_r_default" = "xno"
+then
+  CFLAGS="$CFLAGS -D_REENTRANT=1"
+
+  AC_CACHE_CHECK([if strtok_r needs _REENTRANT],
+    [c_cv_have_strtok_r_reentrant],
+    AC_LINK_IFELSE(
+      [AC_LANG_PROGRAM(
+[[[
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+]]],
+[[[
+        char buffer[] = "foo,bar,baz";
+        char *token;
+        char *dummy;
+        char *saveptr;
+
+        dummy = buffer;
+        saveptr = NULL;
+        while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
+        {
+          dummy = NULL;
+          printf ("token = %s;\n", token);
+        }
+]]]
+      )],
+      [c_cv_have_strtok_r_reentrant="yes"],
+      [AC_MSG_FAILURE([strtok_r isn't available. Please file a bugreport!])]
+    )
+  )
+fi
+
+CFLAGS="$SAVE_CFLAGS"
+if test "x$c_cv_have_strtok_r_reentrant" = "xyes"
+then
+       CFLAGS="$CFLAGS -D_REENTRANT=1"
+fi
+
+AC_CHECK_FUNCS(getpwnam_r getgrnam_r setgroups regcomp regerror regexec regfree)
+
+socket_needs_socket="no"
+AC_CHECK_FUNCS(socket, [], AC_CHECK_LIB(socket, socket, [socket_needs_socket="yes"], AC_MSG_ERROR(cannot find socket)))
+AM_CONDITIONAL(BUILD_WITH_LIBSOCKET, test "x$socket_needs_socket" = "xyes")
+
+clock_gettime_needs_rt="no"
+clock_gettime_needs_posix4="no"
+have_clock_gettime="no"
+AC_CHECK_FUNCS(clock_gettime, [have_clock_gettime="yes"])
+if test "x$have_clock_gettime" = "xno"
+then
+       AC_CHECK_LIB(rt, clock_gettime, [clock_gettime_needs_rt="yes"
+                                        have_clock_gettime="yes"])
+fi
+if test "x$have_clock_gettime" = "xno"
+then
+       AC_CHECK_LIB(posix4, clock_gettime, [clock_gettime_needs_posix4="yes"
+                                            have_clock_gettime="yes"])
+fi
+if test "x$have_clock_gettime" = "xyes"
+then
+       AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if the clock_gettime(2) function is available.])
+else
+       AC_MSG_WARN(cannot find clock_gettime)
+fi
+
+nanosleep_needs_rt="no"
+nanosleep_needs_posix4="no"
+AC_CHECK_FUNCS(nanosleep,
+    [],
+    AC_CHECK_LIB(rt, nanosleep,
+        [nanosleep_needs_rt="yes"],
+        AC_CHECK_LIB(posix4, nanosleep,
+            [nanosleep_needs_posix4="yes"],
+            AC_MSG_ERROR(cannot find nanosleep))))
+
+AM_CONDITIONAL(BUILD_WITH_LIBRT, test "x$clock_gettime_needs_rt" = "xyes" || test "x$nanosleep_needs_rt" = "xyes")
+AM_CONDITIONAL(BUILD_WITH_LIBPOSIX4, test "x$clock_gettime_needs_posix4" = "xyes" || test "x$nanosleep_needs_posix4" = "xyes")
+
+AC_CHECK_FUNCS(sysctl, [have_sysctl="yes"], [have_sysctl="no"])
+AC_CHECK_FUNCS(sysctlbyname, [have_sysctlbyname="yes"], [have_sysctlbyname="no"])
+AC_CHECK_FUNCS(host_statistics, [have_host_statistics="yes"], [have_host_statistics="no"])
+AC_CHECK_FUNCS(processor_info, [have_processor_info="yes"], [have_processor_info="no"])
+AC_CHECK_FUNCS(thread_info, [have_thread_info="yes"], [have_thread_info="no"])
+AC_CHECK_FUNCS(statfs, [have_statfs="yes"], [have_statfs="no"])
+AC_CHECK_FUNCS(statvfs, [have_statvfs="yes"], [have_statvfs="no"])
+AC_CHECK_FUNCS(getifaddrs, [have_getifaddrs="yes"], [have_getifaddrs="no"])
+AC_CHECK_FUNCS(getloadavg, [have_getloadavg="yes"], [have_getloadavg="no"])
+AC_CHECK_FUNCS(syslog, [have_syslog="yes"], [have_syslog="no"])
+AC_CHECK_FUNCS(getutent, [have_getutent="yes"], [have_getutent="no"])
+AC_CHECK_FUNCS(getutxent, [have_getutxent="yes"], [have_getutxent="no"])
+
+# Check for strptime {{{
+if test "x$GCC" = "xyes"
+then
+       SAVE_CFLAGS="$CFLAGS"
+       CFLAGS="$CFLAGS -Wall -Wextra -Werror"
+fi
+
+AC_CHECK_FUNCS(strptime, [have_strptime="yes"], [have_strptime="no"])
+if test "x$have_strptime" = "xyes"
+then
+       AC_CACHE_CHECK([whether strptime is exported by default],
+                      [c_cv_have_strptime_default],
+                      AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+[[[
+#include <time.h>
+]]],
+[[[
+ struct tm stm;
+ (void) strptime ("2010-12-30%13:42:42", "%Y-%m-%dT%T", &stm);
+]]]
+                      )],
+                      [c_cv_have_strptime_default="yes"],
+                      [c_cv_have_strptime_default="no"]))
+fi
+if test "x$have_strptime" = "xyes" && test "x$c_cv_have_strptime_default" = "xno"
+then
+       AC_CACHE_CHECK([whether strptime needs standards mode],
+                      [c_cv_have_strptime_standards],
+                      AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+[[[
+#ifndef _ISOC99_SOURCE
+# define _ISOC99_SOURCE 1
+#endif
+#ifndef _POSIX_C_SOURCE
+# define _POSIX_C_SOURCE 200112L
+#endif
+#ifndef _XOPEN_SOURCE
+# define _XOPEN_SOURCE 500
+#endif
+#include <time.h>
+]]],
+[[[
+ struct tm stm;
+ (void) strptime ("2010-12-30%13:42:42", "%Y-%m-%dT%T", &stm);
+]]]
+                      )],
+                      [c_cv_have_strptime_standards="yes"],
+                      [c_cv_have_strptime_standards="no"]))
+
+       if test "x$c_cv_have_strptime_standards" = "xyes"
+       then
+               AC_DEFINE([STRPTIME_NEEDS_STANDARDS], 1, [Set to true if strptime is only exported in X/Open mode (GNU libc).])
+       else
+               have_strptime="no"
+       fi
+fi
+
+if test "x$GCC" = "xyes"
+then
+       CFLAGS="$SAVE_CFLAGS"
+fi
+# }}} Check for strptime
+
+AC_CHECK_FUNCS(swapctl, [have_swapctl="yes"], [have_swapctl="no"])
+if test "x$have_swapctl" = "xyes"; then
+        AC_CACHE_CHECK([whether swapctl takes two arguments],
+                [c_cv_have_swapctl_two_args],
+                AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+[[[
+#if HAVE_SYS_SWAP_H && !defined(_LP64) && _FILE_OFFSET_BITS == 64
+#  undef _FILE_OFFSET_BITS
+#  undef _LARGEFILE64_SOURCE
+#endif
+#include <sys/stat.h>
+#include <sys/swap.h>
+]]],
+[[[
+int num = swapctl(0, NULL);
+]]]
+                        )],
+                        [c_cv_have_swapctl_two_args="yes"],
+                        [c_cv_have_swapctl_two_args="no"]
+                )
+        )
+        AC_CACHE_CHECK([whether swapctl takes three arguments],
+                [c_cv_have_swapctl_three_args],
+                AC_COMPILE_IFELSE(
+                        [AC_LANG_PROGRAM(
+[[[
+#if HAVE_SYS_SWAP_H && !defined(_LP64) && _FILE_OFFSET_BITS == 64
+#  undef _FILE_OFFSET_BITS
+#  undef _LARGEFILE64_SOURCE
+#endif
+#include <sys/stat.h>
+#include <sys/swap.h>
+]]],
+[[[
+int num = swapctl(0, NULL, 0);
+]]]
+                        )],
+                        [c_cv_have_swapctl_three_args="yes"],
+                        [c_cv_have_swapctl_three_args="no"]
+                )
+        )
+fi
+# Check for different versions of `swapctl' here..
+if test "x$have_swapctl" = "xyes"; then
+        if test "x$c_cv_have_swapctl_two_args" = "xyes"; then
+                AC_DEFINE(HAVE_SWAPCTL_TWO_ARGS, 1,
+                          [Define if the function swapctl exists and takes two arguments.])
+        fi
+        if test "x$c_cv_have_swapctl_three_args" = "xyes"; then
+                AC_DEFINE(HAVE_SWAPCTL_THREE_ARGS, 1,
+                          [Define if the function swapctl exists and takes three arguments.])
+        fi
+fi
+
+# Check for NAN
+AC_ARG_WITH(nan-emulation, [AS_HELP_STRING([--with-nan-emulation], [use emulated NAN. For crosscompiling only.])],
+[
+ if test "x$withval" = "xno"; then
+        nan_type="none"
+ else if test "x$withval" = "xyes"; then
+        nan_type="zero"
+ else
+        nan_type="$withval"
+ fi; fi
+],
+[nan_type="none"])
+if test "x$nan_type" = "xnone"; then
+  AC_CACHE_CHECK([whether NAN is defined by default],
+    [c_cv_have_nan_default],
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+[[[
+#include <stdlib.h>
+#include <math.h>
+static double foo = NAN;
+]]],
+[[[
+       if (isnan (foo))
+        return 0;
+       else
+       return 1;
+]]]
+      )],
+      [c_cv_have_nan_default="yes"],
+      [c_cv_have_nan_default="no"]
+    )
+  )
+  if test "x$c_cv_have_nan_default" = "xyes"
+  then
+    nan_type="default"
+  fi
+fi
+if test "x$nan_type" = "xnone"; then
+  AC_CACHE_CHECK([whether NAN is defined by __USE_ISOC99],
+    [c_cv_have_nan_isoc],
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+[[[
+#include <stdlib.h>
+#define __USE_ISOC99 1
+#include <math.h>
+static double foo = NAN;
+]]],
+[[[
+       if (isnan (foo))
+        return 0;
+       else
+       return 1;
+]]]
+      )],
+      [c_cv_have_nan_isoc="yes"],
+      [c_cv_have_nan_isoc="no"]
+    )
+  )
+  if test "x$c_cv_have_nan_isoc" = "xyes"
+  then
+    nan_type="isoc99"
+  fi
+fi
+if test "x$nan_type" = "xnone"; then
+  SAVE_LDFLAGS=$LDFLAGS
+  LDFLAGS="$LDFLAGS -lm"
+  AC_CACHE_CHECK([whether NAN can be defined by 0/0],
+    [c_cv_have_nan_zero],
+    AC_RUN_IFELSE([AC_LANG_PROGRAM(
+[[[
+#include <stdlib.h>
+#include <math.h>
+#ifdef NAN
+# undef NAN
+#endif
+#define NAN (0.0 / 0.0)
+#ifndef isnan
+# define isnan(f) ((f) != (f))
+#endif
+static double foo = NAN;
+]]],
+[[[
+       if (isnan (foo))
+        return 0;
+       else
+       return 1;
+]]]
+      )],
+      [c_cv_have_nan_zero="yes"],
+      [c_cv_have_nan_zero="no"]
+    )
+  )
+  LDFLAGS=$SAVE_LDFLAGS
+  if test "x$c_cv_have_nan_zero" = "xyes"
+  then
+    nan_type="zero"
+  fi
+fi
+
+if test "x$nan_type" = "xdefault"; then
+  AC_DEFINE(NAN_STATIC_DEFAULT, 1,
+    [Define if NAN is defined by default and can initialize static variables.])
+else if test "x$nan_type" = "xisoc99"; then
+  AC_DEFINE(NAN_STATIC_ISOC, 1,
+    [Define if NAN is defined by __USE_ISOC99 and can initialize static variables.])
+else if test "x$nan_type" = "xzero"; then
+  AC_DEFINE(NAN_ZERO_ZERO, 1,
+    [Define if NAN can be defined as (0.0 / 0.0)])
+else
+  AC_MSG_ERROR([Didn't find out how to statically initialize variables to NAN. Sorry.])
+fi; fi; fi
+
+AC_ARG_WITH(fp-layout, [AS_HELP_STRING([--with-fp-layout], [set the memory layout of doubles. For crosscompiling only.])],
+[
+ if test "x$withval" = "xnothing"; then
+       fp_layout_type="nothing"
+ else if test "x$withval" = "xendianflip"; then
+       fp_layout_type="endianflip"
+ else if test "x$withval" = "xintswap"; then
+       fp_layout_type="intswap"
+ else
+       AC_MSG_ERROR([Invalid argument for --with-fp-layout. Valid arguments are: nothing, endianflip, intswap]);
+fi; fi; fi
+],
+[fp_layout_type="unknown"])
+
+if test "x$fp_layout_type" = "xunknown"; then
+  AC_CACHE_CHECK([if doubles are stored in x86 representation],
+    [c_cv_fp_layout_need_nothing],
+    AC_RUN_IFELSE([AC_LANG_PROGRAM(
+[[[
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#if HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#if HAVE_STDBOOL_H
+# include <stdbool.h>
+#endif
+]]],
+[[[
+       uint64_t i0;
+       uint64_t i1;
+       uint8_t c[8];
+       double d;
+
+       d = 8.642135e130; 
+       memcpy ((void *) &i0, (void *) &d, 8);
+
+       i1 = i0;
+       memcpy ((void *) c, (void *) &i1, 8);
+
+       if ((c[0] == 0x2f) && (c[1] == 0x25)
+                       && (c[2] == 0xc0) && (c[3] == 0xc7)
+                       && (c[4] == 0x43) && (c[5] == 0x2b)
+                       && (c[6] == 0x1f) && (c[7] == 0x5b))
+               return (0);
+       else
+               return (1);
+]]]
+      )],
+      [c_cv_fp_layout_need_nothing="yes"],
+      [c_cv_fp_layout_need_nothing="no"]
+    )
+  )
+  if test "x$c_cv_fp_layout_need_nothing" = "xyes"; then
+    fp_layout_type="nothing"
+  fi
+fi
+if test "x$fp_layout_type" = "xunknown"; then
+  AC_CACHE_CHECK([if endianflip converts to x86 representation],
+    [c_cv_fp_layout_need_endianflip],
+    AC_RUN_IFELSE([AC_LANG_PROGRAM(
+[[[
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#if HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#if HAVE_STDBOOL_H
+# include <stdbool.h>
+#endif
+#define endianflip(A) ((((uint64_t)(A) & 0xff00000000000000LL) >> 56) | \
+                       (((uint64_t)(A) & 0x00ff000000000000LL) >> 40) | \
+                       (((uint64_t)(A) & 0x0000ff0000000000LL) >> 24) | \
+                       (((uint64_t)(A) & 0x000000ff00000000LL) >> 8)  | \
+                       (((uint64_t)(A) & 0x00000000ff000000LL) << 8)  | \
+                       (((uint64_t)(A) & 0x0000000000ff0000LL) << 24) | \
+                       (((uint64_t)(A) & 0x000000000000ff00LL) << 40) | \
+                       (((uint64_t)(A) & 0x00000000000000ffLL) << 56))
+]]],
+[[[
+       uint64_t i0;
+       uint64_t i1;
+       uint8_t c[8];
+       double d;
+
+       d = 8.642135e130; 
+       memcpy ((void *) &i0, (void *) &d, 8);
+
+       i1 = endianflip (i0);
+       memcpy ((void *) c, (void *) &i1, 8);
+
+       if ((c[0] == 0x2f) && (c[1] == 0x25)
+                       && (c[2] == 0xc0) && (c[3] == 0xc7)
+                       && (c[4] == 0x43) && (c[5] == 0x2b)
+                       && (c[6] == 0x1f) && (c[7] == 0x5b))
+               return (0);
+       else
+               return (1);
+]]]
+      )],
+      [c_cv_fp_layout_need_endianflip="yes"],
+      [c_cv_fp_layout_need_endianflip="no"]
+    )
+  )
+  if test "x$c_cv_fp_layout_need_endianflip" = "xyes"; then
+    fp_layout_type="endianflip"
+  fi
+fi
+if test "x$fp_layout_type" = "xunknown"; then
+  AC_CACHE_CHECK([if intswap converts to x86 representation],
+    [c_cv_fp_layout_need_intswap],
+    AC_RUN_IFELSE([AC_LANG_PROGRAM(
+[[[
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#if HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#if HAVE_STDBOOL_H
+# include <stdbool.h>
+#endif
+#define intswap(A)    ((((uint64_t)(A) & 0xffffffff00000000LL) >> 32) | \
+                       (((uint64_t)(A) & 0x00000000ffffffffLL) << 32))
+]]],
+[[[
+       uint64_t i0;
+       uint64_t i1;
+       uint8_t c[8];
+       double d;
+
+       d = 8.642135e130; 
+       memcpy ((void *) &i0, (void *) &d, 8);
+
+       i1 = intswap (i0);
+       memcpy ((void *) c, (void *) &i1, 8);
+
+       if ((c[0] == 0x2f) && (c[1] == 0x25)
+                       && (c[2] == 0xc0) && (c[3] == 0xc7)
+                       && (c[4] == 0x43) && (c[5] == 0x2b)
+                       && (c[6] == 0x1f) && (c[7] == 0x5b))
+               return (0);
+       else
+               return (1);
+]]]
+      )],
+      [c_cv_fp_layout_need_intswap="yes"],
+      [c_cv_fp_layout_need_intswap="no"]
+    )
+  )
+  if test "x$c_cv_fp_layout_need_intswap" = "xyes"; then
+    fp_layout_type="intswap"
+  fi
+fi
+
+if test "x$fp_layout_type" = "xnothing"; then
+  AC_DEFINE(FP_LAYOUT_NEED_NOTHING, 1,
+  [Define if doubles are stored in x86 representation.])
+else if test "x$fp_layout_type" = "xendianflip"; then
+  AC_DEFINE(FP_LAYOUT_NEED_ENDIANFLIP, 1,
+  [Define if endianflip is needed to convert to x86 representation.])
+else if test "x$fp_layout_type" = "xintswap"; then
+  AC_DEFINE(FP_LAYOUT_NEED_INTSWAP, 1,
+  [Define if intswap is needed to convert to x86 representation.])
+else
+  AC_MSG_ERROR([Didn't find out how doubles are stored in memory. Sorry.])
+fi; fi; fi
+
+# --with-useragent {{{
+AC_ARG_WITH(useragent, [AS_HELP_STRING([--with-useragent@<:@=AGENT@:>@], [User agent to use on http requests])],
+[
+    if test "x$withval" != "xno" && test "x$withval" != "xyes"
+    then
+        AC_DEFINE_UNQUOTED(COLLECTD_USERAGENT, ["$withval"], [User agent for http requests])
+    fi
+])
+
+# }}}
+
+have_getfsstat="no"
+AC_CHECK_FUNCS(getfsstat, [have_getfsstat="yes"])
+have_getvfsstat="no"
+AC_CHECK_FUNCS(getvfsstat, [have_getvfsstat="yes"])
+have_listmntent="no"
+AC_CHECK_FUNCS(listmntent, [have_listmntent="yes"])
+
+have_getmntent="no"
+AC_CHECK_FUNCS(getmntent, [have_getmntent="c"])
+if test "x$have_getmntent" = "xno"; then
+       AC_CHECK_LIB(sun, getmntent, [have_getmntent="sun"])
+fi
+if test "x$have_getmntent" = "xno"; then
+       AC_CHECK_LIB(seq, getmntent, [have_getmntent="seq"])
+fi
+if test "x$have_getmntent" = "xno"; then
+       AC_CHECK_LIB(gen, getmntent, [have_getmntent="gen"])
+fi
+
+if test "x$have_getmntent" = "xc"; then
+       AC_CACHE_CHECK([whether getmntent takes one argument],
+               [c_cv_have_one_getmntent],
+               AC_COMPILE_IFELSE(
+                       [AC_LANG_PROGRAM(
+[[[
+#include "$srcdir/src/utils_mount.h"
+]]],
+[[[
+FILE *fh;
+struct mntent *me;
+fh = setmntent ("/etc/mtab", "r");
+me = getmntent (fh);
+]]]
+                       )],
+                       [c_cv_have_one_getmntent="yes"],
+                       [c_cv_have_one_getmntent="no"]
+               )
+       )
+       AC_CACHE_CHECK([whether getmntent takes two arguments],
+               [c_cv_have_two_getmntent],
+               AC_COMPILE_IFELSE(
+                       [AC_LANG_PROGRAM(
+[[[
+#include "$srcdir/src/utils_mount.h"
+]]],
+[[[
+                                FILE *fh;
+                                struct mnttab mt;
+                                int status;
+                                fh = fopen ("/etc/mnttab", "r");
+                                status = getmntent (fh, &mt);
+]]]
+                       )],
+                       [c_cv_have_two_getmntent="yes"],
+                       [c_cv_have_two_getmntent="no"]
+               )
+       )
+fi
+
+# Check for different versions of `getmntent' here..
+
+if test "x$have_getmntent" = "xc"; then
+       if test "x$c_cv_have_one_getmntent" = "xyes"; then
+               AC_DEFINE(HAVE_ONE_GETMNTENT, 1,
+                         [Define if the function getmntent exists and takes one argument.])
+       fi
+       if test "x$c_cv_have_two_getmntent" = "xyes"; then
+               AC_DEFINE(HAVE_TWO_GETMNTENT, 1,
+                         [Define if the function getmntent exists and takes two arguments.])
+       fi
+fi
+if test "x$have_getmntent" = "xsun"; then
+       AC_DEFINE(HAVE_SUN_GETMNTENT, 1,
+                 [Define if the function getmntent exists. It's the version from libsun.])
+fi
+if test "x$have_getmntent" = "xseq"; then
+       AC_DEFINE(HAVE_SEQ_GETMNTENT, 1,
+                 [Define if the function getmntent exists. It's the version from libseq.])
+fi
+if test "x$have_getmntent" = "xgen"; then
+       AC_DEFINE(HAVE_GEN_GETMNTENT, 1,
+                 [Define if the function getmntent exists. It's the version from libgen.])
+fi
+
+# Check for htonll
+AC_MSG_CHECKING([if have htonll defined])
+
+    have_htonll="no"
+    AC_LINK_IFELSE([AC_LANG_PROGRAM(
+[[[
+#include <sys/types.h>
+#include <netinet/in.h>
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+]]],
+[[[
+          return htonll(0);
+]]]
+    )],
+    [
+      have_htonll="yes"
+      AC_DEFINE(HAVE_HTONLL, 1, [Define if the function htonll exists.])
+    ])
+AC_MSG_RESULT([$have_htonll])
+
+# Check for structures
+AC_CHECK_MEMBERS([struct if_data.ifi_ibytes, struct if_data.ifi_opackets, struct if_data.ifi_ierrors],
+       [AC_DEFINE(HAVE_STRUCT_IF_DATA, 1, [Define if struct if_data exists and is usable.])],
+       [],
+       [
+       #include <sys/types.h>
+       #include <sys/socket.h>
+       #include <net/if.h>
+       ])
+AC_CHECK_MEMBERS([struct net_device_stats.rx_bytes, struct net_device_stats.tx_packets, struct net_device_stats.rx_errors],
+       [AC_DEFINE(HAVE_STRUCT_NET_DEVICE_STATS, 1, [Define if struct net_device_stats exists and is usable.])],
+       [],
+       [
+       #include <sys/types.h>
+       #include <sys/socket.h>
+       #include <linux/if.h>
+       #include <linux/netdevice.h>
+       ])
+
+AC_CHECK_MEMBERS([struct ip_mreqn.imr_ifindex], [],
+       [],
+       [
+       #include <netinet/in.h>
+       #include <net/if.h>
+       ])
+
+AC_CHECK_MEMBERS([struct kinfo_proc.ki_pid, struct kinfo_proc.ki_rssize, struct kinfo_proc.ki_rusage],
+       [
+               AC_DEFINE(HAVE_STRUCT_KINFO_PROC_FREEBSD, 1,
+                       [Define if struct kinfo_proc exists in the FreeBSD variant.])
+               have_struct_kinfo_proc_freebsd="yes"
+       ],
+       [
+               have_struct_kinfo_proc_freebsd="no"
+       ],
+       [
+#include <kvm.h>
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#include <sys/user.h>
+       ])
+
+AC_CHECK_MEMBERS([struct kinfo_proc.kp_proc, struct kinfo_proc.kp_eproc],
+       [
+               AC_DEFINE(HAVE_STRUCT_KINFO_PROC_OPENBSD, 1,
+                       [Define if struct kinfo_proc exists in the OpenBSD variant.])
+               have_struct_kinfo_proc_openbsd="yes"
+       ],
+       [
+               have_struct_kinfo_proc_openbsd="no"
+       ],
+       [
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#include <kvm.h>
+       ])
+
+AC_CHECK_MEMBERS([struct udphdr.uh_dport, struct udphdr.uh_sport], [], [],
+[#define _BSD_SOURCE
+#if HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_NETINET_IN_SYSTM_H
+# include <netinet/in_systm.h>
+#endif
+#if HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
+#if HAVE_NETINET_IP_H
+# include <netinet/ip.h>
+#endif
+#if HAVE_NETINET_UDP_H
+# include <netinet/udp.h>
+#endif
+])
+AC_CHECK_MEMBERS([struct udphdr.dest, struct udphdr.source], [], [],
+[#define _BSD_SOURCE
+#if HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_NETINET_IN_SYSTM_H
+# include <netinet/in_systm.h>
+#endif
+#if HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
+#if HAVE_NETINET_IP_H
+# include <netinet/ip.h>
+#endif
+#if HAVE_NETINET_UDP_H
+# include <netinet/udp.h>
+#endif
+])
+
+AC_CHECK_MEMBERS([kstat_io_t.nwritten, kstat_io_t.writes, kstat_io_t.nwrites, kstat_io_t.wtime],
+       [],
+       [],
+       [
+#if HAVE_KSTAT_H
+# include <kstat.h>
+#endif
+       ])
+
+#
+# Checks for libraries begin here
+#
+
+with_libresolv="yes"
+AC_CHECK_LIB(resolv, res_search,
+[
+       AC_DEFINE(HAVE_LIBRESOLV, 1, [Define to 1 if you have the 'resolv' library (-lresolv).])
+],
+[with_libresolv="no"])
+AM_CONDITIONAL(BUILD_WITH_LIBRESOLV, test "x$with_libresolv" = "xyes")
+
+dnl Check for HAL (hardware abstraction library)
+with_libhal="yes"
+AC_CHECK_LIB(hal,libhal_device_property_exists,
+            [AC_DEFINE(HAVE_LIBHAL, 1, [Define to 1 if you have 'hal' library])],
+            [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`"
+               AC_SUBST(BUILD_WITH_LIBHAL_CFLAGS)
+               AC_SUBST(BUILD_WITH_LIBHAL_LIBS)
+       fi
+fi
+
+m4_divert_once([HELP_WITH], [
+collectd additional packages:])
+
+AM_CONDITIONAL([BUILD_FREEBSD],[test "x$x$ac_system" = "xFreeBSD"])
+
+AM_CONDITIONAL([BUILD_AIX],[test "x$x$ac_system" = "xAIX"]) 
+
+if test "x$ac_system" = "xAIX"
+then
+       with_perfstat="yes"
+       with_procinfo="yes"
+else
+       with_perfstat="no (AIX only)"
+       with_procinfo="no (AIX only)"
+fi
+
+if test "x$with_perfstat" = "xyes"
+then
+       AC_CHECK_LIB(perfstat, perfstat_reset, [with_perfstat="yes"], [with_perfstat="no (perfstat not found)"], [])
+#      AC_CHECK_HEADERS(sys/protosw.h libperfstat.h,, [with_perfstat="no (perfstat not found)"])
+fi
+if test "x$with_perfstat" = "xyes"
+then
+        AC_DEFINE(HAVE_PERFSTAT, 1, [Define to 1 if you have the 'perfstat' library (-lperfstat)])
+        # struct members pertaining to donation have been added to libperfstat somewhere between AIX5.3ML5 and AIX5.3ML9
+        AC_CHECK_MEMBER([perfstat_partition_type_t.b.donate_enabled], [], [], [[#include <libperfstat.h]])
+        if test "x$av_cv_member_perfstat_partition_type_t_b_donate_enabled" = "xyes"
+        then
+               AC_DEFINE(PERFSTAT_SUPPORTS_DONATION, 1, [Define to 1 if your version of the 'perfstat' library supports donation])
+        fi
+fi
+AM_CONDITIONAL(BUILD_WITH_PERFSTAT, test "x$with_perfstat" = "xyes")
+
+# Processes plugin under AIX.
+if test "x$with_procinfo" = "xyes"
+then
+       AC_CHECK_HEADERS(procinfo.h,, [with_procinfo="no (procinfo.h not found)"])
+fi
+if test "x$with_procinfo" = "xyes"
+then
+        AC_DEFINE(HAVE_PROCINFO_H, 1, [Define to 1 if you have the procinfo.h])
+fi
+
+if test "x$ac_system" = "xSolaris"
+then
+       with_kstat="yes"
+       with_devinfo="yes"
+else
+       with_kstat="no (Solaris only)"
+       with_devinfo="no (Solaris only)"
+fi
+
+if test "x$with_kstat" = "xyes"
+then
+       AC_CHECK_LIB(kstat, kstat_open, [with_kstat="yes"], [with_kstat="no (libkstat not found)"], [])
+fi
+if test "x$with_kstat" = "xyes"
+then
+       AC_CHECK_LIB(devinfo, di_init, [with_devinfo="yes"], [with_devinfo="no (not found)"], [])
+       AC_CHECK_HEADERS(kstat.h,, [with_kstat="no (kstat.h not found)"])
+fi
+if test "x$with_kstat" = "xyes"
+then
+       AC_DEFINE(HAVE_LIBKSTAT, 1,
+                 [Define to 1 if you have the 'kstat' library (-lkstat)])
+fi
+AM_CONDITIONAL(BUILD_WITH_LIBKSTAT, test "x$with_kstat" = "xyes")
+AM_CONDITIONAL(BUILD_WITH_LIBDEVINFO, test "x$with_devinfo" = "xyes")
+
+with_libiokit="no"
+if test "x$ac_system" = "xDarwin"
+then
+       with_libiokit="yes"
+else
+       with_libiokit="no"
+fi
+AM_CONDITIONAL(BUILD_WITH_LIBIOKIT, test "x$with_libiokit" = "xyes")
+
+with_libkvm="no"
+AC_CHECK_LIB(kvm, kvm_getprocs, [with_kvm_getprocs="yes"], [with_kvm_getprocs="no"])
+if test "x$with_kvm_getprocs" = "xyes"
+then
+       AC_DEFINE(HAVE_LIBKVM_GETPROCS, 1,
+                 [Define to 1 if you have the 'kvm' library with the 'kvm_getprocs' symbol (-lkvm)])
+       with_libkvm="yes"
+fi
+AM_CONDITIONAL(BUILD_WITH_LIBKVM_GETPROCS, test "x$with_kvm_getprocs" = "xyes")
+
+AC_CHECK_LIB(kvm, kvm_getswapinfo, [with_kvm_getswapinfo="yes"], [with_kvm_getswapinfo="no"])
+if test "x$with_kvm_getswapinfo" = "xyes"
+then
+       AC_DEFINE(HAVE_LIBKVM_GETSWAPINFO, 1,
+                 [Define to 1 if you have the 'kvm' library with the 'kvm_getswapinfo' symbol (-lkvm)])
+       with_libkvm="yes"
+fi
+AM_CONDITIONAL(BUILD_WITH_LIBKVM_GETSWAPINFO, test "x$with_kvm_getswapinfo" = "xyes")
+
+AC_CHECK_LIB(kvm, kvm_nlist, [with_kvm_nlist="yes"], [with_kvm_nlist="no"])
+if test "x$with_kvm_nlist" = "xyes"
+then
+       AC_CHECK_HEADERS(bsd/nlist.h nlist.h)
+       AC_DEFINE(HAVE_LIBKVM_NLIST, 1,
+                 [Define to 1 if you have the 'kvm' library with the 'kvm_nlist' symbol (-lkvm)])
+       with_libkvm="yes"
+fi
+AM_CONDITIONAL(BUILD_WITH_LIBKVM_NLIST, test "x$with_kvm_nlist" = "xyes")
+
+AC_CHECK_LIB(kvm, kvm_openfiles, [with_kvm_openfiles="yes"], [with_kvm_openfiles="no"])
+if test "x$with_kvm_openfiles" = "xyes"
+then
+       AC_DEFINE(HAVE_LIBKVM_NLIST, 1,
+                 [Define to 1 if you have the 'kvm' library with the 'kvm_openfiles' symbol (-lkvm)])
+       with_libkvm="yes"
+fi
+AM_CONDITIONAL(BUILD_WITH_LIBKVM_OPENFILES, test "x$with_kvm_openfiles" = "xyes")
+
+# --with-libaquaero5 {{{
+AC_ARG_WITH(libaquaero5, [AS_HELP_STRING([--with-libaquaero5@<:@=PREFIX@:>@], [Path to aquatools-ng source code.])],
+[
+ if test "x$withval" = "xyes"
+ then
+        with_libaquaero5="yes"
+ else if test "x$withval" = "xno"
+ then
+        with_libaquaero5="no"
+ else
+        with_libaquaero5="yes"
+        LIBAQUAERO5_CFLAGS="$LIBAQUAERO5_CFLAGS -I$withval/src"
+        LIBAQUAERO5_LDFLAGS="$LIBAQUAERO5_LDFLAGS -L$withval/obj"
+ fi; fi
+],
+[with_libaquaero5="yes"])
+
+SAVE_CPPFLAGS="$CPPFLAGS"
+SAVE_LDFLAGS="$LDFLAGS"
+
+CPPFLAGS="$CPPFLAGS $LIBAQUAERO5_CFLAGS"
+LDFLAGS="$LDFLAGS $LIBAQUAERO5_LDFLAGS"
+
+if test "x$with_libaquaero5" = "xyes"
+then
+       if test "x$LIBAQUAERO5_CFLAGS" != "x"
+       then
+               AC_MSG_NOTICE([libaquaero5 CPPFLAGS: $LIBAQUAERO5_CFLAGS])
+       fi
+       AC_CHECK_HEADERS(libaquaero5.h,
+       [with_libaquaero5="yes"],
+       [with_libaquaero5="no (libaquaero5.h not found)"])
+fi
+if test "x$with_libaquaero5" = "xyes"
+then
+       if test "x$LIBAQUAERO5_LDFLAGS" != "x"
+       then
+               AC_MSG_NOTICE([libaquaero5 LDFLAGS: $LIBAQUAERO5_LDFLAGS])
+       fi
+       AC_CHECK_LIB(aquaero5, libaquaero5_poll,
+       [with_libaquaero5="yes"],
+       [with_libaquaero5="no (symbol 'libaquaero5_poll' not found)"])
+fi
+
+CPPFLAGS="$SAVE_CPPFLAGS"
+LDFLAGS="$SAVE_LDFLAGS"
+
+if test "x$with_libaquaero5" = "xyes"
+then
+       BUILD_WITH_LIBAQUAERO5_CFLAGS="$LIBAQUAERO5_CFLAGS"
+       BUILD_WITH_LIBAQUAERO5_LDFLAGS="$LIBAQUAERO5_LDFLAGS"
+       AC_SUBST(BUILD_WITH_LIBAQUAERO5_CFLAGS)
+       AC_SUBST(BUILD_WITH_LIBAQUAERO5_LDFLAGS)
+fi
+AM_CONDITIONAL(BUILD_WITH_LIBAQUAERO5, test "x$with_libaquaero5" = "xyes")
+# }}}
+
+# --with-libcredis {{{
+AC_ARG_WITH(libcredis, [AS_HELP_STRING([--with-libcredis@<:@=PREFIX@:>@], [Path to libcredis.])],
+[
+ if test "x$withval" = "xyes"
+ then
+        with_libcredis="yes"
+ else if test "x$withval" = "xno"
+ then
+        with_libcredis="no"
+ else
+        with_libcredis="yes"
+        LIBCREDIS_CPPFLAGS="$LIBCREDIS_CPPFLAGS -I$withval/include"
+        LIBCREDIS_LDFLAGS="$LIBCREDIS_LDFLAGS -L$withval/lib"
+ fi; fi
+],
+[with_libcredis="yes"])
+
+SAVE_CPPFLAGS="$CPPFLAGS"
+SAVE_LDFLAGS="$LDFLAGS"
+
+CPPFLAGS="$CPPFLAGS $LIBCREDIS_CPPFLAGS"
+LDFLAGS="$LDFLAGS $LIBCREDIS_LDFLAGS"
+
+if test "x$with_libcredis" = "xyes"
+then
+       if test "x$LIBCREDIS_CPPFLAGS" != "x"
+       then
+               AC_MSG_NOTICE([libcredis CPPFLAGS: $LIBCREDIS_CPPFLAGS])
+       fi
+       AC_CHECK_HEADERS(credis.h,
+       [with_libcredis="yes"],
+       [with_libcredis="no (credis.h not found)"])
+fi
+if test "x$with_libcredis" = "xyes"
+then
+       if test "x$LIBCREDIS_LDFLAGS" != "x"
+       then
+               AC_MSG_NOTICE([libcredis LDFLAGS: $LIBCREDIS_LDFLAGS])
+       fi
+       AC_CHECK_LIB(credis, credis_info,
+       [with_libcredis="yes"],
+       [with_libcredis="no (symbol 'credis_info' not found)"])
+
+fi
+
+CPPFLAGS="$SAVE_CPPFLAGS"
+LDFLAGS="$SAVE_LDFLAGS"
+
+if test "x$with_libcredis" = "xyes"
+then
+       BUILD_WITH_LIBCREDIS_CPPFLAGS="$LIBCREDIS_CPPFLAGS"
+       BUILD_WITH_LIBCREDIS_LDFLAGS="$LIBCREDIS_LDFLAGS"
+       AC_SUBST(BUILD_WITH_LIBCREDIS_CPPFLAGS)
+       AC_SUBST(BUILD_WITH_LIBCREDIS_LDFLAGS)
+fi
+AM_CONDITIONAL(BUILD_WITH_LIBCREDIS, test "x$with_libcredis" = "xyes")
+# }}}
+
+# --with-libcurl {{{
+with_curl_config="curl-config"
+with_curl_cflags=""
+with_curl_libs=""
+AC_ARG_WITH(libcurl, [AS_HELP_STRING([--with-libcurl@<:@=PREFIX@:>@], [Path to libcurl.])],
+[
+       if test "x$withval" = "xno"
+       then
+               with_libcurl="no"
+       else if test "x$withval" = "xyes"
+       then
+               with_libcurl="yes"
+       else
+               if test -f "$withval" && test -x "$withval"
+               then
+                       with_curl_config="$withval"
+                       with_libcurl="yes"
+               else if test -x "$withval/bin/curl-config"
+               then
+                       with_curl_config="$withval/bin/curl-config"
+                       with_libcurl="yes"
+               fi; fi
+               with_libcurl="yes"
+       fi; fi
+],
+[
+       with_libcurl="yes"
+])
+if test "x$with_libcurl" = "xyes"
+then
+       with_curl_cflags=`$with_curl_config --cflags 2>/dev/null`
+       curl_config_status=$?
+
+       if test $curl_config_status -ne 0
+       then
+               with_libcurl="no ($with_curl_config failed)"
+       else
+               SAVE_CPPFLAGS="$CPPFLAGS"
+               CPPFLAGS="$CPPFLAGS $with_curl_cflags"
+
+               AC_CHECK_HEADERS(curl/curl.h, [], [with_libcurl="no (curl/curl.h not found)"], [])
+
+               CPPFLAGS="$SAVE_CPPFLAGS"
+       fi
+fi
+if test "x$with_libcurl" = "xyes"
+then
+       with_curl_libs=`$with_curl_config --libs 2>/dev/null`
+       curl_config_status=$?
+
+       if test $curl_config_status -ne 0
+       then
+               with_libcurl="no ($with_curl_config failed)"
+       else
+               AC_CHECK_LIB(curl, curl_easy_init,
+                [with_libcurl="yes"],
+                [with_libcurl="no (symbol 'curl_easy_init' not found)"],
+                [$with_curl_libs])
+       fi
+fi
+if test "x$with_libcurl" = "xyes"
+then
+       BUILD_WITH_LIBCURL_CFLAGS="$with_curl_cflags"
+       BUILD_WITH_LIBCURL_LIBS="$with_curl_libs"
+       AC_SUBST(BUILD_WITH_LIBCURL_CFLAGS)
+       AC_SUBST(BUILD_WITH_LIBCURL_LIBS)
+fi
+AM_CONDITIONAL(BUILD_WITH_LIBCURL, test "x$with_libcurl" = "xyes")
+# }}}
+
+# --with-libdbi {{{
+with_libdbi_cppflags=""
+with_libdbi_ldflags=""
+AC_ARG_WITH(libdbi, [AS_HELP_STRING([--with-libdbi@<:@=PREFIX@:>@], [Path to libdbi.])],
+[
+       if test "x$withval" != "xno" && test "x$withval" != "xyes"
+       then
+               with_libdbi_cppflags="-I$withval/include"
+               with_libdbi_ldflags="-L$withval/lib"
+               with_libdbi="yes"
+       else
+               with_libdbi="$withval"
+       fi
+],
+[
+       with_libdbi="yes"
+])
+if test "x$with_libdbi" = "xyes"
+then
+       SAVE_CPPFLAGS="$CPPFLAGS"
+       CPPFLAGS="$CPPFLAGS $with_libdbi_cppflags"
+
+       AC_CHECK_HEADERS(dbi/dbi.h, [with_libdbi="yes"], [with_libdbi="no (dbi/dbi.h not found)"])
+
+       CPPFLAGS="$SAVE_CPPFLAGS"
+fi
+if test "x$with_libdbi" = "xyes"
+then
+       SAVE_CPPFLAGS="$CPPFLAGS"
+       SAVE_LDFLAGS="$LDFLAGS"
+       CPPFLAGS="$CPPFLAGS $with_libdbi_cppflags"
+       LDFLAGS="$LDFLAGS $with_libdbi_ldflags"
+
+       AC_CHECK_LIB(dbi, dbi_initialize, [with_libdbi="yes"], [with_libdbi="no (Symbol 'dbi_initialize' not found)"])
+
+       CPPFLAGS="$SAVE_CPPFLAGS"
+       LDFLAGS="$SAVE_LDFLAGS"
+fi
+if test "x$with_libdbi" = "xyes"
+then
+       BUILD_WITH_LIBDBI_CPPFLAGS="$with_libdbi_cppflags"
+       BUILD_WITH_LIBDBI_LDFLAGS="$with_libdbi_ldflags"
+       BUILD_WITH_LIBDBI_LIBS="-ldbi"
+       AC_SUBST(BUILD_WITH_LIBDBI_CPPFLAGS)
+       AC_SUBST(BUILD_WITH_LIBDBI_LDFLAGS)
+       AC_SUBST(BUILD_WITH_LIBDBI_LIBS)
+fi
+AM_CONDITIONAL(BUILD_WITH_LIBDBI, test "x$with_libdbi" = "xyes")
+# }}}
+
+# --with-libesmtp {{{
+AC_ARG_WITH(libesmtp, [AS_HELP_STRING([--with-libesmtp@<:@=PREFIX@:>@], [Path to libesmtp.])],
+[
+       if test "x$withval" != "xno" && test "x$withval" != "xyes"
+       then
+               LDFLAGS="$LDFLAGS -L$withval/lib"
+               CPPFLAGS="$CPPFLAGS -I$withval/include -D_THREAD_SAFE"
+               with_libesmtp="yes"
+       else
+               with_libesmtp="$withval"
+       fi
+],
+[
+       with_libesmtp="yes"
+])
+if test "x$with_libesmtp" = "xyes"
+then
+       AC_CHECK_LIB(esmtp, smtp_create_session,
+       [
+               AC_DEFINE(HAVE_LIBESMTP, 1, [Define to 1 if you have the esmtp library (-lesmtp).])
+       ], [with_libesmtp="no (libesmtp not found)"])
+fi
+if test "x$with_libesmtp" = "xyes"
+then
+       AC_CHECK_HEADERS(libesmtp.h,
+       [
+               AC_DEFINE(HAVE_LIBESMTP_H, 1, [Define to 1 if you have the <libesmtp.h> header file.])
+       ], [with_libesmtp="no (libesmtp.h not found)"])
+fi
+if test "x$with_libesmtp" = "xyes"
+then
+       collect_libesmtp=1
+else
+       collect_libesmtp=0
+fi
+AC_DEFINE_UNQUOTED(COLLECT_LIBESMTP, [$collect_libesmtp],
+       [Wether or not to use the esmtp library])
+AM_CONDITIONAL(BUILD_WITH_LIBESMTP, test "x$with_libesmtp" = "xyes")
+# }}}
+
+# --with-libganglia {{{
+AC_ARG_WITH(libganglia, [AS_HELP_STRING([--with-libganglia@<:@=PREFIX@:>@], [Path to libganglia.])],
+[
+ if test -f "$withval" && test -x "$withval"
+ then
+        with_libganglia_config="$withval"
+        with_libganglia="yes"
+ else if test -f "$withval/bin/ganglia-config" && test -x "$withval/bin/ganglia-config"
+ then
+        with_libganglia_config="$withval/bin/ganglia-config"
+        with_libganglia="yes"
+ else if test -d "$withval"
+ then
+        GANGLIA_CPPFLAGS="-I$withval/include"
+        GANGLIA_LDFLAGS="-L$withval/lib"
+        with_libganglia="yes"
+ else
+        with_libganglia_config="ganglia-config"
+        with_libganglia="$withval"
+ fi; fi; fi
+],
+[
+ with_libganglia_config="ganglia-config"
+ with_libganglia="yes"
+])
+
+if test "x$with_libganglia" = "xyes" && test "x$with_libganglia_config" != "x"
+then
+       if test "x$GANGLIA_CPPFLAGS" = "x"
+       then
+               GANGLIA_CPPFLAGS=`"$with_libganglia_config" --cflags 2>/dev/null`
+       fi
+
+       if test "x$GANGLIA_LDFLAGS" = "x"
+       then
+               GANGLIA_LDFLAGS=`"$with_libganglia_config" --ldflags 2>/dev/null`
+       fi
+
+       if test "x$GANGLIA_LIBS" = "x"
+       then
+               GANGLIA_LIBS=`"$with_libganglia_config" --libs 2>/dev/null`
+       fi
+fi
+
+SAVE_CPPFLAGS="$CPPFLAGS"
+SAVE_LDFLAGS="$LDFLAGS"
+CPPFLAGS="$CPPFLAGS $GANGLIA_CPPFLAGS"
+LDFLAGS="$LDFLAGS $GANGLIA_LDFLAGS"
+
+if test "x$with_libganglia" = "xyes"
+then
+       AC_CHECK_HEADERS(gm_protocol.h,
+       [
+               AC_DEFINE(HAVE_GM_PROTOCOL_H, 1,
+                         [Define to 1 if you have the <gm_protocol.h> header file.])
+       ], [with_libganglia="no (gm_protocol.h not found)"])
+fi
+
+if test "x$with_libganglia" = "xyes"
+then
+       AC_CHECK_LIB(ganglia, xdr_Ganglia_value_msg,
+       [
+               AC_DEFINE(HAVE_LIBGANGLIA, 1,
+                         [Define to 1 if you have the ganglia library (-lganglia).])
+       ], [with_libganglia="no (symbol xdr_Ganglia_value_msg not found)"])
+fi
+
+CPPFLAGS="$SAVE_CPPFLAGS"
+LDFLAGS="$SAVE_LDFLAGS"
+
+AC_SUBST(GANGLIA_CPPFLAGS)
+AC_SUBST(GANGLIA_LDFLAGS)
+AC_SUBST(GANGLIA_LIBS)
+AM_CONDITIONAL(BUILD_WITH_LIBGANGLIA, test "x$with_libganglia" = "xyes")
+# }}}
+
+# --with-libgcrypt {{{
+GCRYPT_CPPFLAGS="$GCRYPT_CPPFLAGS"
+GCRYPT_LDFLAGS="$GCRYPT_LDFLAGS"
+GCRYPT_LIBS="$GCRYPT_LIBS"
+AC_ARG_WITH(libgcrypt, [AS_HELP_STRING([--with-libgcrypt@<:@=PREFIX@:>@], [Path to libgcrypt.])],
+[
+ if test -f "$withval" && test -x "$withval"
+ then
+        with_libgcrypt_config="$withval"
+        with_libgcrypt="yes"
+ else if test -f "$withval/bin/gcrypt-config" && test -x "$withval/bin/gcrypt-config"
+ then
+        with_libgcrypt_config="$withval/bin/gcrypt-config"
+        with_libgcrypt="yes"
+ else if test -d "$withval"
+ then
+        GCRYPT_CPPFLAGS="$GCRYPT_CPPFLAGS -I$withval/include"
+        GCRYPT_LDFLAGS="$GCRYPT_LDFLAGS -L$withval/lib"
+        with_libgcrypt="yes"
+ else
+        with_libgcrypt_config="gcrypt-config"
+        with_libgcrypt="$withval"
+ fi; fi; fi
+],
+[
+ with_libgcrypt_config="libgcrypt-config"
+ with_libgcrypt="yes"
+])
+
+if test "x$with_libgcrypt" = "xyes" && test "x$with_libgcrypt_config" != "x"
+then
+       if test "x$GCRYPT_CPPFLAGS" = "x"
+       then
+               GCRYPT_CPPFLAGS=`"$with_libgcrypt_config" --cflags 2>/dev/null`
+       fi
+
+       if test "x$GCRYPT_LDFLAGS" = "x"
+       then
+               gcrypt_exec_prefix=`"$with_libgcrypt_config" --exec-prefix 2>/dev/null`
+               GCRYPT_LDFLAGS="-L$gcrypt_exec_prefix/lib"
+       fi
+
+       if test "x$GCRYPT_LIBS" = "x"
+       then
+               GCRYPT_LIBS=`"$with_libgcrypt_config" --libs 2>/dev/null`
+       fi
+fi
+
+SAVE_CPPFLAGS="$CPPFLAGS"
+SAVE_LDFLAGS="$LDFLAGS"
+CPPFLAGS="$CPPFLAGS $GCRYPT_CPPFLAGS"
+LDFLAGS="$LDFLAGS $GCRYPT_LDFLAGS"
+
+if test "x$with_libgcrypt" = "xyes"
+then
+       if test "x$GCRYPT_CPPFLAGS" != "x"
+       then
+               AC_MSG_NOTICE([gcrypt CPPFLAGS: $GCRYPT_CPPFLAGS])
+       fi
+       AC_CHECK_HEADERS(gcrypt.h,
+               [with_libgcrypt="yes"],
+               [with_libgcrypt="no (gcrypt.h not found)"])
+fi
+
+if test "x$with_libgcrypt" = "xyes"
+then
+       if test "x$GCRYPT_LDFLAGS" != "x"
+       then
+               AC_MSG_NOTICE([gcrypt LDFLAGS: $GCRYPT_LDFLAGS])
+       fi
+       AC_CHECK_LIB(gcrypt, gcry_md_hash_buffer,
+               [with_libgcrypt="yes"],
+               [with_libgcrypt="no (symbol gcry_md_hash_buffer not found)"])
+
+       if test "$with_libgcrypt" != "no"; then
+               AM_PATH_LIBGCRYPT(1:1.2.0,,with_libgcrypt="no (version 1.2.0+ required)")
+               GCRYPT_CPPFLAGS="$LIBGCRYPT_CPPFLAGS $LIBGCRYPT_CFLAGS"
+               GCRYPT_LIBS="$LIBGCRYPT_LIBS"
+       fi
+fi
+
+CPPFLAGS="$SAVE_CPPFLAGS"
+LDFLAGS="$SAVE_LDFLAGS"
+
+if test "x$with_libgcrypt" = "xyes"
+then
+       AC_DEFINE(HAVE_LIBGCRYPT, 1, [Define to 1 if you have the gcrypt library (-lgcrypt).])
+fi
+
+AC_SUBST(GCRYPT_CPPFLAGS)
+AC_SUBST(GCRYPT_LDFLAGS)
+AC_SUBST(GCRYPT_LIBS)
+AM_CONDITIONAL(BUILD_WITH_LIBGCRYPT, test "x$with_libgcrypt" = "xyes")
+# }}}
+
+# --with-libiptc {{{
+AC_ARG_WITH(libiptc, [AS_HELP_STRING([--with-libiptc@<:@=PREFIX@:>@], [Path to libiptc.])],
+[
+       if test "x$withval" = "xshipped"
+       then
+               with_libiptc="own"
+       else if test "x$withval" = "xyes"
+       then
+               with_libiptc="pkgconfig"
+       else if test "x$withval" = "xno"
+       then
+               with_libiptc="no"
+       else
+               with_libiptc="yes"
+               with_libiptc_cflags="-I$withval/include"
+               with_libiptc_libs="-L$withval/lib"
+       fi; fi; fi
+],
+[
+       if test "x$ac_system" = "xLinux"
+       then
+               with_libiptc="pkgconfig"
+       else
+               with_libiptc="no (Linux only)"
+       fi
+])
+
+if test "x$with_libiptc" = "xpkgconfig" && test "x$PKG_CONFIG" = "x"
+then
+       with_libiptc="no (Don't have pkg-config)"
+fi
+
+if test "x$with_libiptc" = "xpkgconfig"
+then
+       $PKG_CONFIG --exists 'libiptc' 2>/dev/null
+       if test $? -ne 0
+       then
+               with_libiptc="no (pkg-config doesn't know libiptc)"
+       fi
+fi
+if test "x$with_libiptc" = "xpkgconfig"
+then
+       with_libiptc_cflags="`$PKG_CONFIG --cflags 'libiptc'`"
+       if test $? -ne 0
+       then
+               with_libiptc="no ($PKG_CONFIG failed)"
+       fi
+       with_libiptc_libs="`$PKG_CONFIG --libs 'libiptc'`"
+       if test $? -ne 0
+       then
+               with_libiptc="no ($PKG_CONFIG failed)"
+       fi
+fi
+
+SAVE_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS $with_libiptc_cflags"
+
+# check whether the header file for libiptc is available.
+if test "x$with_libiptc" = "xpkgconfig"
+then
+       AC_CHECK_HEADERS(libiptc/libiptc.h libiptc/libip6tc.h, ,
+                       [with_libiptc="no (header file missing)"])
+fi
+# If the header file is available, check for the required type declaractions.
+# They may be missing in old versions of libiptc. In that case, they will be
+# declared in the iptables plugin.
+if test "x$with_libiptc" = "xpkgconfig"
+then
+       AC_CHECK_TYPES([iptc_handle_t, ip6tc_handle_t], [], [])
+fi
+# Check for the iptc_init symbol in the library.
+# This could be in iptc or ip4tc
+if test "x$with_libiptc" = "xpkgconfig"
+then
+       SAVE_LIBS="$LIBS"
+       AC_SEARCH_LIBS(iptc_init, [iptc ip4tc],
+                       [with_libiptc="pkgconfig"],
+                       [with_libiptc="no"],
+                       [$with_libiptc_libs])
+       LIBS="$SAVE_LIBS"
+fi
+if test "x$with_libiptc" = "xpkgconfig"
+then
+       with_libiptc="yes"
+fi
+
+CPPFLAGS="$SAVE_CPPFLAGS"
+
+if test "x$with_libiptc" = "xown"
+then
+       with_libiptc_cflags=""
+       with_libiptc_libs=""
+fi
+if test "x$with_libiptc" = "xown"
+then
+       AC_CHECK_HEADERS(linux/netfilter_ipv4/ip_tables.h linux/netfilter_ipv6/ip6_tables.h linux/netfilter/x_tables.h, [],
+       [
+               with_libiptc="no (Linux iptables headers not found)"
+       ],
+       [
+#include "$srcdir/src/owniptc/ipt_kernel_headers.h"
+       ])
+fi
+AM_CONDITIONAL(BUILD_WITH_OWN_LIBIPTC, test "x$with_libiptc" = "xown")
+if test "x$with_libiptc" = "xown"
+then
+       AC_DEFINE(OWN_LIBIPTC, 1, [Define to 1 if we use the shipped iptc library.])
+       with_libiptc="yes"
+fi
+
+AM_CONDITIONAL(BUILD_WITH_LIBIPTC, test "x$with_libiptc" = "xyes")
+if test "x$with_libiptc" = "xyes"
+then
+       BUILD_WITH_LIBIPTC_CPPFLAGS="$with_libiptc_cflags"
+       BUILD_WITH_LIBIPTC_LDFLAGS="$with_libiptc_libs"
+       AC_SUBST(BUILD_WITH_LIBIPTC_CPPFLAGS)
+       AC_SUBST(BUILD_WITH_LIBIPTC_LDFLAGS)
+fi
+# }}}
+
+# --with-java {{{
+with_java_home="$JAVA_HOME"
+with_java_vmtype="client"
+with_java_cflags=""
+with_java_libs=""
+JAVAC="$JAVAC"
+JAR="$JAR"
+AC_ARG_WITH(java, [AS_HELP_STRING([--with-java@<:@=PREFIX@:>@], [Path to Java home.])],
+[
+       if test "x$withval" = "xno"
+       then
+               with_java="no"
+       else if test "x$withval" = "xyes"
+       then
+               with_java="yes"
+       else
+               with_java_home="$withval"
+               with_java="yes"
+       fi; fi
+],
+[with_java="yes"])
+if test "x$with_java" = "xyes"
+then
+       if test -d "$with_java_home"
+       then
+               AC_MSG_CHECKING([for jni.h])
+               TMPVAR=`find "$with_java_home" -name jni.h -type f -exec 'dirname' '{}' ';' 2>/dev/null | head -n 1`
+               if test "x$TMPVAR" != "x"
+               then
+                       AC_MSG_RESULT([found in $TMPVAR])
+                       JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPVAR"
+               else
+                       AC_MSG_RESULT([not found])
+               fi
+
+               AC_MSG_CHECKING([for jni_md.h])
+               TMPVAR=`find "$with_java_home" -name jni_md.h -type f -exec 'dirname' '{}' ';' 2>/dev/null | head -n 1`
+               if test "x$TMPVAR" != "x"
+               then
+                       AC_MSG_RESULT([found in $TMPVAR])
+                       JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPVAR"
+               else
+                       AC_MSG_RESULT([not found])
+               fi
+
+               AC_MSG_CHECKING([for libjvm.so])
+               TMPVAR=`find "$with_java_home" -name libjvm.so -type f -exec 'dirname' '{}' ';' 2>/dev/null | head -n 1`
+               if test "x$TMPVAR" != "x"
+               then
+                       AC_MSG_RESULT([found in $TMPVAR])
+                       JAVA_LDFLAGS="$JAVA_LDFLAGS -L$TMPVAR -Wl,-rpath -Wl,$TMPVAR"
+               else
+                       AC_MSG_RESULT([not found])
+               fi
+
+               if test "x$JAVAC" = "x"
+               then
+                       AC_MSG_CHECKING([for javac])
+                       TMPVAR=`find "$with_java_home" -name javac -type f 2>/dev/null | head -n 1`
+                       if test "x$TMPVAR" != "x"
+                       then
+                               JAVAC="$TMPVAR"
+                               AC_MSG_RESULT([$JAVAC])
+                       else
+                               AC_MSG_RESULT([not found])
+                       fi
+               fi
+               if test "x$JAR" = "x"
+               then
+                       AC_MSG_CHECKING([for jar])
+                       TMPVAR=`find "$with_java_home" -name jar -type f 2>/dev/null | head -n 1`
+                       if test "x$TMPVAR" != "x"
+                       then
+                               JAR="$TMPVAR"
+                               AC_MSG_RESULT([$JAR])
+                       else
+                               AC_MSG_RESULT([not found])
+                       fi
+               fi
+       else if test "x$with_java_home" != "x"
+       then
+               AC_MSG_WARN([JAVA_HOME: No such directory: $with_java_home])
+       fi; fi
+fi
+
+if test "x$JAVA_CPPFLAGS" != "x"
+then
+       AC_MSG_NOTICE([Building with JAVA_CPPFLAGS set to: $JAVA_CPPFLAGS])
+fi
+if test "x$JAVA_CFLAGS" != "x"
+then
+       AC_MSG_NOTICE([Building with JAVA_CFLAGS set to: $JAVA_CFLAGS])
+fi
+if test "x$JAVA_LDFLAGS" != "x"
+then
+       AC_MSG_NOTICE([Building with JAVA_LDFLAGS set to: $JAVA_LDFLAGS])
+fi
+if test "x$JAVAC" = "x"
+then
+       with_javac_path="$PATH"
+       if test "x$with_java_home" != "x"
+       then
+               with_javac_path="$with_java_home:with_javac_path"
+               if test -d "$with_java_home/bin"
+               then
+                       with_javac_path="$with_java_home/bin:with_javac_path"
+               fi
+       fi
+
+       AC_PATH_PROG(JAVAC, javac, [], "$with_javac_path")
+fi
+if test "x$JAVAC" = "x"
+then
+       with_java="no (javac not found)"
+fi
+if test "x$JAR" = "x"
+then
+       with_jar_path="$PATH"
+       if test "x$with_java_home" != "x"
+       then
+               with_jar_path="$with_java_home:$with_jar_path"
+               if test -d "$with_java_home/bin"
+               then
+                       with_jar_path="$with_java_home/bin:$with_jar_path"
+               fi
+       fi
+
+       AC_PATH_PROG(JAR, jar, [], "$with_jar_path")
+fi
+if test "x$JAR" = "x"
+then
+       with_java="no (jar not found)"
+fi
+
+SAVE_CPPFLAGS="$CPPFLAGS"
+SAVE_CFLAGS="$CFLAGS"
+SAVE_LDFLAGS="$LDFLAGS"
+CPPFLAGS="$CPPFLAGS $JAVA_CPPFLAGS"
+CFLAGS="$CFLAGS $JAVA_CFLAGS"
+LDFLAGS="$LDFLAGS $JAVA_LDFLAGS"
+
+if test "x$with_java" = "xyes"
+then
+       AC_CHECK_HEADERS(jni.h, [], [with_java="no (jni.h not found)"])
+fi
+if test "x$with_java" = "xyes"
+then
+       AC_CHECK_LIB(jvm, JNI_CreateJavaVM,
+       [with_java="yes"],
+       [with_java="no (libjvm not found)"],
+       [$JAVA_LIBS])
+fi
+if test "x$with_java" = "xyes"
+then
+       JAVA_LIBS="$JAVA_LIBS -ljvm"
+       AC_MSG_NOTICE([Building with JAVA_LIBS set to: $JAVA_LIBS])
+fi
+
+CPPFLAGS="$SAVE_CPPFLAGS"
+CFLAGS="$SAVE_CFLAGS"
+LDFLAGS="$SAVE_LDFLAGS"
+
+AC_SUBST(JAVA_CPPFLAGS)
+AC_SUBST(JAVA_CFLAGS)
+AC_SUBST(JAVA_LDFLAGS)
+AC_SUBST(JAVA_LIBS)
+AM_CONDITIONAL(BUILD_WITH_JAVA, test "x$with_java" = "xyes")
+# }}}
+
+# --with-liblvm2app {{{
+with_liblvm2app_cppflags=""
+with_liblvm2app_ldflags=""
+AC_ARG_WITH(liblvm2app, [AS_HELP_STRING([--with-liblvm2app@<:@=PREFIX@:>@], [Path to liblvm2app.])],
+[
+        if test "x$withval" != "xno" && test "x$withval" != "xyes"
+        then
+                with_liblvm2app_cppflags="-I$withval/include"
+                with_liblvm2app_ldflags="-L$withval/lib"
+                with_liblvm2app="yes"
+        else
+                with_liblvm2app="$withval"
+        fi
+],
+[
+        with_liblvm2app="yes"
+])
+if test "x$with_liblvm2app" = "xyes"
+then
+        SAVE_CPPFLAGS="$CPPFLAGS"
+        CPPFLAGS="$CPPFLAGS $with_liblvm2app_cppflags"
+
+        AC_CHECK_HEADERS(lvm2app.h, [with_liblvm2app="yes"], [with_liblvm2app="no (lvm2app.h not found)"])
+
+        CPPFLAGS="$SAVE_CPPFLAGS"
+fi
+
+if test "x$with_liblvm2app" = "xyes"
+then
+        SAVE_CPPFLAGS="$CPPFLAGS"
+        SAVE_LDFLAGS="$LDFLAGS"
+        CPPFLAGS="$CPPFLAGS $with_liblvm2app_cppflags"
+        LDFLAGS="$LDFLAGS $with_liblvm2app_ldflags"
+
+        AC_CHECK_LIB(lvm2app, lvm_init, [with_liblvm2app="yes"], [with_liblvm2app="no (Symbol 'lvm_init' not found)"])
+
+        CPPFLAGS="$SAVE_CPPFLAGS"
+        LDFLAGS="$SAVE_LDFLAGS"
+fi
+if test "x$with_liblvm2app" = "xyes"
+then
+        BUILD_WITH_LIBLVM2APP_CPPFLAGS="$with_liblvm2app_cppflags"
+        BUILD_WITH_LIBLVM2APP_LDFLAGS="$with_liblvm2app_ldflags"
+        BUILD_WITH_LIBLVM2APP_LIBS="-llvm2app"
+        AC_SUBST(BUILD_WITH_LIBLVM2APP_CPPFLAGS)
+        AC_SUBST(BUILD_WITH_LIBLVM2APP_LDFLAGS)
+        AC_SUBST(BUILD_WITH_LIBLVM2APP_LIBS)
+        AC_DEFINE(HAVE_LIBLVM2APP, 1, [Define if liblvm2app is present and usable.])
+fi
+AM_CONDITIONAL(BUILD_WITH_LIBLVM2APP, test "x$with_liblvm2app" = "xyes")
+# }}}
+
+# --with-libmemcached {{{
+with_libmemcached_cppflags=""
+with_libmemcached_ldflags=""
+AC_ARG_WITH(libmemcached, [AS_HELP_STRING([--with-libmemcached@<:@=PREFIX@:>@], [Path to libmemcached.])],
+[
+       if test "x$withval" != "xno" && test "x$withval" != "xyes"
+       then
+               with_libmemcached_cppflags="-I$withval/include"
+               with_libmemcached_ldflags="-L$withval/lib"
+               with_libmemcached="yes"
+       else
+               with_libmemcached="$withval"
+       fi
+],
+[
+       with_libmemcached="yes"
+])
+if test "x$with_libmemcached" = "xyes"
+then
+       SAVE_CPPFLAGS="$CPPFLAGS"
+       CPPFLAGS="$CPPFLAGS $with_libmemcached_cppflags"
+
+       AC_CHECK_HEADERS(libmemcached/memcached.h, [with_libmemcached="yes"], [with_libmemcached="no (libmemcached/memcached.h not found)"])
+
+       CPPFLAGS="$SAVE_CPPFLAGS"
+fi
+if test "x$with_libmemcached" = "xyes"
+then
+       SAVE_CPPFLAGS="$CPPFLAGS"
+       SAVE_LDFLAGS="$LDFLAGS"
+       CPPFLAGS="$CPPFLAGS $with_libmemcached_cppflags"
+       LDFLAGS="$LDFLAGS $with_libmemcached_ldflags"
+
+       AC_CHECK_LIB(memcached, memcached_create, [with_libmemcached="yes"], [with_libmemcached="no (Symbol 'memcached_create' not found)"])
+
+       CPPFLAGS="$SAVE_CPPFLAGS"
+       LDFLAGS="$SAVE_LDFLAGS"
+fi
+if test "x$with_libmemcached" = "xyes"
+then
+       BUILD_WITH_LIBMEMCACHED_CPPFLAGS="$with_libmemcached_cppflags"
+       BUILD_WITH_LIBMEMCACHED_LDFLAGS="$with_libmemcached_ldflags"
+       BUILD_WITH_LIBMEMCACHED_LIBS="-lmemcached"
+       AC_SUBST(BUILD_WITH_LIBMEMCACHED_CPPFLAGS)
+       AC_SUBST(BUILD_WITH_LIBMEMCACHED_LDFLAGS)
+       AC_SUBST(BUILD_WITH_LIBMEMCACHED_LIBS)
+       AC_DEFINE(HAVE_LIBMEMCACHED, 1, [Define if libmemcached is present and usable.])
+fi
+AM_CONDITIONAL(BUILD_WITH_LIBMEMCACHED, test "x$with_libmemcached" = "xyes")
+# }}}
+
+# --with-libmodbus {{{
+with_libmodbus_config=""
+with_libmodbus_cflags=""
+with_libmodbus_libs=""
+AC_ARG_WITH(libmodbus, [AS_HELP_STRING([--with-libmodbus@<:@=PREFIX@:>@], [Path to the modbus library.])],
+[
+       if test "x$withval" = "xno"
+       then
+               with_libmodbus="no"
+       else if test "x$withval" = "xyes"
+       then
+               with_libmodbus="use_pkgconfig"
+       else if test -d "$with_libmodbus/lib"
+       then
+               AC_MSG_NOTICE([Not checking for libmodbus: Manually configured])
+               with_libmodbus_cflags="-I$withval/include"
+               with_libmodbus_libs="-L$withval/lib -lmodbus"
+               with_libmodbus="yes"
+       fi; fi; fi
+],
+[with_libmodbus="use_pkgconfig"])
+
+# configure using pkg-config
+if test "x$with_libmodbus" = "xuse_pkgconfig"
+then
+       if test "x$PKG_CONFIG" = "x"
+       then
+               with_libmodbus="no (Don't have pkg-config)"
+       fi
+fi
+if test "x$with_libmodbus" = "xuse_pkgconfig"
+then
+       AC_MSG_NOTICE([Checking for libmodbus using $PKG_CONFIG])
+       $PKG_CONFIG --exists 'libmodbus' 2>/dev/null
+       if test $? -ne 0
+       then
+               with_libmodbus="no (pkg-config doesn't know libmodbus)"
+       fi
+fi
+if test "x$with_libmodbus" = "xuse_pkgconfig"
+then
+       with_libmodbus_cflags="`$PKG_CONFIG --cflags 'libmodbus'`"
+       if test $? -ne 0
+       then
+               with_libmodbus="no ($PKG_CONFIG failed)"
+       fi
+       with_libmodbus_libs="`$PKG_CONFIG --libs 'libmodbus'`"
+       if test $? -ne 0
+       then
+               with_libmodbus="no ($PKG_CONFIG failed)"
+       fi
+fi
+if test "x$with_libmodbus" = "xuse_pkgconfig"
+then
+       with_libmodbus="yes"
+fi
+
+# with_libmodbus_cflags and with_libmodbus_libs are set up now, let's do
+# the actual checks.
+if test "x$with_libmodbus" = "xyes"
+then
+       SAVE_CPPFLAGS="$CPPFLAGS"
+       CPPFLAGS="$CPPFLAGS $with_libmodbus_cflags"
+
+       AC_CHECK_HEADERS(modbus/modbus.h, [], [with_libmodbus="no (modbus/modbus.h not found)"])
+
+       CPPFLAGS="$SAVE_CPPFLAGS"
+fi
+if test "x$with_libmodbus" = "xyes"
+then
+       SAVE_CPPFLAGS="$CPPFLAGS"
+       SAVE_LDFLAGS="$LDFLAGS"
+
+       CPPFLAGS="$CPPFLAGS $with_libmodbus_cflags"
+       LDFLAGS="$LDFLAGS $with_libmodbus_libs"
+
+       AC_CHECK_LIB(modbus, modbus_connect,
+                    [with_libmodbus="yes"],
+                    [with_libmodbus="no (symbol modbus_connect not found)"])
+
+       CPPFLAGS="$SAVE_CPPFLAGS"
+       LDFLAGS="$SAVE_LDFLAGS"
+fi
+if test "x$with_libmodbus" = "xyes"
+then
+       BUILD_WITH_LIBMODBUS_CFLAGS="$with_libmodbus_cflags"
+       BUILD_WITH_LIBMODBUS_LIBS="$with_libmodbus_libs"
+       AC_SUBST(BUILD_WITH_LIBMODBUS_CFLAGS)
+       AC_SUBST(BUILD_WITH_LIBMODBUS_LIBS)
+fi
+# }}}
+
+# --with-libmongoc {{{
+AC_ARG_WITH(libmongoc, [AS_HELP_STRING([--with-libmongoc@<:@=PREFIX@:>@], [Path to libmongoc.])],
+[
+ if test "x$withval" = "xyes"
+ then
+        with_libmongoc="yes"
+ else if test "x$withval" = "xno"
+ then
+        with_libmongoc="no"
+ else
+        with_libmongoc="yes"
+        LIBMONGOC_CPPFLAGS="$LIBMONGOC_CPPFLAGS -I$withval/include"
+        LIBMONGOC_LDFLAGS="$LIBMONGOC_LDFLAGS -L$withval/lib"
+ fi; fi
+],
+[with_libmongoc="yes"])
+
+SAVE_CPPFLAGS="$CPPFLAGS"
+SAVE_LDFLAGS="$LDFLAGS"
+
+CPPFLAGS="$CPPFLAGS $LIBMONGOC_CPPFLAGS"
+LDFLAGS="$LDFLAGS $LIBMONGOC_LDFLAGS"
+
+if test "x$with_libmongoc" = "xyes"
+then
+       if test "x$LIBMONGOC_CPPFLAGS" != "x"
+       then
+               AC_MSG_NOTICE([libmongoc CPPFLAGS: $LIBMONGOC_CPPFLAGS])
+       fi
+       AC_CHECK_HEADERS(mongo.h,
+       [with_libmongoc="yes"],
+       [with_libmongoc="no ('mongo.h' not found)"],
+[#if HAVE_STDINT_H
+# define MONGO_HAVE_STDINT 1
+#else
+# define MONGO_USE_LONG_LONG_INT 1
+#endif
+])
+fi
+if test "x$with_libmongoc" = "xyes"
+then
+       if test "x$LIBMONGOC_LDFLAGS" != "x"
+       then
+               AC_MSG_NOTICE([libmongoc LDFLAGS: $LIBMONGOC_LDFLAGS])
+       fi
+       AC_CHECK_LIB(mongoc, mongo_run_command,
+       [with_libmongoc="yes"],
+       [with_libmongoc="no (symbol 'mongo_run_command' not found)"])
+fi
+
+CPPFLAGS="$SAVE_CPPFLAGS"
+LDFLAGS="$SAVE_LDFLAGS"
+
+if test "x$with_libmongoc" = "xyes"
+then
+       BUILD_WITH_LIBMONGOC_CPPFLAGS="$LIBMONGOC_CPPFLAGS"
+       BUILD_WITH_LIBMONGOC_LDFLAGS="$LIBMONGOC_LDFLAGS"
+       AC_SUBST(BUILD_WITH_LIBMONGOC_CPPFLAGS)
+       AC_SUBST(BUILD_WITH_LIBMONGOC_LDFLAGS)
+fi
+AM_CONDITIONAL(BUILD_WITH_LIBMONGOC, test "x$with_libmongoc" = "xyes")
+# }}}
+
+# --with-libmysql {{{
+with_mysql_config="mysql_config"
+with_mysql_cflags=""
+with_mysql_libs=""
+AC_ARG_WITH(libmysql, [AS_HELP_STRING([--with-libmysql@<:@=PREFIX@:>@], [Path to libmysql.])],
+[
+       if test "x$withval" = "xno"
+       then
+               with_libmysql="no"
+       else if test "x$withval" = "xyes"
+       then
+               with_libmysql="yes"
+       else
+               if test -f "$withval" && test -x "$withval";
+               then
+                       with_mysql_config="$withval"
+               else if test -x "$withval/bin/mysql_config"
+               then
+                       with_mysql_config="$withval/bin/mysql_config"
+               fi; fi
+               with_libmysql="yes"
+       fi; fi
+],
+[
+       with_libmysql="yes"
+])
+if test "x$with_libmysql" = "xyes"
+then
+       with_mysql_cflags=`$with_mysql_config --cflags 2>/dev/null`
+       mysql_config_status=$?
+
+       if test $mysql_config_status -ne 0
+       then
+               with_libmysql="no ($with_mysql_config failed)"
+       else
+               SAVE_CPPFLAGS="$CPPFLAGS"
+               CPPFLAGS="$CPPFLAGS $with_mysql_cflags"
+
+               have_mysql_h="no"
+               have_mysql_mysql_h="no"
+               AC_CHECK_HEADERS(mysql.h, [have_mysql_h="yes"])
+
+               if test "x$have_mysql_h" = "xno"
+               then
+                       AC_CHECK_HEADERS(mysql/mysql.h, [have_mysql_mysql_h="yes"])
+               fi
+
+               if test "x$have_mysql_h$have_mysql_mysql_h" = "xnono"
+               then
+                       with_libmysql="no (mysql.h not found)"
+               fi
+
+               CPPFLAGS="$SAVE_CPPFLAGS"
+       fi
+fi
+if test "x$with_libmysql" = "xyes"
+then
+       with_mysql_libs=`$with_mysql_config --libs_r 2>/dev/null`
+       mysql_config_status=$?
+
+       if test $mysql_config_status -ne 0
+       then
+               with_libmysql="no ($with_mysql_config failed)"
+       else
+               AC_CHECK_LIB(mysqlclient, mysql_init,
+                [with_libmysql="yes"],
+                [with_libmysql="no (symbol 'mysql_init' not found)"],
+                [$with_mysql_libs])
+
+               AC_CHECK_LIB(mysqlclient, mysql_get_server_version,
+                [with_libmysql="yes"],
+                [with_libmysql="no (symbol 'mysql_get_server_version' not found)"],
+                [$with_mysql_libs])
+       fi
+fi
+if test "x$with_libmysql" = "xyes"
+then
+       BUILD_WITH_LIBMYSQL_CFLAGS="$with_mysql_cflags"
+       BUILD_WITH_LIBMYSQL_LIBS="$with_mysql_libs"
+       AC_SUBST(BUILD_WITH_LIBMYSQL_CFLAGS)
+       AC_SUBST(BUILD_WITH_LIBMYSQL_LIBS)
+fi
+AM_CONDITIONAL(BUILD_WITH_LIBMYSQL, test "x$with_libmysql" = "xyes")
+# }}}
+
+# --with-libmnl {{{
+with_libmnl_cflags=""
+with_libmnl_libs=""
+AC_ARG_WITH(libmnl, [AS_HELP_STRING([--with-libmnl@<:@=PREFIX@:>@], [Path to libmnl.])],
+[
+ echo "libmnl: withval = $withval"
+ if test "x$withval" = "xyes"
+ then
+        with_libmnl="yes"
+ else if test "x$withval" = "xno"
+ then
+        with_libmnl="no"
+ else
+        if test -d "$withval/include"
+        then
+                with_libmnl_cflags="-I$withval/include"
+                with_libmnl_libs="-L$withval/lib -lmnl"
+                with_libmnl="yes"
+        else
+                AC_MSG_ERROR("no such directory: $withval/include")
+        fi
+ fi; fi
+],
+[
+ if test "x$ac_system" = "xLinux"
+ then
+        with_libmnl="yes"
+ else
+        with_libmnl="no (Linux only library)"
+ fi
+])
+if test "x$PKG_CONFIG" = "x"
+then
+       with_libmnl="no (Don't have pkg-config)"
+fi
+if test "x$with_libmnl" = "xyes"
+then
+       if $PKG_CONFIG --exists libmnl 2>/dev/null; then
+         with_libmnl_cflags="$with_libmnl_ldflags `$PKG_CONFIG --cflags libmnl`"
+         with_libmnl_libs="$with_libmnl_libs `$PKG_CONFIG --libs libmnl`"
+       fi
+
+       AC_CHECK_HEADERS(libmnl.h libmnl/libmnl.h,
+       [
+        with_libmnl="yes"
+        break
+       ], [],
+[#include <stdio.h>
+#include <sys/types.h>
+#include <asm/types.h>
+#include <sys/socket.h>
+#include <linux/netlink.h>
+#include <linux/rtnetlink.h>])
+       AC_CHECK_HEADERS(linux/gen_stats.h linux/pkt_sched.h, [], [],
+[#include <stdio.h>
+#include <sys/types.h>
+#include <asm/types.h>
+#include <sys/socket.h>])
+
+        AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+[[
+#include <stdio.h>
+#include <sys/types.h>
+#include <asm/types.h>
+#include <sys/socket.h>
+#include <linux/netlink.h>
+#include <linux/rtnetlink.h>
+]],
+[[
+int retval = TCA_STATS2;
+return (retval);
+]]
+       )],
+       [AC_DEFINE([HAVE_TCA_STATS2], [1], [True if the enum-member TCA_STATS2 exists])])
+
+       AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+[[
+#include <stdio.h>
+#include <sys/types.h>
+#include <asm/types.h>
+#include <sys/socket.h>
+#include <linux/netlink.h>
+#include <linux/rtnetlink.h>
+]],
+[[
+int retval = TCA_STATS;
+return (retval);
+]]
+       )],
+       [AC_DEFINE([HAVE_TCA_STATS], 1, [True if the enum-member TCA_STATS exists])])
+fi
+if test "x$with_libmnl" = "xyes"
+then
+       AC_CHECK_MEMBERS([struct rtnl_link_stats64.tx_window_errors],
+       [AC_DEFINE(HAVE_RTNL_LINK_STATS64, 1, [Define if struct rtnl_link_stats64 exists and is usable.])],
+       [],
+       [
+       #include <linux/if_link.h>
+       ])
+fi
+if test "x$with_libmnl" = "xyes"
+then
+       AC_CHECK_LIB(mnl, mnl_nlmsg_get_payload,
+                    [with_libmnl="yes"],
+                    [with_libmnl="no (symbol 'mnl_nlmsg_get_payload' not found)"],
+                    [$with_libmnl_libs])
+fi
+if test "x$with_libmnl" = "xyes"
+then
+       AC_DEFINE(HAVE_LIBMNL, 1, [Define if libmnl is present and usable.])
+       BUILD_WITH_LIBMNL_CFLAGS="$with_libmnl_cflags"
+       BUILD_WITH_LIBMNL_LIBS="$with_libmnl_libs"
+       AC_SUBST(BUILD_WITH_LIBMNL_CFLAGS)
+       AC_SUBST(BUILD_WITH_LIBMNL_LIBS)
+fi
+AM_CONDITIONAL(BUILD_WITH_LIBMNL, test "x$with_libmnl" = "xyes")
+# }}}
+
+# --with-libnetapp {{{
+AC_ARG_VAR([LIBNETAPP_CPPFLAGS], [C preprocessor flags required to build with libnetapp])
+AC_ARG_VAR([LIBNETAPP_LDFLAGS],  [Linker flags required to build with libnetapp])
+AC_ARG_VAR([LIBNETAPP_LIBS],     [Other libraries required to link against libnetapp])
+LIBNETAPP_CPPFLAGS="$LIBNETAPP_CPPFLAGS"
+LIBNETAPP_LDFLAGS="$LIBNETAPP_LDFLAGS"
+LIBNETAPP_LIBS="$LIBNETAPP_LIBS"
+AC_ARG_WITH(libnetapp, [AS_HELP_STRING([--with-libnetapp@<:@=PREFIX@:>@], [Path to libnetapp.])],
+[
+ if test -d "$withval"
+ then
+        LIBNETAPP_CPPFLAGS="$LIBNETAPP_CPPFLAGS -I$withval/include"
+        LIBNETAPP_LDFLAGS="$LIBNETAPP_LDFLAGS -L$withval/lib"
+        with_libnetapp="yes"
+ else
+        with_libnetapp="$withval"
+ fi
+],
+[
+ with_libnetapp="yes"
+])
+
+SAVE_CPPFLAGS="$CPPFLAGS"
+SAVE_LDFLAGS="$LDFLAGS"
+CPPFLAGS="$CPPFLAGS $LIBNETAPP_CPPFLAGS"
+LDFLAGS="$LDFLAGS $LIBNETAPP_LDFLAGS"
+
+if test "x$with_libnetapp" = "xyes"
+then
+       if test "x$LIBNETAPP_CPPFLAGS" != "x"
+       then
+               AC_MSG_NOTICE([netapp CPPFLAGS: $LIBNETAPP_CPPFLAGS])
+       fi
+       AC_CHECK_HEADERS(netapp_api.h,
+               [with_libnetapp="yes"],
+               [with_libnetapp="no (netapp_api.h not found)"])
+fi
+
+if test "x$with_libnetapp" = "xyes"
+then
+       if test "x$LIBNETAPP_LDFLAGS" != "x"
+       then
+               AC_MSG_NOTICE([netapp LDFLAGS: $LIBNETAPP_LDFLAGS])
+       fi
+
+       if test "x$LIBNETAPP_LIBS" = "x"
+       then
+               LIBNETAPP_LIBS="-lpthread -lxml -ladt -lssl -lm -lcrypto -lz"
+       fi
+       AC_MSG_NOTICE([netapp LIBS: $LIBNETAPP_LIBS])
+
+       AC_CHECK_LIB(netapp, na_server_invoke_elem,
+               [with_libnetapp="yes"],
+               [with_libnetapp="no (symbol na_server_invoke_elem not found)"],
+               [$LIBNETAPP_LIBS])
+       LIBNETAPP_LIBS="-lnetapp $LIBNETAPP_LIBS"
+fi
+
+CPPFLAGS="$SAVE_CPPFLAGS"
+LDFLAGS="$SAVE_LDFLAGS"
+
+if test "x$with_libnetapp" = "xyes"
+then
+       AC_DEFINE(HAVE_LIBNETAPP, 1, [Define to 1 if you have the netapp library (-lnetapp).])
+fi
+
+AC_SUBST(LIBNETAPP_CPPFLAGS)
+AC_SUBST(LIBNETAPP_LDFLAGS)
+AC_SUBST(LIBNETAPP_LIBS)
+AM_CONDITIONAL(BUILD_WITH_LIBNETAPP, test "x$with_libnetapp" = "xyes")
+# }}}
+
+# --with-libnetsnmp {{{
+with_snmp_config="net-snmp-config"
+with_snmp_cflags=""
+with_snmp_libs=""
+AC_ARG_WITH(libnetsnmp, [AS_HELP_STRING([--with-libnetsnmp@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
+[
+       if test "x$withval" = "xno"
+       then
+               with_libnetsnmp="no"
+       else if test "x$withval" = "xyes"
+       then
+               with_libnetsnmp="yes"
+       else
+               if test -x "$withval"
+               then
+                       with_snmp_config="$withval"
+                       with_libnetsnmp="yes"
+               else
+                       with_snmp_config="$withval/bin/net-snmp-config"
+                       with_libnetsnmp="yes"
+               fi
+       fi; fi
+],
+[with_libnetsnmp="yes"])
+if test "x$with_libnetsnmp" = "xyes"
+then
+       with_snmp_cflags=`$with_snmp_config --cflags 2>/dev/null`
+       snmp_config_status=$?
+
+       if test $snmp_config_status -ne 0
+       then
+               with_libnetsnmp="no ($with_snmp_config failed)"
+       else
+               SAVE_CPPFLAGS="$CPPFLAGS"
+               CPPFLAGS="$CPPFLAGS $with_snmp_cflags"
+               
+               AC_CHECK_HEADERS(net-snmp/net-snmp-config.h, [], [with_libnetsnmp="no (net-snmp/net-snmp-config.h not found)"])
+
+               CPPFLAGS="$SAVE_CPPFLAGS"
+       fi
+fi
+if test "x$with_libnetsnmp" = "xyes"
+then
+       with_snmp_libs=`$with_snmp_config --libs 2>/dev/null`
+       snmp_config_status=$?
+
+       if test $snmp_config_status -ne 0
+       then
+               with_libnetsnmp="no ($with_snmp_config failed)"
+       else
+               AC_CHECK_LIB(netsnmp, init_snmp,
+               [with_libnetsnmp="yes"],
+               [with_libnetsnmp="no (libnetsnmp not found)"],
+               [$with_snmp_libs])
+       fi
+fi
+if test "x$with_libnetsnmp" = "xyes"
+then
+       BUILD_WITH_LIBSNMP_CFLAGS="$with_snmp_cflags"
+       BUILD_WITH_LIBSNMP_LIBS="$with_snmp_libs"
+       AC_SUBST(BUILD_WITH_LIBSNMP_CFLAGS)
+       AC_SUBST(BUILD_WITH_LIBSNMP_LIBS)
+fi
+AM_CONDITIONAL(BUILD_WITH_LIBNETSNMP, test "x$with_libnetsnmp" = "xyes")
+# }}}
+
+# --with-liboconfig {{{
+with_own_liboconfig="no"
+liboconfig_LDFLAGS="$LDFLAGS"
+liboconfig_CPPFLAGS="$CPPFLAGS"
+AC_ARG_WITH(liboconfig, [AS_HELP_STRING([--with-liboconfig@<:@=PREFIX@:>@], [Path to liboconfig.])],
+[
+       if test "x$withval" != "xno" && test "x$withval" != "xyes"
+       then
+               if test -d "$withval/lib"
+               then
+                       liboconfig_LDFLAGS="$LDFLAGS -L$withval/lib"
+               fi
+               if test -d "$withval/include"
+               then
+                       liboconfig_CPPFLAGS="$CPPFLAGS -I$withval/include"
+               fi
+       fi
+       if test "x$withval" = "xno"
+       then
+               AC_MSG_ERROR("liboconfig is required")
+       fi
+],
+[
+       with_liboconfig="yes"
+])
+
+save_LDFLAGS="$LDFLAGS"
+save_CPPFLAGS="$CPPFLAGS"
+LDFLAGS="$liboconfig_LDFLAGS"
+CPPFLAGS="$liboconfig_CPPFLAGS"
+AC_CHECK_LIB(oconfig, oconfig_parse_fh,
+[
+       with_liboconfig="yes"
+       with_own_liboconfig="no"
+],
+[
+       with_liboconfig="yes"
+       with_own_liboconfig="yes"
+       LDFLAGS="$save_LDFLAGS"
+       CPPFLAGS="$save_CPPFLAGS"
+])
+
+AM_CONDITIONAL(BUILD_WITH_OWN_LIBOCONFIG, test "x$with_own_liboconfig" = "xyes")
+if test "x$with_own_liboconfig" = "xyes"
+then
+       with_liboconfig="yes (shipped version)"
+fi
+# }}}
+
+# --with-liboping {{{
+AC_ARG_WITH(liboping, [AS_HELP_STRING([--with-liboping@<:@=PREFIX@:>@], [Path to liboping.])],
+[
+ if test "x$withval" = "xyes"
+ then
+        with_liboping="yes"
+ else if test "x$withval" = "xno"
+ then
+        with_liboping="no"
+ else
+        with_liboping="yes"
+        LIBOPING_CPPFLAGS="$LIBOPING_CPPFLAGS -I$withval/include"
+        LIBOPING_LDFLAGS="$LIBOPING_LDFLAGS -L$withval/lib"
+ fi; fi
+],
+[with_liboping="yes"])
+
+SAVE_CPPFLAGS="$CPPFLAGS"
+SAVE_LDFLAGS="$LDFLAGS"
+
+CPPFLAGS="$CPPFLAGS $LIBOPING_CPPFLAGS"
+LDFLAGS="$LDFLAGS $LIBOPING_LDFLAGS"
+
+if test "x$with_liboping" = "xyes"
+then
+       if test "x$LIBOPING_CPPFLAGS" != "x"
+       then
+               AC_MSG_NOTICE([liboping CPPFLAGS: $LIBOPING_CPPFLAGS])
+       fi
+       AC_CHECK_HEADERS(oping.h,
+       [with_liboping="yes"],
+       [with_liboping="no (oping.h not found)"])
+fi
+if test "x$with_liboping" = "xyes"
+then
+       if test "x$LIBOPING_LDFLAGS" != "x"
+       then
+               AC_MSG_NOTICE([liboping LDFLAGS: $LIBOPING_LDFLAGS])
+       fi
+       AC_CHECK_LIB(oping, ping_construct,
+       [with_liboping="yes"],
+       [with_liboping="no (symbol 'ping_construct' not found)"])
+fi
+
+CPPFLAGS="$SAVE_CPPFLAGS"
+LDFLAGS="$SAVE_LDFLAGS"
+
+if test "x$with_liboping" = "xyes"
+then
+       BUILD_WITH_LIBOPING_CPPFLAGS="$LIBOPING_CPPFLAGS"
+       BUILD_WITH_LIBOPING_LDFLAGS="$LIBOPING_LDFLAGS"
+       AC_SUBST(BUILD_WITH_LIBOPING_CPPFLAGS)
+       AC_SUBST(BUILD_WITH_LIBOPING_LDFLAGS)
+fi
+AM_CONDITIONAL(BUILD_WITH_LIBOPING, test "x$with_liboping" = "xyes")
+# }}}
+
+# --with-oracle {{{
+with_oracle_cppflags=""
+with_oracle_libs=""
+AC_ARG_WITH(oracle, [AS_HELP_STRING([--with-oracle@<:@=ORACLE_HOME@:>@], [Path to Oracle.])],
+[
+       if test "x$withval" = "xyes"
+       then
+               if test "x$ORACLE_HOME" = "x"
+               then
+                       AC_MSG_WARN([Use of the Oracle library has been forced, but the environment variable ORACLE_HOME is not set.])
+               fi
+               with_oracle="yes"
+       else if test "x$withval" = "xno"
+       then
+               with_oracle="no"
+       else
+               with_oracle="yes"
+               ORACLE_HOME="$withval"
+       fi; fi
+],
+[
+       if test "x$ORACLE_HOME" = "x"
+       then
+               with_oracle="no (ORACLE_HOME is not set)"
+       else
+               with_oracle="yes"
+       fi
+])
+if test "x$ORACLE_HOME" != "x"
+then
+       with_oracle_cppflags="-I$ORACLE_HOME/rdbms/public"
+
+       if test -e "$ORACLE_HOME/lib/ldflags"
+       then
+               with_oracle_libs=`cat "$ORACLE_HOME/lib/ldflags"`
+       fi
+       #with_oracle_libs="-L$ORACLE_HOME/lib $with_oracle_libs -lclntsh"
+       with_oracle_libs="-L$ORACLE_HOME/lib -lclntsh"
+fi
+if test "x$with_oracle" = "xyes"
+then
+       SAVE_CPPFLAGS="$CPPFLAGS"
+       CPPFLAGS="$CPPFLAGS $with_oracle_cppflags"
+
+       AC_CHECK_HEADERS(oci.h, [with_oracle="yes"], [with_oracle="no (oci.h not found)"])
+
+       CPPFLAGS="$SAVE_CPPFLAGS"
+fi
+if test "x$with_oracle" = "xyes"
+then
+       SAVE_CPPFLAGS="$CPPFLAGS"
+       SAVE_LDFLAGS="$LDFLAGS"
+       CPPFLAGS="$CPPFLAGS $with_oracle_cppflags"
+       LDFLAGS="$LDFLAGS $with_oracle_libs"
+
+       AC_CHECK_FUNC(OCIEnvCreate, [with_oracle="yes"], [with_oracle="no (Symbol 'OCIEnvCreate' not found)"])
+
+       CPPFLAGS="$SAVE_CPPFLAGS"
+       LDFLAGS="$SAVE_LDFLAGS"
+fi
+if test "x$with_oracle" = "xyes"
+then
+       BUILD_WITH_ORACLE_CFLAGS="$with_oracle_cppflags"
+       BUILD_WITH_ORACLE_LIBS="$with_oracle_libs"
+       AC_SUBST(BUILD_WITH_ORACLE_CFLAGS)
+       AC_SUBST(BUILD_WITH_ORACLE_LIBS)
+fi
+# }}}
+
+# --with-libowcapi {{{
+with_libowcapi_cppflags=""
+with_libowcapi_libs="-lowcapi"
+AC_ARG_WITH(libowcapi, [AS_HELP_STRING([--with-libowcapi@<:@=PREFIX@:>@], [Path to libowcapi.])],
+[
+       if test "x$withval" != "xno" && test "x$withval" != "xyes"
+       then
+               with_libowcapi_cppflags="-I$withval/include"
+               with_libowcapi_libs="-L$withval/lib -lowcapi"
+               with_libowcapi="yes"
+       else
+               with_libowcapi="$withval"
+       fi
+],
+[
+       with_libowcapi="yes"
+])
+if test "x$with_libowcapi" = "xyes"
+then
+       SAVE_CPPFLAGS="$CPPFLAGS"
+       CPPFLAGS="$with_libowcapi_cppflags"
+       
+       AC_CHECK_HEADERS(owcapi.h, [with_libowcapi="yes"], [with_libowcapi="no (owcapi.h not found)"])
+
+       CPPFLAGS="$SAVE_CPPFLAGS"
+fi
+if test "x$with_libowcapi" = "xyes"
+then
+       SAVE_LDFLAGS="$LDFLAGS"
+       SAVE_CPPFLAGS="$CPPFLAGS"
+       LDFLAGS="$with_libowcapi_libs"
+       CPPFLAGS="$with_libowcapi_cppflags"
+       
+       AC_CHECK_LIB(owcapi, OW_get, [with_libowcapi="yes"], [with_libowcapi="no (libowcapi not found)"])
+
+       LDFLAGS="$SAVE_LDFLAGS"
+       CPPFLAGS="$SAVE_CPPFLAGS"
+fi
+if test "x$with_libowcapi" = "xyes"
+then
+       BUILD_WITH_LIBOWCAPI_CPPFLAGS="$with_libowcapi_cppflags"
+       BUILD_WITH_LIBOWCAPI_LIBS="$with_libowcapi_libs"
+       AC_SUBST(BUILD_WITH_LIBOWCAPI_CPPFLAGS)
+       AC_SUBST(BUILD_WITH_LIBOWCAPI_LIBS)
+fi
+# }}}
+
+# --with-libpcap {{{
+AC_ARG_WITH(libpcap, [AS_HELP_STRING([--with-libpcap@<:@=PREFIX@:>@], [Path to libpcap.])],
+[
+       if test "x$withval" != "xno" && test "x$withval" != "xyes"
+       then
+               LDFLAGS="$LDFLAGS -L$withval/lib"
+               CPPFLAGS="$CPPFLAGS -I$withval/include"
+               with_libpcap="yes"
+       else
+               with_libpcap="$withval"
+       fi
+],
+[
+       with_libpcap="yes"
+])
+if test "x$with_libpcap" = "xyes"
+then
+       AC_CHECK_LIB(pcap, pcap_open_live,
+       [
+               AC_DEFINE(HAVE_LIBPCAP, 1, [Define to 1 if you have the pcap library (-lpcap).])
+       ], [with_libpcap="no (libpcap not found)"])
+fi
+if test "x$with_libpcap" = "xyes"
+then
+       AC_CHECK_HEADERS(pcap.h,,
+                        [with_libpcap="no (pcap.h not found)"])
+fi
+if test "x$with_libpcap" = "xyes"
+then
+       AC_CHECK_HEADERS(pcap-bpf.h,,
+                        [with_libpcap="no (pcap-bpf.h not found)"])
+fi
+if test "x$with_libpcap" = "xyes"
+then
+       AC_CACHE_CHECK([whether libpcap has PCAP_ERROR_IFACE_NOT_UP],
+                      [c_cv_libpcap_have_pcap_error_iface_not_up],
+                      AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+[[[
+#include <pcap.h>
+]]],
+[[[
+  int val = PCAP_ERROR_IFACE_NOT_UP;
+]]]
+                      )],
+                      [c_cv_libpcap_have_pcap_error_iface_not_up="yes"],
+                      [c_cv_libpcap_have_pcap_error_iface_not_up="no"]))
+fi
+if test "x$c_cv_libpcap_have_pcap_error_iface_not_up" != "xyes"
+then
+               with_libpcap="no (pcap.h misses PCAP_ERROR_IFACE_NOT_UP)"
+fi
+AM_CONDITIONAL(BUILD_WITH_LIBPCAP, test "x$with_libpcap" = "xyes")
+# }}}
+
+# --with-libperl {{{
+perl_interpreter="perl"
+AC_ARG_WITH(libperl, [AS_HELP_STRING([--with-libperl@<:@=PREFIX@:>@], [Path to libperl.])],
+[
+       if test -f "$withval" && test -x "$withval"
+       then
+               perl_interpreter="$withval"
+               with_libperl="yes"
+       else if test "x$withval" != "xno" && test "x$withval" != "xyes"
+       then
+               LDFLAGS="$LDFLAGS -L$withval/lib"
+               CPPFLAGS="$CPPFLAGS -I$withval/include"
+               perl_interpreter="$withval/bin/perl"
+               with_libperl="yes"
+       else
+               with_libperl="$withval"
+       fi; fi
+],
+[
+       with_libperl="yes"
+])
+
+AC_MSG_CHECKING([for perl])
+perl_interpreter=`which "$perl_interpreter" 2> /dev/null`
+if test -x "$perl_interpreter"
+then
+       AC_MSG_RESULT([yes ($perl_interpreter)])
+else
+       perl_interpreter=""
+       AC_MSG_RESULT([no])
+fi
+
+AC_SUBST(PERL, "$perl_interpreter")
+
+if test "x$with_libperl" = "xyes" \
+       && test -n "$perl_interpreter"
+then
+  SAVE_CFLAGS="$CFLAGS"
+  SAVE_LDFLAGS="$LDFLAGS"
+dnl ARCHFLAGS="" -> disable multi -arch on OSX (see Config_heavy.pl:fetch_string)
+  PERL_CFLAGS=`ARCHFLAGS="" $perl_interpreter -MExtUtils::Embed -e ccopts`
+  PERL_LDFLAGS=`ARCHFLAGS="" $perl_interpreter -MExtUtils::Embed -e ldopts`
+  CFLAGS="$CFLAGS $PERL_CFLAGS"
+  LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
+
+  AC_CACHE_CHECK([for libperl],
+    [c_cv_have_libperl],
+    AC_LINK_IFELSE([AC_LANG_PROGRAM(
+[[[
+#define PERL_NO_GET_CONTEXT
+#include <EXTERN.h>
+#include <perl.h>
+#include <XSUB.h>
+]]],
+[[[
+       dTHX;
+       load_module (PERL_LOADMOD_NOIMPORT,
+                        newSVpv ("Collectd::Plugin::FooBar", 24),
+                        Nullsv);
+]]]
+      )],
+      [c_cv_have_libperl="yes"],
+      [c_cv_have_libperl="no"]
+    )
+  )
+
+  if test "x$c_cv_have_libperl" = "xyes"
+  then
+         AC_DEFINE(HAVE_LIBPERL, 1, [Define if libperl is present and usable.])
+         AC_SUBST(PERL_CFLAGS)
+         AC_SUBST(PERL_LDFLAGS)
+  else
+         with_libperl="no"
+  fi
+
+  CFLAGS="$SAVE_CFLAGS"
+  LDFLAGS="$SAVE_LDFLAGS"
+else if test -z "$perl_interpreter"; then
+  with_libperl="no (no perl interpreter found)"
+  c_cv_have_libperl="no"
+fi; fi
+AM_CONDITIONAL(BUILD_WITH_LIBPERL, test "x$with_libperl" = "xyes")
+
+if test "x$with_libperl" = "xyes"
+then
+       SAVE_CFLAGS="$CFLAGS"
+       SAVE_LDFLAGS="$LDFLAGS"
+       CFLAGS="$CFLAGS $PERL_CFLAGS"
+       LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
+
+       AC_CACHE_CHECK([if perl supports ithreads],
+               [c_cv_have_perl_ithreads],
+               AC_LINK_IFELSE([AC_LANG_PROGRAM(
+[[[
+#include <EXTERN.h>
+#include <perl.h>
+#include <XSUB.h>
+
+#if !defined(USE_ITHREADS)
+# error "Perl does not support ithreads!"
+#endif /* !defined(USE_ITHREADS) */
+]]],
+[[[ ]]]
+                       )],
+                       [c_cv_have_perl_ithreads="yes"],
+                       [c_cv_have_perl_ithreads="no"]
+               )
+       )
+
+       if test "x$c_cv_have_perl_ithreads" = "xyes"
+       then
+               AC_DEFINE(HAVE_PERL_ITHREADS, 1, [Define if Perl supports ithreads.])
+       fi
+
+       CFLAGS="$SAVE_CFLAGS"
+       LDFLAGS="$SAVE_LDFLAGS"
+fi
+
+if test "x$with_libperl" = "xyes"
+then
+       SAVE_CFLAGS="$CFLAGS"
+       SAVE_LDFLAGS="$LDFLAGS"
+       # trigger an error if Perl_load_module*() uses __attribute__nonnull__(3)
+       # (see issues #41 and #42)
+       CFLAGS="$CFLAGS $PERL_CFLAGS -Wall -Werror"
+       LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
+
+       AC_CACHE_CHECK([for broken Perl_load_module()],
+               [c_cv_have_broken_perl_load_module],
+               AC_LINK_IFELSE([AC_LANG_PROGRAM(
+[[[
+#define PERL_NO_GET_CONTEXT
+#include <EXTERN.h>
+#include <perl.h>
+#include <XSUB.h>
+]]],
+[[[
+                        dTHX;
+                        load_module (PERL_LOADMOD_NOIMPORT,
+                            newSVpv ("Collectd::Plugin::FooBar", 24),
+                            Nullsv);
+]]]
+                       )],
+                       [c_cv_have_broken_perl_load_module="no"],
+                       [c_cv_have_broken_perl_load_module="yes"]
+               )
+       )
+
+       CFLAGS="$SAVE_CFLAGS"
+       LDFLAGS="$SAVE_LDFLAGS"
+fi
+AM_CONDITIONAL(HAVE_BROKEN_PERL_LOAD_MODULE,
+               test "x$c_cv_have_broken_perl_load_module" = "xyes")
+
+if test "x$with_libperl" = "xyes"
+then
+       SAVE_CFLAGS="$CFLAGS"
+       SAVE_LDFLAGS="$LDFLAGS"
+       CFLAGS="$CFLAGS $PERL_CFLAGS"
+       LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
+
+       AC_CHECK_MEMBER(
+               [struct mgvtbl.svt_local],
+               [have_struct_mgvtbl_svt_local="yes"],
+               [have_struct_mgvtbl_svt_local="no"],
+               [
+#include <EXTERN.h>
+#include <perl.h>
+#include <XSUB.h>
+               ])
+
+       if test "x$have_struct_mgvtbl_svt_local" = "xyes"
+       then
+               AC_DEFINE(HAVE_PERL_STRUCT_MGVTBL_SVT_LOCAL, 1,
+                                 [Define if Perl's struct mgvtbl has member svt_local.])
+       fi
+
+       CFLAGS="$SAVE_CFLAGS"
+       LDFLAGS="$SAVE_LDFLAGS"
+fi
+# }}}
+
+# --with-libpq {{{
+with_pg_config="pg_config"
+with_libpq_includedir=""
+with_libpq_libdir=""
+with_libpq_cppflags=""
+with_libpq_ldflags=""
+AC_ARG_WITH(libpq, [AS_HELP_STRING([--with-libpq@<:@=PREFIX@:>@],
+       [Path to libpq.])],
+[
+       if test "x$withval" = "xno"
+       then
+               with_libpq="no"
+       else if test "x$withval" = "xyes"
+       then
+               with_libpq="yes"
+       else
+               if test -f "$withval" && test -x "$withval";
+               then
+                       with_pg_config="$withval"
+               else if test -x "$withval/bin/pg_config"
+               then
+                       with_pg_config="$withval/bin/pg_config"
+               fi; fi
+               with_libpq="yes"
+       fi; fi
+],
+[
+       with_libpq="yes"
+])
+if test "x$with_libpq" = "xyes"
+then
+       with_libpq_includedir=`$with_pg_config --includedir 2> /dev/null`
+       pg_config_status=$?
+
+       if test $pg_config_status -eq 0
+       then
+               if test -n "$with_libpq_includedir"; then
+                       for dir in $with_libpq_includedir; do
+                               with_libpq_cppflags="$with_libpq_cppflags -I$dir"
+                       done
+               fi
+       else
+               AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
+       fi
+
+       SAVE_CPPFLAGS="$CPPFLAGS"
+       CPPFLAGS="$CPPFLAGS $with_libpq_cppflags"
+
+       AC_CHECK_HEADERS(libpq-fe.h, [],
+               [with_libpq="no (libpq-fe.h not found)"], [])
+
+       CPPFLAGS="$SAVE_CPPFLAGS"
+fi
+if test "x$with_libpq" = "xyes"
+then
+       with_libpq_libdir=`$with_pg_config --libdir 2> /dev/null`
+       pg_config_status=$?
+
+       if test $pg_config_status -eq 0
+       then
+               if test -n "$with_libpq_libdir"; then
+                       for dir in $with_libpq_libdir; do
+                               with_libpq_ldflags="$with_libpq_ldflags -L$dir"
+                       done
+               fi
+       else
+               AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
+       fi
+
+       SAVE_LDFLAGS="$LDFLAGS"
+       LDFLAGS="$LDFLAGS $with_libpq_ldflags"
+
+       AC_CHECK_LIB(pq, PQconnectdb,
+               [with_libpq="yes"],
+               [with_libpq="no (symbol 'PQconnectdb' not found)"])
+
+       AC_CHECK_LIB(pq, PQserverVersion,
+               [with_libpq="yes"],
+               [with_libpq="no (symbol 'PQserverVersion' not found)"])
+
+       LDFLAGS="$SAVE_LDFLAGS"
+fi
+if test "x$with_libpq" = "xyes"
+then
+       BUILD_WITH_LIBPQ_CPPFLAGS="$with_libpq_cppflags"
+       BUILD_WITH_LIBPQ_LDFLAGS="$with_libpq_ldflags"
+       AC_SUBST(BUILD_WITH_LIBPQ_CPPFLAGS)
+       AC_SUBST(BUILD_WITH_LIBPQ_LDFLAGS)
+fi
+AM_CONDITIONAL(BUILD_WITH_LIBPQ, test "x$with_libpq" = "xyes")
+# }}}
+
+# --with-libpthread {{{
+AC_ARG_WITH(libpthread, [AS_HELP_STRING([--with-libpthread=@<:@=PREFIX@:>@], [Path to libpthread.])],
+[      if test "x$withval" != "xno" \
+               && test "x$withval" != "xyes"
+       then
+               LDFLAGS="$LDFLAGS -L$withval/lib"
+               CPPFLAGS="$CPPFLAGS -I$withval/include"
+               with_libpthread="yes"
+       else
+               if test "x$withval" = "xno"
+               then
+                       with_libpthread="no (disabled)"
+               fi
+       fi
+], [with_libpthread="yes"])
+if test "x$with_libpthread" = "xyes"
+then
+       AC_CHECK_LIB(pthread, pthread_create, [with_libpthread="yes"], [with_libpthread="no (libpthread not found)"], [])
+fi
+
+if test "x$with_libpthread" = "xyes"
+then
+       AC_CHECK_HEADERS(pthread.h,, [with_libpthread="no (pthread.h not found)"])
+fi
+if test "x$with_libpthread" = "xyes"
+then
+       collect_pthread=1
+else
+       collect_pthread=0
+fi
+AC_DEFINE_UNQUOTED(HAVE_LIBPTHREAD, [$collect_pthread],
+       [Wether or not to use pthread (POSIX threads) library])
+AM_CONDITIONAL(BUILD_WITH_LIBPTHREAD, test "x$with_libpthread" = "xyes")
+# }}}
+
+# --with-python {{{
+with_python_prog=""
+with_python_path="$PATH"
+AC_ARG_WITH(python, [AS_HELP_STRING([--with-python@<:@=PREFIX@:>@], [Path to the python interpreter.])],
+[
+ if test "x$withval" = "xyes" || test "x$withval" = "xno"
+ then
+        with_python="$withval"
+ else if test -x "$withval"
+ then
+        with_python_prog="$withval"
+        with_python_path="`dirname \"$withval\"`$PATH_SEPARATOR$with_python_path"
+        with_python="yes"
+ else if test -d "$withval"
+ then
+        with_python_path="$withval$PATH_SEPARATOR$with_python_path"
+        with_python="yes"
+ else
+        AC_MSG_WARN([Argument not recognized: $withval])
+ fi; fi; fi
+], [with_python="yes"])
+
+SAVE_PATH="$PATH"
+SAVE_CPPFLAGS="$CPPFLAGS"
+SAVE_LDFLAGS="$LDFLAGS"
+SAVE_LIBS="$LIBS"
+
+PATH="$with_python_path"
+
+if test "x$with_python" = "xyes" && test "x$with_python_prog" = "x"
+then
+       AC_MSG_CHECKING([for python])
+       with_python_prog="`which python 2>/dev/null`"
+       if test "x$with_python_prog" = "x"
+       then
+               AC_MSG_RESULT([not found])
+               with_python="no (interpreter not found)"
+       else
+               AC_MSG_RESULT([$with_python_prog])
+       fi
+fi
+
+if test "x$with_python" = "xyes"
+then
+       AC_MSG_CHECKING([for Python CPPFLAGS])
+       python_include_path=`echo "import distutils.sysconfig;import sys;sys.stdout.write(distutils.sysconfig.get_python_inc())" | "$with_python_prog" 2>&1`
+       python_config_status=$?
+
+       if test "$python_config_status" -ne 0 || test "x$python_include_path" = "x"
+       then
+               AC_MSG_RESULT([failed with status $python_config_status (output: $python_include_path)])
+               with_python="no"
+       else
+               AC_MSG_RESULT([$python_include_path])
+       fi
+fi
+
+if test "x$with_python" = "xyes"
+then
+       CPPFLAGS="-I$python_include_path $CPPFLAGS"
+       AC_CHECK_HEADERS(Python.h,
+                        [with_python="yes"],
+                        [with_python="no ('Python.h' not found)"])
+fi
+
+if test "x$with_python" = "xyes"
+then
+       AC_MSG_CHECKING([for Python LDFLAGS])
+       python_library_path=`echo "import distutils.sysconfig;import sys;sys.stdout.write(distutils.sysconfig.get_config_vars(\"LIBDIR\").__getitem__(0))" | "$with_python_prog" 2>&1`
+       python_config_status=$?
+
+       if test "$python_config_status" -ne 0 || test "x$python_library_path" = "x"
+       then
+               AC_MSG_RESULT([failed with status $python_config_status (output: $python_library_path)])
+               with_python="no"
+       else
+               AC_MSG_RESULT([$python_library_path])
+       fi
+fi
+
+if test "x$with_python" = "xyes"
+then
+       AC_MSG_CHECKING([for Python LIBS])
+       python_library_flags=`echo "import distutils.sysconfig;import sys;sys.stdout.write(distutils.sysconfig.get_config_vars(\"BLDLIBRARY\").__getitem__(0))" | "$with_python_prog" 2>&1`
+       python_config_status=$?
+
+       if test "$python_config_status" -ne 0 || test "x$python_library_flags" = "x"
+       then
+               AC_MSG_RESULT([failed with status $python_config_status (output: $python_library_flags)])
+               with_python="no"
+       else
+               AC_MSG_RESULT([$python_library_flags])
+       fi
+fi
+
+if test "x$with_python" = "xyes"
+then
+       LDFLAGS="-L$python_library_path $LDFLAGS"
+       LIBS="$python_library_flags $LIBS"
+
+       AC_CHECK_FUNC(PyObject_CallFunction,
+                     [with_python="yes"],
+                     [with_python="no (Symbol 'PyObject_CallFunction' not found)"])
+fi
+
+PATH="$SAVE_PATH"
+CPPFLAGS="$SAVE_CPPFLAGS"
+LDFLAGS="$SAVE_LDFLAGS"
+LIBS="$SAVE_LIBS"
+
+if test "x$with_python" = "xyes"
+then
+       BUILD_WITH_PYTHON_CPPFLAGS="-I$python_include_path"
+       BUILD_WITH_PYTHON_LDFLAGS="-L$python_library_path"
+       BUILD_WITH_PYTHON_LIBS="$python_library_flags"
+       AC_SUBST(BUILD_WITH_PYTHON_CPPFLAGS)
+       AC_SUBST(BUILD_WITH_PYTHON_LDFLAGS)
+       AC_SUBST(BUILD_WITH_PYTHON_LIBS)
+fi
+# }}} --with-python
+
+# --with-librabbitmq {{{
+with_librabbitmq_cppflags=""
+with_librabbitmq_ldflags=""
+AC_ARG_WITH(librabbitmq, [AS_HELP_STRING([--with-librabbitmq@<:@=PREFIX@:>@], [Path to librabbitmq.])],
+[
+       if test "x$withval" != "xno" && test "x$withval" != "xyes"
+       then
+               with_librabbitmq_cppflags="-I$withval/include"
+               with_librabbitmq_ldflags="-L$withval/lib"
+               with_librabbitmq="yes"
+       else
+               with_librabbitmq="$withval"
+       fi
+],
+[
+       with_librabbitmq="yes"
+])
+SAVE_CPPFLAGS="$CPPFLAGS"
+SAVE_LDFLAGS="$LDFLAGS"
+CPPFLAGS="$CPPFLAGS $with_librabbitmq_cppflags"
+LDFLAGS="$LDFLAGS $with_librabbitmq_ldflags"
+if test "x$with_librabbitmq" = "xyes"
+then
+       AC_CHECK_HEADERS(amqp.h, [with_librabbitmq="yes"], [with_librabbitmq="no (amqp.h not found)"])
+fi
+if test "x$with_librabbitmq" = "xyes"
+then
+       # librabbitmq up to version 0.9.1 provides "library_errno", later
+       # versions use "library_error". The library does not provide a version
+       # macro :( Use "AC_CHECK_MEMBERS" (plural) for automatic defines.
+       AC_CHECK_MEMBERS([amqp_rpc_reply_t.library_errno],,,
+                        [
+#if HAVE_STDLIB_H
+# include <stdlib.h>
+#endif
+#if HAVE_STDIO_H
+# include <stdio.h>
+#endif
+#if HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#include <amqp.h>
+                         ])
+fi
+if test "x$with_librabbitmq" = "xyes"
+then
+       AC_CHECK_LIB(rabbitmq, amqp_basic_publish, [with_librabbitmq="yes"], [with_librabbitmq="no (Symbol 'amqp_basic_publish' not found)"])
+fi
+if test "x$with_librabbitmq" = "xyes"
+then
+       BUILD_WITH_LIBRABBITMQ_CPPFLAGS="$with_librabbitmq_cppflags"
+       BUILD_WITH_LIBRABBITMQ_LDFLAGS="$with_librabbitmq_ldflags"
+       BUILD_WITH_LIBRABBITMQ_LIBS="-lrabbitmq"
+       AC_SUBST(BUILD_WITH_LIBRABBITMQ_CPPFLAGS)
+       AC_SUBST(BUILD_WITH_LIBRABBITMQ_LDFLAGS)
+       AC_SUBST(BUILD_WITH_LIBRABBITMQ_LIBS)
+       AC_DEFINE(HAVE_LIBRABBITMQ, 1, [Define if librabbitmq is present and usable.])
+fi
+CPPFLAGS="$SAVE_CPPFLAGS"
+LDFLAGS="$SAVE_LDFLAGS"
+AM_CONDITIONAL(BUILD_WITH_LIBRABBITMQ, test "x$with_librabbitmq" = "xyes")
+# }}}
+
+# --with-librouteros {{{
+AC_ARG_WITH(librouteros, [AS_HELP_STRING([--with-librouteros@<:@=PREFIX@:>@], [Path to librouteros.])],
+[
+ if test "x$withval" = "xyes"
+ then
+        with_librouteros="yes"
+ else if test "x$withval" = "xno"
+ then
+        with_librouteros="no"
+ else
+        with_librouteros="yes"
+        LIBROUTEROS_CPPFLAGS="$LIBROUTEROS_CPPFLAGS -I$withval/include"
+        LIBROUTEROS_LDFLAGS="$LIBROUTEROS_LDFLAGS -L$withval/lib"
+ fi; fi
+],
+[with_librouteros="yes"])
+
+SAVE_CPPFLAGS="$CPPFLAGS"
+SAVE_LDFLAGS="$LDFLAGS"
+
+CPPFLAGS="$CPPFLAGS $LIBROUTEROS_CPPFLAGS"
+LDFLAGS="$LDFLAGS $LIBROUTEROS_LDFLAGS"
+
+if test "x$with_librouteros" = "xyes"
+then
+       if test "x$LIBROUTEROS_CPPFLAGS" != "x"
+       then
+               AC_MSG_NOTICE([librouteros CPPFLAGS: $LIBROUTEROS_CPPFLAGS])
+       fi
+       AC_CHECK_HEADERS(routeros_api.h,
+       [with_librouteros="yes"],
+       [with_librouteros="no (routeros_api.h not found)"])
+fi
+if test "x$with_librouteros" = "xyes"
+then
+       if test "x$LIBROUTEROS_LDFLAGS" != "x"
+       then
+               AC_MSG_NOTICE([librouteros LDFLAGS: $LIBROUTEROS_LDFLAGS])
+       fi
+       AC_CHECK_LIB(routeros, ros_interface,
+       [with_librouteros="yes"],
+       [with_librouteros="no (symbol 'ros_interface' not found)"])
+fi
+
+CPPFLAGS="$SAVE_CPPFLAGS"
+LDFLAGS="$SAVE_LDFLAGS"
+
+if test "x$with_librouteros" = "xyes"
+then
+       BUILD_WITH_LIBROUTEROS_CPPFLAGS="$LIBROUTEROS_CPPFLAGS"
+       BUILD_WITH_LIBROUTEROS_LDFLAGS="$LIBROUTEROS_LDFLAGS"
+       AC_SUBST(BUILD_WITH_LIBROUTEROS_CPPFLAGS)
+       AC_SUBST(BUILD_WITH_LIBROUTEROS_LDFLAGS)
+fi
+AM_CONDITIONAL(BUILD_WITH_LIBROUTEROS, test "x$with_librouteros" = "xyes")
+# }}}
+
+# --with-librrd {{{
+# AC_ARG_WITH (package, help-string, [action-if-given], [action-if-not-given])
+librrd_cflags=""
+librrd_ldflags=""
+librrd_threadsafe="yes"
+librrd_rrdc_update="no"
+AC_ARG_WITH(librrd, [AS_HELP_STRING([--with-librrd@<:@=PREFIX@:>@], [Path to rrdtool.])],
+[      if test "x$withval" != "xno" && test "x$withval" != "xyes"
+       then
+               librrd_cflags="-I$withval/include"
+               librrd_ldflags="-L$withval/lib"
+               with_librrd="yes"
+       else
+               with_librrd="$withval"
+       fi
+], [with_librrd="yes"])
+if test "x$with_librrd" = "xyes"
+then
+       SAVE_CPPFLAGS="$CPPFLAGS"
+       SAVE_LDFLAGS="$LDFLAGS"
+
+       CPPFLAGS="$CPPFLAGS $librrd_cflags"
+       LDFLAGS="$LDFLAGS $librrd_ldflags"
+
+       AC_CHECK_HEADERS(rrd.h,, [with_librrd="no (rrd.h not found)"])
+
+       CPPFLAGS="$SAVE_CPPFLAGS"
+       LDFLAGS="$SAVE_LDFLAGS"
+fi
+if test "x$with_librrd" = "xyes"
+then
+       SAVE_CPPFLAGS="$CPPFLAGS"
+       SAVE_LDFLAGS="$LDFLAGS"
+
+       CPPFLAGS="$CPPFLAGS $librrd_cflags"
+       LDFLAGS="$LDFLAGS $librrd_ldflags"
+
+       AC_CHECK_LIB(rrd_th, rrd_update_r,
+       [with_librrd="yes"
+        librrd_ldflags="$librrd_ldflags -lrrd_th -lm"
+       ],
+       [librrd_threadsafe="no"
+        AC_CHECK_LIB(rrd, rrd_update,
+        [with_librrd="yes"
+         librrd_ldflags="$librrd_ldflags -lrrd -lm"
+        ],
+        [with_librrd="no (symbol 'rrd_update' not found)"],
+        [-lm])
+       ],
+       [-lm])
+
+       if test "x$librrd_threadsafe" = "xyes"
+       then
+               AC_CHECK_LIB(rrd_th, rrdc_update, [librrd_rrdc_update="yes"], [librrd_rrdc_update="no"])
+       else
+               AC_CHECK_LIB(rrd, rrdc_update, [librrd_rrdc_update="yes"], [librrd_rrdc_update="no"])
+       fi
+
+       CPPFLAGS="$SAVE_CPPFLAGS"
+       LDFLAGS="$SAVE_LDFLAGS"
+fi
+if test "x$with_librrd" = "xyes"
+then
+       BUILD_WITH_LIBRRD_CFLAGS="$librrd_cflags"
+       BUILD_WITH_LIBRRD_LDFLAGS="$librrd_ldflags"
+       AC_SUBST(BUILD_WITH_LIBRRD_CFLAGS)
+       AC_SUBST(BUILD_WITH_LIBRRD_LDFLAGS)
+fi
+if test "x$librrd_threadsafe" = "xyes"
+then
+       AC_DEFINE(HAVE_THREADSAFE_LIBRRD, 1, [Define to 1 if you have the threadsafe rrd library (-lrrd_th).])
+fi
+# }}}
+
+# --with-libsensors {{{
+with_sensors_cflags=""
+with_sensors_ldflags=""
+AC_ARG_WITH(libsensors, [AS_HELP_STRING([--with-libsensors@<:@=PREFIX@:>@], [Path to lm_sensors.])],
+[
+       if test "x$withval" = "xno"
+       then
+               with_libsensors="no"
+       else
+               with_libsensors="yes"
+               if test "x$withval" != "xyes"
+               then
+                       with_sensors_cflags="-I$withval/include"
+                       with_sensors_ldflags="-L$withval/lib"
+                       with_libsensors="yes"
+               fi
+       fi
+],
+[
+       if test "x$ac_system" = "xLinux"
+       then
+               with_libsensors="yes"
+       else
+               with_libsensors="no (Linux only library)"
+       fi
+])
+if test "x$with_libsensors" = "xyes"
+then
+       SAVE_CPPFLAGS="$CPPFLAGS"
+       CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
+
+#      AC_CHECK_HEADERS(sensors/sensors.h,
+#      [
+#              AC_DEFINE(HAVE_SENSORS_SENSORS_H, 1, [Define to 1 if you have the <sensors/sensors.h> header file.])
+#      ],
+#      [with_libsensors="no (sensors/sensors.h not found)"])
+       AC_CHECK_HEADERS(sensors/sensors.h, [], [with_libsensors="no (sensors/sensors.h not found)"])
+
+       CPPFLAGS="$SAVE_CPPFLAGS"
+fi
+if test "x$with_libsensors" = "xyes"
+then
+       SAVE_CPPFLAGS="$CPPFLAGS"
+       SAVE_LDFLAGS="$LDFLAGS"
+       CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
+       LDFLAGS="$LDFLAGS $with_sensors_ldflags"
+
+       AC_CHECK_LIB(sensors, sensors_init,
+       [
+               AC_DEFINE(HAVE_LIBSENSORS, 1, [Define to 1 if you have the sensors library (-lsensors).])
+       ],
+       [with_libsensors="no (libsensors not found)"])
+
+       CPPFLAGS="$SAVE_CPPFLAGS"
+       LDFLAGS="$SAVE_LDFLAGS"
+fi
+if test "x$with_libsensors" = "xyes"
+then
+       BUILD_WITH_LIBSENSORS_CFLAGS="$with_sensors_cflags"
+       BUILD_WITH_LIBSENSORS_LDFLAGS="$with_sensors_ldflags"
+       AC_SUBST(BUILD_WITH_LIBSENSORS_CFLAGS)
+       AC_SUBST(BUILD_WITH_LIBSENSORS_LDFLAGS)
+fi
+AM_CONDITIONAL(BUILD_WITH_LM_SENSORS, test "x$with_libsensors" = "xyes")
+# }}}
+
+# --with-libsigrok {{{
+with_libsigrok_cflags=""
+with_libsigrok_ldflags=""
+AC_ARG_WITH(libsigrok, [AS_HELP_STRING([--with-libsigrok@<:@=PREFIX@:>@], [Path to libsigrok.])],
+[
+       if test "x$withval" = "xno"
+       then
+               with_libsigrok="no"
+       else
+               with_libsigrok="yes"
+               if test "x$withval" != "xyes"
+               then
+                       with_libsigrok_cflags="-I$withval/include"
+                       with_libsigrok_ldflags="-L$withval/lib"
+               fi
+       fi
+],[])
+
+# libsigrok has a glib dependency
+if test "x$with_libsigrok" = "xyes"
+then
+       if test -z "m4_ifdef([AM_PATH_GLIB_2_0], [yes], [])"
+       then
+               with_libsigrok="no (glib not available)"
+       else
+               AM_PATH_GLIB_2_0([2.28.0],
+                       [with_libsigrok_cflags="$with_libsigrok_cflags $GLIB_CFLAGS"; with_libsigrok_ldflags="$with_libsigrok_ldflags $GLIB_LIBS"])
+       fi
+fi
+
+# libsigrok headers
+if test "x$with_libsigrok" = "xyes"
+then
+       SAVE_CPPFLAGS="$CPPFLAGS"
+       CPPFLAGS="$CPPFLAGS $with_libsigrok_cflags"
+
+       AC_CHECK_HEADERS(libsigrok/libsigrok.h, [], [with_libsigrok="no (libsigrok/libsigrok.h not found)"])
+
+       CPPFLAGS="$SAVE_CPPFLAGS"
+fi
+
+# libsigrok library
+if test "x$with_libsigrok" = "xyes"
+then
+       SAVE_CPPFLAGS="$CPPFLAGS"
+       SAVE_LDFLAGS="$LDFLAGS"
+       CPPFLAGS="$CPPFLAGS $with_libsigrok_cflags"
+       LDFLAGS="$LDFLAGS $with_libsigrok_ldflags"
+
+       AC_CHECK_LIB(sigrok, sr_init,
+       [
+               AC_DEFINE(HAVE_LIBSIGROK, 1, [Define to 1 if you have the sigrok library (-lsigrok).])
+       ],
+       [with_libsigrok="no (libsigrok not found)"])
+
+       CPPFLAGS="$SAVE_CPPFLAGS"
+       LDFLAGS="$SAVE_LDFLAGS"
+fi
+if test "x$with_libsigrok" = "xyes"
+then
+       BUILD_WITH_LIBSIGROK_CFLAGS="$with_libsigrok_cflags"
+       BUILD_WITH_LIBSIGROK_LDFLAGS="$with_libsigrok_ldflags"
+       AC_SUBST(BUILD_WITH_LIBSIGROK_CFLAGS)
+       AC_SUBST(BUILD_WITH_LIBSIGROK_LDFLAGS)
+fi
+AM_CONDITIONAL(BUILD_WITH_LIBSIGROK, test "x$with_libsigrok" = "xyes")
+# }}}
+
+# --with-libstatgrab {{{
+with_libstatgrab_cflags=""
+with_libstatgrab_ldflags=""
+AC_ARG_WITH(libstatgrab, [AS_HELP_STRING([--with-libstatgrab@<:@=PREFIX@:>@], [Path to libstatgrab.])],
+[
+ if test "x$withval" != "xno" \
+   && test "x$withval" != "xyes"
+ then
+   with_libstatgrab_cflags="-I$withval/include"
+   with_libstatgrab_ldflags="-L$withval/lib -lstatgrab"
+   with_libstatgrab="yes"
+   with_libstatgrab_pkg_config="no"
+ else
+   with_libstatgrab="$withval"
+   with_libstatgrab_pkg_config="yes"
+ fi
+ ],
+[
+ with_libstatgrab="yes"
+ with_libstatgrab_pkg_config="yes"
+])
+
+if test "x$with_libstatgrab" = "xyes" \
+  && test "x$with_libstatgrab_pkg_config" = "xyes"
+then
+  if test "x$PKG_CONFIG" != "x"
+  then
+    AC_MSG_CHECKING([pkg-config for libstatgrab])
+    temp_result="found"
+    $PKG_CONFIG --exists libstatgrab 2>/dev/null
+    if test "$?" != "0"
+    then
+      with_libstatgrab_pkg_config="no"
+      with_libstatgrab="no (pkg-config doesn't know libstatgrab)"
+      temp_result="not found"
+    fi
+    AC_MSG_RESULT([$temp_result])
+  else
+    AC_MSG_NOTICE([pkg-config not available, trying to guess flags for the statgrab library.])
+    with_libstatgrab_pkg_config="no"
+    with_libstatgrab_ldflags="$with_libstatgrab_ldflags -lstatgrab"
+  fi
+fi
+
+if test "x$with_libstatgrab" = "xyes" \
+  && test "x$with_libstatgrab_pkg_config" = "xyes" \
+  && test "x$with_libstatgrab_cflags" = "x"
+then
+  AC_MSG_CHECKING([for libstatgrab CFLAGS])
+  temp_result="`$PKG_CONFIG --cflags libstatgrab`"
+  if test "$?" = "0"
+  then
+    with_libstatgrab_cflags="$temp_result"
+  else
+    with_libstatgrab="no ($PKG_CONFIG --cflags libstatgrab failed)"
+    temp_result="$PKG_CONFIG --cflags libstatgrab failed"
+  fi
+  AC_MSG_RESULT([$temp_result])
+fi
+
+if test "x$with_libstatgrab" = "xyes" \
+  && test "x$with_libstatgrab_pkg_config" = "xyes" \
+  && test "x$with_libstatgrab_ldflags" = "x"
+then
+  AC_MSG_CHECKING([for libstatgrab LDFLAGS])
+  temp_result="`$PKG_CONFIG --libs libstatgrab`"
+  if test "$?" = "0"
+  then
+    with_libstatgrab_ldflags="$temp_result"
+  else
+    with_libstatgrab="no ($PKG_CONFIG --libs libstatgrab failed)"
+    temp_result="$PKG_CONFIG --libs libstatgrab failed"
+  fi
+  AC_MSG_RESULT([$temp_result])
+fi
+
+if test "x$with_libstatgrab" = "xyes"
+then
+  SAVE_CPPFLAGS="$CPPFLAGS"
+  CPPFLAGS="$CPPFLAGS $with_libstatgrab_cflags"
+
+  AC_CHECK_HEADERS(statgrab.h,
+                  [with_libstatgrab="yes"],
+                  [with_libstatgrab="no (statgrab.h not found)"])
+
+  CPPFLAGS="$SAVE_CPPFLAGS"
+fi
+
+if test "x$with_libstatgrab" = "xyes"
+then
+  SAVE_CFLAGS="$CFLAGS"
+  SAVE_LDFLAGS="$LDFLAGS"
+
+  CFLAGS="$CFLAGS $with_libstatgrab_cflags"
+  LDFLAGS="$LDFLAGS $with_libstatgrab_ldflags"
+
+  AC_CHECK_LIB(statgrab, sg_init,
+              [with_libstatgrab="yes"],
+              [with_libstatgrab="no (symbol sg_init not found)"])
+
+  CFLAGS="$SAVE_CFLAGS"
+  LDFLAGS="$SAVE_LDFLAGS"
+fi
+
+AM_CONDITIONAL(BUILD_WITH_LIBSTATGRAB, test "x$with_libstatgrab" = "xyes")
+if test "x$with_libstatgrab" = "xyes"
+then
+  AC_DEFINE(HAVE_LIBSTATGRAB, 1, [Define to 1 if you have the 'statgrab' library (-lstatgrab)])
+  BUILD_WITH_LIBSTATGRAB_CFLAGS="$with_libstatgrab_cflags"
+  BUILD_WITH_LIBSTATGRAB_LDFLAGS="$with_libstatgrab_ldflags"
+  AC_SUBST(BUILD_WITH_LIBSTATGRAB_CFLAGS)
+  AC_SUBST(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
+fi
+# }}}
+
+# --with-libtokyotyrant {{{
+with_libtokyotyrant_cppflags=""
+with_libtokyotyrant_ldflags=""
+with_libtokyotyrant_libs=""
+AC_ARG_WITH(libtokyotyrant, [AS_HELP_STRING([--with-libtokyotyrant@<:@=PREFIX@:>@], [Path to libtokyotyrant.])],
+[
+  if test "x$withval" = "xno"
+  then
+    with_libtokyotyrant="no"
+  else if test "x$withval" = "xyes"
+  then
+    with_libtokyotyrant="yes"
+  else
+    with_libtokyotyrant_cppflags="-I$withval/include"
+    with_libtokyotyrant_ldflags="-L$withval/include"
+    with_libtokyotyrant_libs="-ltokyotyrant"
+    with_libtokyotyrant="yes"
+  fi; fi
+],
+[
+  with_libtokyotyrant="yes"
+])
+
+if test "x$with_libtokyotyrant" = "xyes"
+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`"
+  fi
+fi
+
+SAVE_CPPFLAGS="$CPPFLAGS"
+SAVE_LDFLAGS="$LDFLAGS"
+CPPFLAGS="$CPPFLAGS $with_libtokyotyrant_cppflags"
+LDFLAGS="$LDFLAGS $with_libtokyotyrant_ldflags"
+
+if test "x$with_libtokyotyrant" = "xyes"
+then
+  AC_CHECK_HEADERS(tcrdb.h,
+  [
+          AC_DEFINE(HAVE_TCRDB_H, 1,
+                    [Define to 1 if you have the <tcrdb.h> header file.])
+  ], [with_libtokyotyrant="no (tcrdb.h not found)"])
+fi
+
+if test "x$with_libtokyotyrant" = "xyes"
+then
+  AC_CHECK_LIB(tokyotyrant, tcrdbrnum,
+  [
+          AC_DEFINE(HAVE_LIBTOKYOTYRANT, 1,
+                    [Define to 1 if you have the tokyotyrant library (-ltokyotyrant).])
+  ],
+  [with_libtokyotyrant="no (symbol tcrdbrnum not found)"],
+  [$with_libtokyotyrant_libs])
+fi
+
+CPPFLAGS="$SAVE_CPPFLAGS"
+LDFLAGS="$SAVE_LDFLAGS"
+
+if test "x$with_libtokyotyrant" = "xyes"
+then 
+  BUILD_WITH_LIBTOKYOTYRANT_CPPFLAGS="$with_libtokyotyrant_cppflags"
+  BUILD_WITH_LIBTOKYOTYRANT_LDFLAGS="$with_libtokyotyrant_ldflags"
+  BUILD_WITH_LIBTOKYOTYRANT_LIBS="$with_libtokyotyrant_libs"
+  AC_SUBST(BUILD_WITH_LIBTOKYOTYRANT_CPPFLAGS)
+  AC_SUBST(BUILD_WITH_LIBTOKYOTYRANT_LDFLAGS)
+  AC_SUBST(BUILD_WITH_LIBTOKYOTYRANT_LIBS)
+fi
+AM_CONDITIONAL(BUILD_WITH_LIBTOKYOTYRANT, test "x$with_libtokyotyrant" = "xyes")
+# }}}
+
+# --with-libupsclient {{{
+with_libupsclient_config=""
+with_libupsclient_cflags=""
+with_libupsclient_libs=""
+AC_ARG_WITH(libupsclient, [AS_HELP_STRING([--with-libupsclient@<:@=PREFIX@:>@], [Path to the upsclient library.])],
+[
+       if test "x$withval" = "xno"
+       then
+               with_libupsclient="no"
+       else if test "x$withval" = "xyes"
+       then
+               with_libupsclient="use_pkgconfig"
+       else
+               if test -x "$withval"
+               then
+                       with_libupsclient_config="$withval"
+                       with_libupsclient="use_libupsclient_config"
+               else if test -x "$withval/bin/libupsclient-config"
+               then
+                       with_libupsclient_config="$withval/bin/libupsclient-config"
+                       with_libupsclient="use_libupsclient_config"
+               else
+                       AC_MSG_NOTICE([Not checking for libupsclient: Manually configured])
+                       with_libupsclient_cflags="-I$withval/include"
+                       with_libupsclient_libs="-L$withval/lib -lupsclient"
+                       with_libupsclient="yes"
+               fi; fi
+       fi; fi
+],
+[with_libupsclient="use_pkgconfig"])
+
+# configure using libupsclient-config
+if test "x$with_libupsclient" = "xuse_libupsclient_config"
+then
+       AC_MSG_NOTICE([Checking for libupsclient using $with_libupsclient_config])
+       with_libupsclient_cflags="`$with_libupsclient_config --cflags`"
+       if test $? -ne 0
+       then
+               with_libupsclient="no ($with_libupsclient_config failed)"
+       fi
+       with_libupsclient_libs="`$with_libupsclient_config --libs`"
+       if test $? -ne 0
+       then
+               with_libupsclient="no ($with_libupsclient_config failed)"
+       fi
+fi
+if test "x$with_libupsclient" = "xuse_libupsclient_config"
+then
+       with_libupsclient="yes"
+fi
+
+# configure using pkg-config
+if test "x$with_libupsclient" = "xuse_pkgconfig"
+then
+       if test "x$PKG_CONFIG" = "x"
+       then
+               with_libupsclient="no (Don't have pkg-config)"
+       fi
+fi
+if test "x$with_libupsclient" = "xuse_pkgconfig"
+then
+       AC_MSG_NOTICE([Checking for libupsclient using $PKG_CONFIG])
+       $PKG_CONFIG --exists 'libupsclient' 2>/dev/null
+       if test $? -ne 0
+       then
+               with_libupsclient="no (pkg-config doesn't know libupsclient)"
+       fi
+fi
+if test "x$with_libupsclient" = "xuse_pkgconfig"
+then
+       with_libupsclient_cflags="`$PKG_CONFIG --cflags 'libupsclient'`"
+       if test $? -ne 0
+       then
+               with_libupsclient="no ($PKG_CONFIG failed)"
+       fi
+       with_libupsclient_libs="`$PKG_CONFIG --libs 'libupsclient'`"
+       if test $? -ne 0
+       then
+               with_libupsclient="no ($PKG_CONFIG failed)"
+       fi
+fi
+if test "x$with_libupsclient" = "xuse_pkgconfig"
+then
+       with_libupsclient="yes"
+fi
+
+# with_libupsclient_cflags and with_libupsclient_libs are set up now, let's do
+# the actual checks.
+if test "x$with_libupsclient" = "xyes"
+then
+       SAVE_CPPFLAGS="$CPPFLAGS"
+       CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
+
+       AC_CHECK_HEADERS(upsclient.h, [], [with_libupsclient="no (upsclient.h not found)"])
+
+       CPPFLAGS="$SAVE_CPPFLAGS"
+fi
+if test "x$with_libupsclient" = "xyes"
+then
+       SAVE_CPPFLAGS="$CPPFLAGS"
+       SAVE_LDFLAGS="$LDFLAGS"
+
+       CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
+       LDFLAGS="$LDFLAGS $with_libupsclient_libs"
+
+       AC_CHECK_LIB(upsclient, upscli_connect,
+                    [with_libupsclient="yes"],
+                    [with_libupsclient="no (symbol upscli_connect not found)"])
+
+       CPPFLAGS="$SAVE_CPPFLAGS"
+       LDFLAGS="$SAVE_LDFLAGS"
+fi
+if test "x$with_libupsclient" = "xyes"
+then
+       SAVE_CPPFLAGS="$CPPFLAGS"
+       CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
+
+       AC_CHECK_TYPES([UPSCONN_t, UPSCONN], [], [],
+[#include <stdlib.h>
+#include <stdio.h>
+#include <upsclient.h>])
+
+       CPPFLAGS="$SAVE_CPPFLAGS"
+fi
+if test "x$with_libupsclient" = "xyes"
+then
+       BUILD_WITH_LIBUPSCLIENT_CFLAGS="$with_libupsclient_cflags"
+       BUILD_WITH_LIBUPSCLIENT_LIBS="$with_libupsclient_libs"
+       AC_SUBST(BUILD_WITH_LIBUPSCLIENT_CFLAGS)
+       AC_SUBST(BUILD_WITH_LIBUPSCLIENT_LIBS)
+fi
+# }}}
+
+# --with-libxmms {{{
+with_xmms_config="xmms-config"
+with_xmms_cflags=""
+with_xmms_libs=""
+AC_ARG_WITH(libxmms, [AS_HELP_STRING([--with-libxmms@<:@=PREFIX@:>@], [Path to libxmms.])],
+[
+       if test "x$withval" != "xno" \
+               && test "x$withval" != "xyes"
+       then
+               if test -f "$withval" && test -x "$withval";
+               then
+                       with_xmms_config="$withval"
+               else if test -x "$withval/bin/xmms-config"
+               then
+                       with_xmms_config="$withval/bin/xmms-config"
+               fi; fi
+               with_libxmms="yes"
+       else if test "x$withval" = "xno"
+       then
+               with_libxmms="no"
+       else
+               with_libxmms="yes"
+       fi; fi
+],
+[
+       with_libxmms="yes"
+])
+if test "x$with_libxmms" = "xyes"
+then
+       with_xmms_cflags=`$with_xmms_config --cflags 2>/dev/null`
+       xmms_config_status=$?
+
+       if test $xmms_config_status -ne 0
+       then
+               with_libxmms="no"
+       fi
+fi
+if test "x$with_libxmms" = "xyes"
+then
+       with_xmms_libs=`$with_xmms_config --libs 2>/dev/null`
+       xmms_config_status=$?
+
+       if test $xmms_config_status -ne 0
+       then
+               with_libxmms="no"
+       fi
+fi
+if test "x$with_libxmms" = "xyes"
+then
+       AC_CHECK_LIB(xmms, xmms_remote_get_info,
+       [
+               BUILD_WITH_LIBXMMS_CFLAGS="$with_xmms_cflags"
+               BUILD_WITH_LIBXMMS_LIBS="$with_xmms_libs"
+               AC_SUBST(BUILD_WITH_LIBXMMS_CFLAGS)
+               AC_SUBST(BUILD_WITH_LIBXMMS_LIBS)
+       ],
+       [
+               with_libxmms="no"
+       ],
+       [$with_xmms_libs])
+fi
+with_libxmms_numeric=0
+if test "x$with_libxmms" = "xyes"
+then
+       with_libxmms_numeric=1
+fi
+AC_DEFINE_UNQUOTED(HAVE_LIBXMMS, [$with_libxmms_numeric], [Define to 1 if you have the 'xmms' library (-lxmms).])
+AM_CONDITIONAL(BUILD_WITH_LIBXMMS, test "x$with_libxmms" = "xyes")
+# }}}
+
+# --with-libyajl {{{
+with_libyajl_cppflags=""
+with_libyajl_ldflags=""
+AC_ARG_WITH(libyajl, [AS_HELP_STRING([--with-libyajl@<:@=PREFIX@:>@], [Path to libyajl.])],
+[
+       if test "x$withval" != "xno" && test "x$withval" != "xyes"
+       then
+               with_libyajl_cppflags="-I$withval/include"
+               with_libyajl_ldflags="-L$withval/lib"
+               with_libyajl="yes"
+       else
+               with_libyajl="$withval"
+       fi
+],
+[
+       with_libyajl="yes"
+])
+if test "x$with_libyajl" = "xyes"
+then
+       SAVE_CPPFLAGS="$CPPFLAGS"
+       CPPFLAGS="$CPPFLAGS $with_libyajl_cppflags"
+
+       AC_CHECK_HEADERS(yajl/yajl_parse.h, [with_libyajl="yes"], [with_libyajl="no (yajl/yajl_parse.h not found)"])
+       AC_CHECK_HEADERS(yajl/yajl_version.h)
+
+       CPPFLAGS="$SAVE_CPPFLAGS"
+fi
+if test "x$with_libyajl" = "xyes"
+then
+       SAVE_CPPFLAGS="$CPPFLAGS"
+       SAVE_LDFLAGS="$LDFLAGS"
+       CPPFLAGS="$CPPFLAGS $with_libyajl_cppflags"
+       LDFLAGS="$LDFLAGS $with_libyajl_ldflags"
+
+       AC_CHECK_LIB(yajl, yajl_alloc, [with_libyajl="yes"], [with_libyajl="no (Symbol 'yajl_alloc' not found)"])
+
+       CPPFLAGS="$SAVE_CPPFLAGS"
+       LDFLAGS="$SAVE_LDFLAGS"
+fi
+if test "x$with_libyajl" = "xyes"
+then
+       BUILD_WITH_LIBYAJL_CPPFLAGS="$with_libyajl_cppflags"
+       BUILD_WITH_LIBYAJL_LDFLAGS="$with_libyajl_ldflags"
+       BUILD_WITH_LIBYAJL_LIBS="-lyajl"
+       AC_SUBST(BUILD_WITH_LIBYAJL_CPPFLAGS)
+       AC_SUBST(BUILD_WITH_LIBYAJL_LDFLAGS)
+       AC_SUBST(BUILD_WITH_LIBYAJL_LIBS)
+       AC_DEFINE(HAVE_LIBYAJL, 1, [Define if libyajl is present and usable.])
+fi
+AM_CONDITIONAL(BUILD_WITH_LIBYAJL, test "x$with_libyajl" = "xyes")
+# }}}
+
+# --with-mic {{{
+with_mic_cflags="-I/opt/intel/mic/sysmgmt/sdk/include"
+with_mic_ldpath="-L/opt/intel/mic/sysmgmt/sdk/lib/Linux"
+with_mic_libs=""
+AC_ARG_WITH(mic,[AS_HELP_STRING([--with-mic@<:@=PREFIX@:>@], [Path to Intel MIC Access API.])],
+[
+       if test "x$withval" = "xno"
+       then
+               with_mic="no"
+       else if test "x$withval" = "xyes"
+       then
+               with_mic="yes"
+       else if test -d "$with_mic/lib"
+       then
+               AC_MSG_NOTICE([Not checking for Intel Mic: Manually configured])
+               with_mic_cflags="-I$withval/include"
+               with_mic_ldpath="-L$withval/lib/Linux"
+               with_mic_libs="-lMicAccessSDK -lscif -lpthread"
+               with_mic="yes"
+       fi; fi; fi
+],
+[with_mic="yes"])
+if test "x$with_mic" = "xyes"
+then
+       SAVE_CPPFLAGS="$CPPFLAGS"
+       CPPFLAGS="$CPPFLAGS $with_mic_cflags"
+       AC_CHECK_HEADERS(MicAccessApi.h,[],[with_mic="no (MicAccessApi not found)"])
+       CPPFLAGS="$SAVE_CPPFLAGS"
+fi
+if test "x$with_mic" = "xyes"
+then
+       SAVE_CPPFLAGS="$CPPFLAGS"
+       SAVE_LDFLAGS="$LDFLAGS"
+
+       CPPFLAGS="$CPPFLAGS $with_mic_cflags"
+       LDFLAGS="$LDFLAGS $with_mic_ldpath"
+
+       AC_CHECK_LIB(MicAccessSDK, MicInitAPI,
+                       [with_mic_ldpath="$with_mic_ldpath"
+                       with_mic_libs="-lMicAccessSDK -lscif -lpthread"],
+                       [with_mic="no (symbol MicInitAPI not found)"],[-lscif -lpthread])
+
+       CPPFLAGS="$SAVE_CPPFLAGS"
+       LDFLAGS="$SAVE_LDFLAGS"
+fi
+
+if test "x$with_mic" = "xyes"
+then
+       BUILD_WITH_MIC_CPPFLAGS="$with_mic_cflags"
+       BUILD_WITH_MIC_LIBPATH="$with_mic_ldpath"
+       BUILD_WITH_MIC_LDADD="$with_mic_libs"
+       AC_SUBST(BUILD_WITH_MIC_CPPFLAGS)
+       AC_SUBST(BUILD_WITH_MIC_LIBPATH)
+       AC_SUBST(BUILD_WITH_MIC_LDADD)
+fi
+#}}}
+
+# --with-libvarnish {{{
+with_libvarnish_cppflags=""
+with_libvarnish_cflags=""
+with_libvarnish_libs=""
+AC_ARG_WITH(libvarnish, [AS_HELP_STRING([--with-libvarnish@<:@=PREFIX@:>@], [Path to libvarnish.])],
+[
+       if test "x$withval" = "xno"
+       then
+               with_libvarnish="no"
+       else if test "x$withval" = "xyes"
+       then
+               with_libvarnish="use_pkgconfig"
+       else if test -d "$with_libvarnish/lib"
+       then
+               AC_MSG_NOTICE([Not checking for libvarnish: Manually configured])
+               with_libvarnish_cflags="-I$withval/include"
+               with_libvarnish_libs="-L$withval/lib -lvarnishapi"
+               with_libvarnish="yes"
+       fi; fi; fi
+],
+[with_libvarnish="use_pkgconfig"])
+
+# configure using pkg-config
+if test "x$with_libvarnish" = "xuse_pkgconfig"
+then
+       if test "x$PKG_CONFIG" = "x"
+       then
+               with_libvarnish="no (Don't have pkg-config)"
+       fi
+fi
+if test "x$with_libvarnish" = "xuse_pkgconfig"
+then
+       AC_MSG_NOTICE([Checking for varnishapi using $PKG_CONFIG])
+       $PKG_CONFIG --exists 'varnishapi' 2>/dev/null
+       if test $? -ne 0
+       then
+               with_libvarnish="no (pkg-config doesn't know varnishapi)"
+       fi
+fi
+if test "x$with_libvarnish" = "xuse_pkgconfig"
+then
+       with_libvarnish_cflags="`$PKG_CONFIG --cflags 'varnishapi'`"
+       if test $? -ne 0
+       then
+               with_libvarnish="no ($PKG_CONFIG failed)"
+       fi
+       with_libvarnish_libs="`$PKG_CONFIG --libs 'varnishapi'`"
+       if test $? -ne 0
+       then
+               with_libvarnish="no ($PKG_CONFIG failed)"
+       fi
+fi
+if test "x$with_libvarnish" = "xuse_pkgconfig"
+then
+       with_libvarnish="yes"
+fi
+
+# with_libvarnish_cflags and with_libvarnish_libs are set up now, let's do
+# the actual checks.
+if test "x$with_libvarnish" = "xyes"
+then
+       SAVE_CPPFLAGS="$CPPFLAGS"
+       CPPFLAGS="$CPPFLAGS $with_libvarnish_cflags"
+       AC_CHECK_HEADERS(varnish/varnishapi.h, [], [with_libvarnish="no (varnish/varnishapi.h not found)"])
+
+       CPPFLAGS="$SAVE_CPPFLAGS"
+fi
+if test "x$with_libvarnish" = "xyes"
+then
+       SAVE_CPPFLAGS="$CPPFLAGS"
+       #SAVE_LDFLAGS="$LDFLAGS"
+
+       CPPFLAGS="$CPPFLAGS $with_libvarnish_cflags"
+       #LDFLAGS="$LDFLAGS $with_libvarnish_libs"
+
+    AC_CHECK_HEADERS(varnish/vsc.h,
+        [AC_DEFINE([HAVE_VARNISH_V3], [1], [Varnish 3 API support])],
+        [AC_DEFINE([HAVE_VARNISH_V2], [1], [Varnish 2 API support])])
+
+       CPPFLAGS="$SAVE_CPPFLAGS"
+       #LDFLAGS="$SAVE_LDFLAGS"
+fi
+if test "x$with_libvarnish" = "xyes"
+then
+       BUILD_WITH_LIBVARNISH_CFLAGS="$with_libvarnish_cflags"
+       BUILD_WITH_LIBVARNISH_LIBS="$with_libvarnish_libs"
+       AC_SUBST(BUILD_WITH_LIBVARNISH_CFLAGS)
+       AC_SUBST(BUILD_WITH_LIBVARNISH_LIBS)
+fi
+# }}}
+
+# pkg-config --exists 'libxml-2.0'; pkg-config --exists libvirt {{{
+with_libxml2="no (pkg-config isn't available)"
+with_libxml2_cflags=""
+with_libxml2_ldflags=""
+with_libvirt="no (pkg-config isn't available)"
+with_libvirt_cflags=""
+with_libvirt_ldflags=""
+if test "x$PKG_CONFIG" != "x"
+then
+       pkg-config --exists 'libxml-2.0' 2>/dev/null
+       if test "$?" = "0"
+       then
+               with_libxml2="yes"
+       else
+               with_libxml2="no (pkg-config doesn't know libxml-2.0)"
+       fi
+
+       pkg-config --exists libvirt 2>/dev/null
+       if test "$?" = "0"
+       then
+               with_libvirt="yes"
+       else
+               with_libvirt="no (pkg-config doesn't know libvirt)"
+       fi
+fi
+if test "x$with_libxml2" = "xyes"
+then
+       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`"
+       if test $? -ne 0
+       then
+               with_libxml2="no"
+       fi
+fi
+if test "x$with_libxml2" = "xyes"
+then
+       SAVE_CPPFLAGS="$CPPFLAGS"
+       CPPFLAGS="$CPPFLAGS $with_libxml2_cflags"
+
+       AC_CHECK_HEADERS(libxml/parser.h, [],
+                     [with_libxml2="no (libxml/parser.h not found)"])
+
+       CPPFLAGS="$SAVE_CPPFLAGS"
+fi
+if test "x$with_libxml2" = "xyes"
+then
+       SAVE_CFLAGS="$CFLAGS"
+       SAVE_LDFLAGS="$LDFLAGS"
+
+       CFLAGS="$CFLAGS $with_libxml2_cflags"
+       LDFLAGS="$LDFLAGS $with_libxml2_ldflags"
+
+       AC_CHECK_LIB(xml2, xmlXPathEval,
+                    [with_libxml2="yes"],
+                    [with_libxml2="no (symbol xmlXPathEval not found)"])
+
+       CFLAGS="$SAVE_CFLAGS"
+       LDFLAGS="$SAVE_LDFLAGS"
+fi
+dnl Add the right compiler flags and libraries.
+if test "x$with_libxml2" = "xyes"; then
+       BUILD_WITH_LIBXML2_CFLAGS="$with_libxml2_cflags"
+       BUILD_WITH_LIBXML2_LIBS="$with_libxml2_ldflags"
+       AC_SUBST(BUILD_WITH_LIBXML2_CFLAGS)
+       AC_SUBST(BUILD_WITH_LIBXML2_LIBS)
+fi
+if test "x$with_libvirt" = "xyes"
+then
+       with_libvirt_cflags="`pkg-config --cflags libvirt`"
+       if test $? -ne 0
+       then
+               with_libvirt="no"
+       fi
+       with_libvirt_ldflags="`pkg-config --libs libvirt`"
+       if test $? -ne 0
+       then
+               with_libvirt="no"
+       fi
+fi
+if test "x$with_libvirt" = "xyes"
+then
+       SAVE_CPPFLAGS="$CPPFLAGS"
+       CPPFLAGS="$CPPFLAGS $with_libvirt_cflags"
+
+       AC_CHECK_HEADERS(libvirt/libvirt.h, [],
+                     [with_libvirt="no (libvirt/libvirt.h not found)"])
+
+       CPPFLAGS="$SAVE_CPPFLAGS"
+fi
+if test "x$with_libvirt" = "xyes"
+then
+       SAVE_CFLAGS="$CFLAGS"
+       SAVE_LDFLAGS="$LDFLAGS"
+
+       CFLAGS="$CFLAGS $with_libvirt_cflags"
+       LDFLAGS="$LDFLAGS $with_libvirt_ldflags"
+
+       AC_CHECK_LIB(virt, virDomainBlockStats,
+                    [with_libvirt="yes"],
+                    [with_libvirt="no (symbol virDomainBlockStats not found)"])
+
+       CFLAGS="$SAVE_CFLAGS"
+       LDFLAGS="$SAVE_LDFLAGS"
+fi
+dnl Add the right compiler flags and libraries.
+if test "x$with_libvirt" = "xyes"; then
+       BUILD_WITH_LIBVIRT_CFLAGS="$with_libvirt_cflags"
+       BUILD_WITH_LIBVIRT_LIBS="$with_libvirt_ldflags"
+       AC_SUBST(BUILD_WITH_LIBVIRT_CFLAGS)
+       AC_SUBST(BUILD_WITH_LIBVIRT_LIBS)
+fi
+# }}}
+
+# $PKG_CONFIG --exists OpenIPMIpthread {{{
+with_libopenipmipthread="yes"
+with_libopenipmipthread_cflags=""
+with_libopenipmipthread_libs=""
+
+AC_MSG_CHECKING([for pkg-config])
+temp_result="no"
+if test "x$PKG_CONFIG" = "x"
+then
+       with_libopenipmipthread="no"
+       temp_result="no"
+else
+       temp_result="$PKG_CONFIG"
+fi
+AC_MSG_RESULT([$temp_result])
+
+if test "x$with_libopenipmipthread" = "xyes"
+then
+       AC_MSG_CHECKING([for libOpenIPMIpthread])
+       $PKG_CONFIG --exists OpenIPMIpthread 2>/dev/null
+       if test "$?" != "0"
+       then
+               with_libopenipmipthread="no (pkg-config doesn't know OpenIPMIpthread)"
+       fi
+       AC_MSG_RESULT([$with_libopenipmipthread])
+fi
+
+if test "x$with_libopenipmipthread" = "xyes"
+then
+       AC_MSG_CHECKING([for libOpenIPMIpthread CFLAGS])
+       temp_result="`$PKG_CONFIG --cflags OpenIPMIpthread`"
+       if test "$?" = "0"
+       then
+               with_libopenipmipthread_cflags="$temp_result"
+       else
+               with_libopenipmipthread="no ($PKG_CONFIG --cflags OpenIPMIpthread failed)"
+               temp_result="$PKG_CONFIG --cflags OpenIPMIpthread failed"
+       fi
+       AC_MSG_RESULT([$temp_result])
+fi
+
+if test "x$with_libopenipmipthread" = "xyes"
+then
+       AC_MSG_CHECKING([for libOpenIPMIpthread LDFLAGS])
+       temp_result="`$PKG_CONFIG --libs OpenIPMIpthread`"
+       if test "$?" = "0"
+       then
+               with_libopenipmipthread_ldflags="$temp_result"
+       else
+               with_libopenipmipthread="no ($PKG_CONFIG --libs OpenIPMIpthread failed)"
+               temp_result="$PKG_CONFIG --libs OpenIPMIpthread failed"
+       fi
+       AC_MSG_RESULT([$temp_result])
+fi
+
+if test "x$with_libopenipmipthread" = "xyes"
+then
+       SAVE_CPPFLAGS="$CPPFLAGS"
+       CPPFLAGS="$CPPFLAGS $with_libopenipmipthread_cflags"
+
+       AC_CHECK_HEADERS(OpenIPMI/ipmi_smi.h,
+                        [with_libopenipmipthread="yes"],
+                        [with_libopenipmipthread="no (OpenIPMI/ipmi_smi.h not found)"],
+[#include <OpenIPMI/ipmiif.h>
+#include <OpenIPMI/ipmi_err.h>
+#include <OpenIPMI/ipmi_posix.h>
+#include <OpenIPMI/ipmi_conn.h>
+])
+
+       CPPFLAGS="$SAVE_CPPFLAGS"
+fi
+
+if test "x$with_libopenipmipthread" = "xyes"
+then
+       BUILD_WITH_OPENIPMI_CFLAGS="$with_libopenipmipthread_cflags"
+       BUILD_WITH_OPENIPMI_LIBS="$with_libopenipmipthread_ldflags"
+       AC_SUBST(BUILD_WITH_OPENIPMI_CFLAGS)
+       AC_SUBST(BUILD_WITH_OPENIPMI_LIBS)
+fi
+# }}}
+
+PKG_CHECK_MODULES([LIBNOTIFY], [libnotify],
+               [with_libnotify="yes"],
+               [if test "x$LIBNOTIFY_PKG_ERRORS" = "x"; then
+                        with_libnotify="no"
+                else
+                        with_libnotify="no ($LIBNOTIFY_PKG_ERRORS)"
+                fi])
+
+# Check for enabled/disabled features
+#
+
+# AC_COLLECTD(name, enable/disable, info-text, feature/module)
+# ------------------------------------------------------------
+dnl
+m4_define([my_toupper], [m4_translit([$1], m4_defn([m4_cr_letters]), m4_defn([m4_cr_LETTERS]))])
+dnl
+AC_DEFUN(
+       [AC_COLLECTD],
+       [
+       m4_if([$1], [], [AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 1st argument must not be empty])])dnl
+       m4_if(
+               [$2],
+               [enable],
+               [dnl
+               m4_define([EnDis],[disabled])dnl
+               m4_define([YesNo],[no])dnl
+               ],dnl
+               [m4_if(
+                       [$2],
+                       [disable],
+                       [dnl
+                       m4_define([EnDis],[enabled])dnl
+                       m4_define([YesNo],[yes])dnl
+                       ],
+                       [dnl
+                       AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 2nd argument must be either enable or disable])dnl
+                       ]dnl
+               )]dnl
+       )dnl
+       m4_if([$3], [feature], [],
+               [m4_if(
+                       [$3], [module], [],
+                       [dnl
+                       AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 3rd argument must be either feature or disable])dnl
+                       ]dnl
+               )]dnl
+       )dnl
+       AC_ARG_ENABLE(
+               [$1],
+               AS_HELP_STRING([--$2-$1], [$2 $4 (EnDis by def)]),
+               [],
+               enable_$1='[YesNo]'dnl
+       )# AC_ARG_ENABLE
+if test "x$enable_$1" = "xno"
+then
+       collectd_$1=0
+else
+       if test "x$enable_$1" = "xyes"
+       then
+               collectd_$1=1
+       else
+               AC_MSG_NOTICE([please specify either --enable-$1 or --disable-$1; enabling $1.])
+               collectd_$1=1
+               enable_$1='yes'
+       fi
+fi
+       AC_DEFINE_UNQUOTED([COLLECT_]my_toupper([$1]), [$collectd_$1], [wether or not to enable $3 $4])
+       AM_CONDITIONAL([BUILD_]my_toupper([$3])[_]my_toupper([$1]), [test "x$enable_$1" = "xyes"])dnl
+       ]dnl
+)# AC_COLLECTD(name, enable/disable, info-text, feature/module)
+
+# AC_PLUGIN(name, default, info)
+# ------------------------------------------------------------
+dnl
+AC_DEFUN(
+  [AC_PLUGIN],
+  [
+    enable_plugin="no"
+    force="no"
+    AC_ARG_ENABLE([$1], AS_HELP_STRING([--enable-$1],[$3]),
+    [
+     if test "x$enableval" = "xyes"
+     then
+            enable_plugin="yes"
+     else if test "x$enableval" = "xforce"
+     then
+            enable_plugin="yes"
+            force="yes"
+     else
+            enable_plugin="no (disabled on command line)"
+     fi; fi
+    ],
+    [
+        if test "x$enable_all_plugins" = "xauto"
+        then
+            if test "x$2" = "xyes"
+            then
+                    enable_plugin="yes"
+            else
+                    enable_plugin="no"
+            fi
+        else
+            enable_plugin="$enable_all_plugins"
+        fi
+    ])
+    if test "x$enable_plugin" = "xyes"
+    then
+           if test "x$2" = "xyes" || test "x$force" = "xyes"
+           then
+                   AC_DEFINE([HAVE_PLUGIN_]my_toupper([$1]), 1, [Define to 1 if the $1 plugin is enabled.])
+                   if test "x$2" != "xyes"
+                   then
+                           dependency_warning="yes"
+                   fi
+           else # User passed "yes" but dependency checking yielded "no" => Dependency problem.
+                   dependency_error="yes"
+                   enable_plugin="no (dependency error)"
+           fi
+    fi
+    AM_CONDITIONAL([BUILD_PLUGIN_]my_toupper([$1]), test "x$enable_plugin" = "xyes")
+    enable_$1="$enable_plugin"
+  ]
+)# AC_PLUGIN(name, default, info)
+
+m4_divert_once([HELP_ENABLE], [
+collectd features:])
+# FIXME: Remove these calls to `AC_COLLECTD' and then remove that macro.
+AC_COLLECTD([debug],     [enable],  [feature], [debugging])
+AC_COLLECTD([daemon],    [disable], [feature], [daemon mode])
+AC_COLLECTD([getifaddrs],[enable],  [feature], [getifaddrs under Linux])
+
+dependency_warning="no"
+dependency_error="no"
+
+plugin_ascent="no"
+plugin_battery="no"
+plugin_bind="no"
+plugin_cgroups="no"
+plugin_conntrack="no"
+plugin_contextswitch="no"
+plugin_cpu="no"
+plugin_cpufreq="no"
+plugin_curl_json="no"
+plugin_curl_xml="no"
+plugin_df="no"
+plugin_disk="no"
+plugin_entropy="no"
+plugin_ethstat="no"
+plugin_fscache="no"
+plugin_interface="no"
+plugin_ipmi="no"
+plugin_ipvs="no"
+plugin_irq="no"
+plugin_libvirt="no"
+plugin_load="no"
+plugin_memory="no"
+plugin_multimeter="no"
+plugin_nfs="no"
+plugin_numa="no"
+plugin_perl="no"
+plugin_processes="no"
+plugin_protocols="no"
+plugin_serial="no"
+plugin_swap="no"
+plugin_tape="no"
+plugin_tcpconns="no"
+plugin_ted="no"
+plugin_thermal="no"
+plugin_users="no"
+plugin_uptime="no"
+plugin_vmem="no"
+plugin_vserver="no"
+plugin_wireless="no"
+plugin_zfs_arc="no"
+
+# Linux
+if test "x$ac_system" = "xLinux"
+then
+       plugin_battery="yes"
+       plugin_conntrack="yes"
+       plugin_contextswitch="yes"
+       plugin_cgroups="yes"
+       plugin_cpu="yes"
+       plugin_cpufreq="yes"
+       plugin_disk="yes"
+       plugin_entropy="yes"
+       plugin_fscache="yes"
+       plugin_interface="yes"
+       plugin_irq="yes"
+       plugin_load="yes"
+       plugin_lvm="yes"
+       plugin_memory="yes"
+       plugin_nfs="yes"
+       plugin_numa="yes"
+       plugin_processes="yes"
+       plugin_protocols="yes"
+       plugin_serial="yes"
+       plugin_swap="yes"
+       plugin_tcpconns="yes"
+       plugin_thermal="yes"
+       plugin_uptime="yes"
+       plugin_vmem="yes"
+       plugin_vserver="yes"
+       plugin_wireless="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
+               plugin_ipvs="yes"
+       fi
+fi
+
+if test "x$ac_system" = "xOpenBSD"
+then
+       plugin_tcpconns="yes"
+fi
+
+# Mac OS X devices
+if test "x$with_libiokit" = "xyes"
+then
+       plugin_battery="yes"
+       plugin_disk="yes"
+fi
+
+# AIX
+
+if test "x$ac_system" = "xAIX"
+then
+        plugin_tcpconns="yes"
+fi
+
+# FreeBSD
+
+if test "x$ac_system" = "xFreeBSD"
+then
+        plugin_zfs_arc="yes"
+fi
+
+
+if test "x$with_perfstat" = "xyes"
+then
+       plugin_cpu="yes"
+       plugin_contextswitch="yes"
+       plugin_disk="yes"
+       plugin_memory="yes"
+       plugin_swap="yes"
+       plugin_interface="yes"
+       plugin_load="yes"
+       plugin_uptime="yes"
+fi
+
+if test "x$with_procinfo" = "xyes"
+then
+       plugin_processes="yes"
+fi
+
+# Solaris
+if test "x$with_kstat" = "xyes"
+then
+       plugin_nfs="yes"
+       plugin_uptime="yes"
+       plugin_zfs_arc="yes"
+fi
+
+if test "x$with_devinfo$with_kstat" = "xyesyes"
+then
+       plugin_cpu="yes"
+       plugin_disk="yes"
+       plugin_interface="yes"
+       plugin_memory="yes"
+       plugin_tape="yes"
+fi
+
+# libstatgrab
+if test "x$with_libstatgrab" = "xyes"
+then
+       plugin_cpu="yes"
+       plugin_disk="yes"
+       plugin_interface="yes"
+       plugin_load="yes"
+       plugin_memory="yes"
+       plugin_swap="yes"
+       plugin_users="yes"
+fi
+
+if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes"
+then
+       plugin_ascent="yes"
+       if test "x$have_strptime" = "xyes"
+       then
+               plugin_bind="yes"
+       fi
+fi
+
+if test "x$with_libopenipmipthread" = "xyes"
+then
+       plugin_ipmi="yes"
+fi
+
+if test "x$with_libcurl" = "xyes" && test "x$with_libyajl" = "xyes"
+then
+       plugin_curl_json="yes"
+fi
+
+if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes"
+then
+       plugin_curl_xml="yes"
+fi
+
+if test "x$have_processor_info" = "xyes"
+then
+       plugin_cpu="yes"
+fi
+if test "x$have_sysctl" = "xyes"
+then
+       plugin_cpu="yes"
+       plugin_memory="yes"
+       plugin_uptime="yes"
+       if test "x$ac_system" = "xDarwin"
+       then
+               plugin_swap="yes"
+       fi
+fi
+if test "x$have_sysctlbyname" = "xyes"
+then
+       plugin_contextswitch="yes"
+       plugin_cpu="yes"
+       plugin_memory="yes"
+       plugin_tcpconns="yes"
+fi
+
+# Df plugin: Check if we know how to determine mount points first.
+#if test "x$have_listmntent" = "xyes"; then
+#      plugin_df="yes"
+#fi
+if test "x$have_getvfsstat" = "xyes" || test "x$have_getfsstat" = "xyes"
+then
+       plugin_df="yes"
+fi
+if test "x$c_cv_have_two_getmntent" = "xyes" || test "x$have_getmntent" = "xgen" || test "x$have_getmntent" = "xsun"
+then
+       plugin_df="yes"
+fi
+#if test "x$have_getmntent" = "xseq"
+#then
+#      plugin_df="yes"
+#fi
+if test "x$c_cv_have_one_getmntent" = "xyes"
+then
+       plugin_df="yes"
+fi
+
+# Df plugin: Check if we have either `statfs' or `statvfs' second.
+if test "x$plugin_df" = "xyes"
+then
+       plugin_df="no"
+       if test "x$have_statfs" = "xyes"
+       then
+               plugin_df="yes"
+       fi
+       if test "x$have_statvfs" = "xyes"
+       then
+               plugin_df="yes"
+       fi
+fi
+
+if test "x$have_linux_sockios_h$have_linux_ethtool_h" = "xyesyes"
+then
+       plugin_ethstat="yes"
+fi
+
+if test "x$have_getifaddrs" = "xyes"
+then
+       plugin_interface="yes"
+fi
+
+if test "x$with_libxml2" = "xyes" && test "x$with_libvirt" = "xyes"
+then
+       plugin_libvirt="yes"
+fi
+
+if test "x$have_getloadavg" = "xyes"
+then
+       plugin_load="yes"
+fi
+
+if test "x$c_cv_have_libperl$c_cv_have_perl_ithreads" = "xyesyes"
+then
+       plugin_perl="yes"
+fi
+
+# Mac OS X memory interface
+if test "x$have_host_statistics" = "xyes"
+then
+       plugin_memory="yes"
+fi
+
+if test "x$have_termios_h" = "xyes"
+then
+       plugin_multimeter="yes"
+       plugin_ted="yes"
+fi
+
+if test "x$have_thread_info" = "xyes"
+then
+       plugin_processes="yes"
+fi
+
+if test "x$with_kvm_getprocs" = "xyes" && test "x$have_struct_kinfo_proc_freebsd" = "xyes"
+then
+       plugin_processes="yes"
+fi
+
+if test "x$with_kvm_getswapinfo" = "xyes"
+then
+       plugin_swap="yes"
+fi
+
+if test "x$have_swapctl" = "xyes" && test "x$c_cv_have_swapctl_two_args" = "xyes"
+then
+       plugin_swap="yes"
+fi
+
+if test "x$with_kvm_openfiles$with_kvm_nlist" = "xyesyes"
+then
+       plugin_tcpconns="yes"
+fi
+
+if test "x$have_getutent" = "xyes"
+then
+       plugin_users="yes"
+fi
+if test "x$have_getutxent" = "xyes"
+then
+       plugin_users="yes"
+fi
+
+m4_divert_once([HELP_ENABLE], [
+collectd plugins:])
+
+AC_ARG_ENABLE([all-plugins],
+               AS_HELP_STRING([--enable-all-plugins],[enable all plugins (auto by def)]),
+               [
+                if test "x$enableval" = "xyes"
+                then
+                        enable_all_plugins="yes"
+                else if test "x$enableval" = "xauto"
+                then
+                        enable_all_plugins="auto"
+                else
+                        enable_all_plugins="no"
+                fi; fi
+               ],
+               [enable_all_plugins="auto"])
+
+m4_divert_once([HELP_ENABLE], [])
+
+AC_PLUGIN([aggregation], [yes],                [Aggregation plugin])
+AC_PLUGIN([amqp],        [$with_librabbitmq],  [AMQP output plugin])
+AC_PLUGIN([apache],      [$with_libcurl],      [Apache httpd statistics])
+AC_PLUGIN([apcups],      [yes],                [Statistics of UPSes by APC])
+AC_PLUGIN([apple_sensors], [$with_libiokit],   [Apple's hardware sensors])
+AC_PLUGIN([aquaero],     [$with_libaquaero5],  [Aquaero's hardware sensors])
+AC_PLUGIN([ascent],      [$plugin_ascent],     [AscentEmu player statistics])
+AC_PLUGIN([battery],     [$plugin_battery],    [Battery statistics])
+AC_PLUGIN([bind],        [$plugin_bind],       [ISC Bind nameserver statistics])
+AC_PLUGIN([conntrack],   [$plugin_conntrack],  [nf_conntrack statistics])
+AC_PLUGIN([contextswitch], [$plugin_contextswitch], [context switch statistics])
+AC_PLUGIN([cpufreq],     [$plugin_cpufreq],    [CPU frequency statistics])
+AC_PLUGIN([cpu],         [$plugin_cpu],        [CPU usage statistics])
+AC_PLUGIN([csv],         [yes],                [CSV output plugin])
+AC_PLUGIN([curl],        [$with_libcurl],      [CURL generic web statistics])
+AC_PLUGIN([curl_json],   [$plugin_curl_json],    [CouchDB statistics])
+AC_PLUGIN([curl_xml],   [$plugin_curl_xml],    [CURL generic xml statistics])
+AC_PLUGIN([cgroups],     [$plugin_cgroups],    [CGroups CPU usage accounting])
+AC_PLUGIN([dbi],         [$with_libdbi],       [General database statistics])
+AC_PLUGIN([df],          [$plugin_df],         [Filesystem usage statistics])
+AC_PLUGIN([disk],        [$plugin_disk],       [Disk usage statistics])
+AC_PLUGIN([dns],         [$with_libpcap],      [DNS traffic analysis])
+AC_PLUGIN([email],       [yes],                [EMail statistics])
+AC_PLUGIN([entropy],     [$plugin_entropy],    [Entropy statistics])
+AC_PLUGIN([ethstat],     [$plugin_ethstat],    [Stats from NIC driver])
+AC_PLUGIN([exec],        [yes],                [Execution of external programs])
+AC_PLUGIN([filecount],   [yes],                [Count files in directories])
+AC_PLUGIN([fscache],     [$plugin_fscache],    [fscache statistics])
+AC_PLUGIN([gmond],       [$with_libganglia],   [Ganglia plugin])
+AC_PLUGIN([hddtemp],     [yes],                [Query hddtempd])
+AC_PLUGIN([interface],   [$plugin_interface],  [Interface traffic statistics])
+AC_PLUGIN([ipmi],        [$plugin_ipmi],       [IPMI sensor statistics])
+AC_PLUGIN([iptables],    [$with_libiptc],      [IPTables rule counters])
+AC_PLUGIN([ipvs],        [$plugin_ipvs],       [IPVS connection statistics])
+AC_PLUGIN([irq],         [$plugin_irq],        [IRQ statistics])
+AC_PLUGIN([java],        [$with_java],         [Embed the Java Virtual Machine])
+AC_PLUGIN([libvirt],     [$plugin_libvirt],    [Virtual machine statistics])
+AC_PLUGIN([load],        [$plugin_load],       [System load])
+AC_PLUGIN([logfile],     [yes],                [File logging plugin])
+AC_PLUGIN([lpar],        [$with_perfstat],     [AIX logical partitions statistics])
+AC_PLUGIN([lvm],         [$with_liblvm2app],   [LVM statistics])
+AC_PLUGIN([madwifi],     [$have_linux_wireless_h], [Madwifi wireless statistics])
+AC_PLUGIN([match_empty_counter], [yes],        [The empty counter match])
+AC_PLUGIN([match_hashed], [yes],               [The hashed match])
+AC_PLUGIN([match_regex], [yes],                [The regex match])
+AC_PLUGIN([match_timediff], [yes],             [The timediff match])
+AC_PLUGIN([match_value], [yes],                [The value match])
+AC_PLUGIN([mbmon],       [yes],                [Query mbmond])
+AC_PLUGIN([md],          [$have_linux_raid_md_u_h], [md (Linux software RAID) devices])
+AC_PLUGIN([memcachec],   [$with_libmemcached], [memcachec statistics])
+AC_PLUGIN([memcached],   [yes],                [memcached statistics])
+AC_PLUGIN([memory],      [$plugin_memory],     [Memory usage])
+AC_PLUGIN([mic],         [$with_mic],          [Intel Many Integrated Core stats])
+AC_PLUGIN([modbus],      [$with_libmodbus],    [Modbus plugin])
+AC_PLUGIN([multimeter],  [$plugin_multimeter], [Read multimeter values])
+AC_PLUGIN([mysql],       [$with_libmysql],     [MySQL statistics])
+AC_PLUGIN([netapp],      [$with_libnetapp],    [NetApp plugin])
+AC_PLUGIN([netlink],     [$with_libmnl],       [Enhanced Linux network statistics])
+AC_PLUGIN([network],     [yes],                [Network communication plugin])
+AC_PLUGIN([nfs],         [$plugin_nfs],        [NFS statistics])
+AC_PLUGIN([nginx],       [$with_libcurl],      [nginx statistics])
+AC_PLUGIN([notify_desktop], [$with_libnotify], [Desktop notifications])
+AC_PLUGIN([notify_email], [$with_libesmtp],    [Email notifier])
+AC_PLUGIN([ntpd],        [yes],                [NTPd statistics])
+AC_PLUGIN([numa],        [$plugin_numa],       [NUMA virtual memory statistics])
+AC_PLUGIN([nut],         [$with_libupsclient], [Network UPS tools statistics])
+AC_PLUGIN([olsrd],       [yes],                [olsrd statistics])
+AC_PLUGIN([onewire],     [$with_libowcapi],    [OneWire sensor statistics])
+AC_PLUGIN([openvpn],     [yes],                [OpenVPN client statistics])
+AC_PLUGIN([oracle],      [$with_oracle],       [Oracle plugin])
+AC_PLUGIN([perl],        [$plugin_perl],       [Embed a Perl interpreter])
+AC_PLUGIN([pf],          [$have_net_pfvar_h],  [BSD packet filter (PF) statistics])
+# FIXME: Check for libevent, too.
+AC_PLUGIN([pinba],       [$have_protoc_c],     [Pinba statistics])
+AC_PLUGIN([ping],        [$with_liboping],     [Network latency statistics])
+AC_PLUGIN([postgresql],  [$with_libpq],        [PostgreSQL database statistics])
+AC_PLUGIN([powerdns],    [yes],                [PowerDNS statistics])
+AC_PLUGIN([processes],   [$plugin_processes],  [Process statistics])
+AC_PLUGIN([protocols],   [$plugin_protocols],  [Protocol (IP, TCP, ...) statistics])
+AC_PLUGIN([python],      [$with_python],       [Embed a Python interpreter])
+AC_PLUGIN([redis],       [$with_libcredis],    [Redis plugin])
+AC_PLUGIN([routeros],    [$with_librouteros],  [RouterOS plugin])
+AC_PLUGIN([rrdcached],   [$librrd_rrdc_update], [RRDTool output plugin])
+AC_PLUGIN([rrdtool],     [$with_librrd],       [RRDTool output plugin])
+AC_PLUGIN([sensors],     [$with_libsensors],   [lm_sensors statistics])
+AC_PLUGIN([serial],      [$plugin_serial],     [serial port traffic])
+AC_PLUGIN([sigrok],      [$with_libsigrok],    [sigrok acquisition sources])
+AC_PLUGIN([snmp],        [$with_libnetsnmp],   [SNMP querying plugin])
+AC_PLUGIN([statsd],      [yes],                [StatsD plugin])
+AC_PLUGIN([swap],        [$plugin_swap],       [Swap usage statistics])
+AC_PLUGIN([syslog],      [$have_syslog],       [Syslog logging plugin])
+AC_PLUGIN([table],       [yes],                [Parsing of tabular data])
+AC_PLUGIN([tail],        [yes],                [Parsing of logfiles])
+AC_PLUGIN([tail_csv],    [yes],                [Parsing of CSV files])
+AC_PLUGIN([tape],        [$plugin_tape],       [Tape drive statistics])
+AC_PLUGIN([target_notification], [yes],        [The notification target])
+AC_PLUGIN([target_replace], [yes],             [The replace target])
+AC_PLUGIN([target_scale],[yes],                [The scale target])
+AC_PLUGIN([target_set],  [yes],                [The set target])
+AC_PLUGIN([target_v5upgrade], [yes],           [The v5upgrade target])
+AC_PLUGIN([tcpconns],    [$plugin_tcpconns],   [TCP connection statistics])
+AC_PLUGIN([teamspeak2],  [yes],                [TeamSpeak2 server statistics])
+AC_PLUGIN([ted],         [$plugin_ted],        [Read The Energy Detective values])
+AC_PLUGIN([thermal],     [$plugin_thermal],    [Linux ACPI thermal zone statistics])
+AC_PLUGIN([threshold],   [yes],                [Threshold checking plugin])
+AC_PLUGIN([tokyotyrant], [$with_libtokyotyrant],  [TokyoTyrant database statistics])
+AC_PLUGIN([unixsock],    [yes],                [Unixsock communication plugin])
+AC_PLUGIN([uptime],      [$plugin_uptime],     [Uptime statistics])
+AC_PLUGIN([users],       [$plugin_users],      [User statistics])
+AC_PLUGIN([uuid],        [yes],                [UUID as hostname plugin])
+AC_PLUGIN([varnish],     [$with_libvarnish],   [Varnish cache statistics])
+AC_PLUGIN([vmem],        [$plugin_vmem],       [Virtual memory statistics])
+AC_PLUGIN([vserver],     [$plugin_vserver],    [Linux VServer statistics])
+AC_PLUGIN([wireless],    [$plugin_wireless],   [Wireless statistics])
+AC_PLUGIN([write_graphite], [yes],             [Graphite / Carbon output plugin])
+AC_PLUGIN([write_http],  [$with_libcurl],      [HTTP output plugin])
+AC_PLUGIN([write_mongodb], [$with_libmongoc],  [MongoDB output plugin])
+AC_PLUGIN([write_redis], [$with_libcredis],    [Redis output plugin])
+AC_PLUGIN([write_riemann], [$have_protoc_c],   [Riemann output plugin])
+AC_PLUGIN([xmms],        [$with_libxmms],      [XMMS statistics])
+AC_PLUGIN([zfs_arc],     [$plugin_zfs_arc],    [ZFS ARC statistics])
+
+dnl Default configuration file
+# Load either syslog or logfile
+LOAD_PLUGIN_SYSLOG=""
+LOAD_PLUGIN_LOGFILE=""
+
+AC_MSG_CHECKING([which default log plugin to load])
+default_log_plugin="none"
+if test "x$enable_syslog" = "xyes"
+then
+       default_log_plugin="syslog"
+else
+       LOAD_PLUGIN_SYSLOG="##"
+fi
+
+if test "x$enable_logfile" = "xyes"
+then
+       if test "x$default_log_plugin" = "xnone"
+       then
+               default_log_plugin="logfile"
+       else
+               LOAD_PLUGIN_LOGFILE="#"
+       fi
+else
+       LOAD_PLUGIN_LOGFILE="##"
+fi
+AC_MSG_RESULT([$default_log_plugin])
+
+AC_SUBST(LOAD_PLUGIN_SYSLOG)
+AC_SUBST(LOAD_PLUGIN_LOGFILE)
+
+DEFAULT_LOG_LEVEL="info"
+if test "x$enable_debug" = "xyes"
+then
+       DEFAULT_LOG_LEVEL="debug"
+fi
+AC_SUBST(DEFAULT_LOG_LEVEL)
+
+# Load only one of rrdtool, network, csv in the default config.
+LOAD_PLUGIN_RRDTOOL=""
+LOAD_PLUGIN_NETWORK=""
+LOAD_PLUGIN_CSV=""
+
+AC_MSG_CHECKING([which default write plugin to load])
+default_write_plugin="none"
+if test "x$enable_rrdtool" = "xyes"
+then
+       default_write_plugin="rrdtool"
+else
+       LOAD_PLUGIN_RRDTOOL="##"
+fi
+
+if test "x$enable_network" = "xyes"
+then
+       if test "x$default_write_plugin" = "xnone"
+       then
+               default_write_plugin="network"
+       else
+               LOAD_PLUGIN_NETWORK="#"
+       fi
+else
+       LOAD_PLUGIN_NETWORK="##"
+fi
+
+if test "x$enable_csv" = "xyes"
+then
+       if test "x$default_write_plugin" = "xnone"
+       then
+               default_write_plugin="csv"
+       else
+               LOAD_PLUGIN_CSV="#"
+       fi
+else
+       LOAD_PLUGIN_CSV="##"
+fi
+AC_MSG_RESULT([$default_write_plugin])
+
+AC_SUBST(LOAD_PLUGIN_RRDTOOL)
+AC_SUBST(LOAD_PLUGIN_NETWORK)
+AC_SUBST(LOAD_PLUGIN_CSV)
+
+dnl ip_vs.h
+if test "x$ac_system" = "xLinux" \
+       && 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
+PERL_BINDINGS_OPTIONS="PREFIX=${prefix}"
+AC_ARG_WITH(perl-bindings, [AS_HELP_STRING([--with-perl-bindings@<:@=OPTIONS@:>@], [Options passed to "perl Makefile.PL".])],
+[
+       if test "x$withval" != "xno" && test "x$withval" != "xyes"
+       then
+               PERL_BINDINGS_OPTIONS="$withval"
+               with_perl_bindings="yes"
+       else
+               with_perl_bindings="$withval"
+       fi
+],
+[
+       if test -n "$perl_interpreter"
+       then
+               with_perl_bindings="yes"
+       else
+               with_perl_bindings="no (no perl interpreter found)"
+       fi
+])
+if test "x$with_perl_bindings" = "xyes"
+then
+       PERL_BINDINGS="perl"
+else
+       PERL_BINDINGS=""
+fi
+AC_SUBST(PERL_BINDINGS)
+AC_SUBST(PERL_BINDINGS_OPTIONS)
+
+dnl libcollectdclient
+LCC_VERSION_MAJOR=`echo $PACKAGE_VERSION | cut -d'.' -f1`
+LCC_VERSION_MINOR=`echo $PACKAGE_VERSION | cut -d'.' -f2`
+LCC_VERSION_PATCH=`echo $PACKAGE_VERSION | cut -d'.' -f3`
+
+LCC_VERSION_EXTRA=`echo $PACKAGE_VERSION | cut -d'.' -f4-`
+
+LCC_VERSION_STRING="$LCC_VERSION_MAJOR.$LCC_VERSION_MINOR.$LCC_VERSION_PATCH"
+
+AC_SUBST(LCC_VERSION_MAJOR)
+AC_SUBST(LCC_VERSION_MINOR)
+AC_SUBST(LCC_VERSION_PATCH)
+AC_SUBST(LCC_VERSION_EXTRA)
+AC_SUBST(LCC_VERSION_STRING)
+
+AC_CONFIG_FILES(src/libcollectdclient/collectd/lcc_features.h)
+
+AC_CONFIG_FILES([Makefile src/Makefile src/collectd.conf src/libcollectdclient/Makefile src/libcollectdclient/libcollectdclient.pc src/liboconfig/Makefile bindings/Makefile bindings/java/Makefile])
+AC_OUTPUT
+
+if test "x$with_librrd" = "xyes" \
+       && test "x$librrd_threadsafe" != "xyes"
+then
+       with_librrd="yes (warning: librrd is not thread-safe)"
+fi
+
+if test "x$with_libperl" = "xyes"
+then
+       with_libperl="yes (version `$perl_interpreter -MConfig -e 'print $Config{version};'`)"
+else
+       enable_perl="no (needs libperl)"
+fi
+
+if test "x$enable_perl" = "xno" && test "x$c_cv_have_perl_ithreads" = "xno"
+then
+       enable_perl="no (libperl doesn't support ithreads)"
+fi
+
+if test "x$with_perl_bindings" = "xyes" \
+       && test "x$PERL_BINDINGS_OPTIONS" != "x"
+then
+       with_perl_bindings="yes ($PERL_BINDINGS_OPTIONS)"
+fi
+
+cat <<EOF;
+
+Configuration:
+  Libraries:
+    intel mic . . . . . . $with_mic
+    libaquaero5 . . . . . $with_libaquaero5
+    libcurl . . . . . . . $with_libcurl
+    libdbi  . . . . . . . $with_libdbi
+    libcredis . . . . . . $with_libcredis
+    libesmtp  . . . . . . $with_libesmtp
+    libganglia  . . . . . $with_libganglia
+    libgcrypt . . . . . . $with_libgcrypt
+    libiokit  . . . . . . $with_libiokit
+    libiptc . . . . . . . $with_libiptc
+    libjvm  . . . . . . . $with_java
+    libkstat  . . . . . . $with_kstat
+    libkvm  . . . . . . . $with_libkvm
+    libmemcached  . . . . $with_libmemcached
+    libmnl  . . . . . . . $with_libmnl
+    libmodbus . . . . . . $with_libmodbus
+    libmysql  . . . . . . $with_libmysql
+    libnetapp . . . . . . $with_libnetapp
+    libnetsnmp  . . . . . $with_libnetsnmp
+    libnotify . . . . . . $with_libnotify
+    liboconfig  . . . . . $with_liboconfig
+    libopenipmi . . . . . $with_libopenipmipthread
+    liboping  . . . . . . $with_liboping
+    libpcap . . . . . . . $with_libpcap
+    libperfstat . . . . . $with_perfstat
+    libperl . . . . . . . $with_libperl
+    libpq . . . . . . . . $with_libpq
+    libpthread  . . . . . $with_libpthread
+    librabbitmq . . . . . $with_librabbitmq
+    librouteros . . . . . $with_librouteros
+    librrd  . . . . . . . $with_librrd
+    libsensors  . . . . . $with_libsensors
+    libsigrok   . . . . . $with_libsigrok
+    libstatgrab . . . . . $with_libstatgrab
+    libtokyotyrant  . . . $with_libtokyotyrant
+    libupsclient  . . . . $with_libupsclient
+    libvarnish  . . . . . $with_libvarnish
+    libvirt . . . . . . . $with_libvirt
+    libxml2 . . . . . . . $with_libxml2
+    libxmms . . . . . . . $with_libxmms
+    libyajl . . . . . . . $with_libyajl
+    libevent  . . . . . . $with_libevent
+    protobuf-c  . . . . . $have_protoc_c
+    oracle  . . . . . . . $with_oracle
+    python  . . . . . . . $with_python
+
+  Features:
+    daemon mode . . . . . $enable_daemon
+    debug . . . . . . . . $enable_debug
+
+  Bindings:
+    perl  . . . . . . . . $with_perl_bindings
+
+  Modules:
+    aggregation . . . . . $enable_aggregation
+    amqp    . . . . . . . $enable_amqp
+    apache  . . . . . . . $enable_apache
+    apcups  . . . . . . . $enable_apcups
+    aquaero . . . . . . . $enable_aquaero
+    apple_sensors . . . . $enable_apple_sensors
+    ascent  . . . . . . . $enable_ascent
+    battery . . . . . . . $enable_battery
+    bind  . . . . . . . . $enable_bind
+    conntrack . . . . . . $enable_conntrack
+    contextswitch . . . . $enable_contextswitch
+    cgroups . . . . . . . $enable_cgroups
+    cpu . . . . . . . . . $enable_cpu
+    cpufreq . . . . . . . $enable_cpufreq
+    csv . . . . . . . . . $enable_csv
+    curl  . . . . . . . . $enable_curl
+    curl_json . . . . . . $enable_curl_json
+    curl_xml  . . . . . . $enable_curl_xml
+    dbi . . . . . . . . . $enable_dbi
+    df  . . . . . . . . . $enable_df
+    disk  . . . . . . . . $enable_disk
+    dns . . . . . . . . . $enable_dns
+    email . . . . . . . . $enable_email
+    entropy . . . . . . . $enable_entropy
+    ethstat . . . . . . . $enable_ethstat
+    exec  . . . . . . . . $enable_exec
+    filecount . . . . . . $enable_filecount
+    fscache . . . . . . . $enable_fscache
+    gmond . . . . . . . . $enable_gmond
+    hddtemp . . . . . . . $enable_hddtemp
+    interface . . . . . . $enable_interface
+    ipmi  . . . . . . . . $enable_ipmi
+    iptables  . . . . . . $enable_iptables
+    ipvs  . . . . . . . . $enable_ipvs
+    irq . . . . . . . . . $enable_irq
+    java  . . . . . . . . $enable_java
+    libvirt . . . . . . . $enable_libvirt
+    load  . . . . . . . . $enable_load
+    logfile . . . . . . . $enable_logfile
+    lpar  . . . . . . . . $enable_lpar
+    lvm . . . . . . . . . $enable_lvm
+    madwifi . . . . . . . $enable_madwifi
+    match_empty_counter . $enable_match_empty_counter
+    match_hashed  . . . . $enable_match_hashed
+    match_regex . . . . . $enable_match_regex
+    match_timediff  . . . $enable_match_timediff
+    match_value . . . . . $enable_match_value
+    mbmon . . . . . . . . $enable_mbmon
+    md  . . . . . . . . . $enable_md
+    memcachec . . . . . . $enable_memcachec
+    memcached . . . . . . $enable_memcached
+    memory  . . . . . . . $enable_memory
+    mic . . . . . . . . . $enable_mic
+    modbus  . . . . . . . $enable_modbus
+    multimeter  . . . . . $enable_multimeter
+    mysql . . . . . . . . $enable_mysql
+    netapp  . . . . . . . $enable_netapp
+    netlink . . . . . . . $enable_netlink
+    network . . . . . . . $enable_network
+    nfs . . . . . . . . . $enable_nfs
+    nginx . . . . . . . . $enable_nginx
+    notify_desktop  . . . $enable_notify_desktop
+    notify_email  . . . . $enable_notify_email
+    ntpd  . . . . . . . . $enable_ntpd
+    numa  . . . . . . . . $enable_numa
+    nut . . . . . . . . . $enable_nut
+    olsrd . . . . . . . . $enable_olsrd
+    onewire . . . . . . . $enable_onewire
+    openvpn . . . . . . . $enable_openvpn
+    oracle  . . . . . . . $enable_oracle
+    perl  . . . . . . . . $enable_perl
+    pf  . . . . . . . . . $enable_pf
+    pinba . . . . . . . . $enable_pinba
+    ping  . . . . . . . . $enable_ping
+    postgresql  . . . . . $enable_postgresql
+    powerdns  . . . . . . $enable_powerdns
+    processes . . . . . . $enable_processes
+    protocols . . . . . . $enable_protocols
+    python  . . . . . . . $enable_python
+    redis . . . . . . . . $enable_redis
+    routeros  . . . . . . $enable_routeros
+    rrdcached . . . . . . $enable_rrdcached
+    rrdtool . . . . . . . $enable_rrdtool
+    sensors . . . . . . . $enable_sensors
+    serial  . . . . . . . $enable_serial
+    sigrok  . . . . . . . $enable_sigrok
+    snmp  . . . . . . . . $enable_snmp
+    statsd  . . . . . . . $enable_statsd
+    swap  . . . . . . . . $enable_swap
+    syslog  . . . . . . . $enable_syslog
+    table . . . . . . . . $enable_table
+    tail  . . . . . . . . $enable_tail
+    tail_csv  . . . . . . $enable_tail_csv
+    tape  . . . . . . . . $enable_tape
+    target_notification . $enable_target_notification
+    target_replace  . . . $enable_target_replace
+    target_scale  . . . . $enable_target_scale
+    target_set  . . . . . $enable_target_set
+    target_v5upgrade  . . $enable_target_v5upgrade
+    tcpconns  . . . . . . $enable_tcpconns
+    teamspeak2  . . . . . $enable_teamspeak2
+    ted . . . . . . . . . $enable_ted
+    thermal . . . . . . . $enable_thermal
+    threshold . . . . . . $enable_threshold
+    tokyotyrant . . . . . $enable_tokyotyrant
+    unixsock  . . . . . . $enable_unixsock
+    uptime  . . . . . . . $enable_uptime
+    users . . . . . . . . $enable_users
+    uuid  . . . . . . . . $enable_uuid
+    varnish . . . . . . . $enable_varnish
+    vmem  . . . . . . . . $enable_vmem
+    vserver . . . . . . . $enable_vserver
+    wireless  . . . . . . $enable_wireless
+    write_graphite  . . . $enable_write_graphite
+    write_http  . . . . . $enable_write_http
+    write_mongodb . . . . $enable_write_mongodb
+    write_redis . . . . . $enable_write_redis
+    write_riemann . . . . $enable_write_riemann
+    xmms  . . . . . . . . $enable_xmms
+    zfs_arc . . . . . . . $enable_zfs_arc
+
+EOF
+
+if test "x$dependency_error" = "xyes"; then
+       AC_MSG_ERROR("Some plugins are missing dependencies - see the summary above for details")
+fi
+
+if test "x$dependency_warning" = "xyes"; then
+       AC_MSG_WARN("Some plugins seem to have missing dependencies but have been enabled forcibly - see the summary above for details")
+fi
+
+# vim: set fdm=marker :
diff --git a/configure.in b/configure.in
deleted file mode 100644 (file)
index c4d9558..0000000
+++ /dev/null
@@ -1,5566 +0,0 @@
-dnl Process this file with autoconf to produce a configure script.
-AC_INIT(collectd, [m4_esyscmd(./version-gen.sh)])
-AC_CONFIG_SRCDIR(src/collectd.c)
-AC_CONFIG_HEADERS(src/config.h)
-AC_CONFIG_AUX_DIR([libltdl/config])
-
-m4_ifdef([LT_PACKAGE_VERSION],
-       # libtool >= 2.2
-       [
-        LT_CONFIG_LTDL_DIR([libltdl])
-        LT_INIT([dlopen])
-        LTDL_INIT([convenience])
-        AC_DEFINE(LIBTOOL_VERSION, 2, [Define to used libtool version.])
-       ]
-,
-       # libtool <= 1.5
-       [
-        AC_LIBLTDL_CONVENIENCE
-        AC_SUBST(LTDLINCL)
-        AC_SUBST(LIBLTDL)
-        AC_LIBTOOL_DLOPEN
-        AC_CONFIG_SUBDIRS(libltdl)
-        AC_DEFINE(LIBTOOL_VERSION, 1, [Define to used libtool version.])
-       ]
-)
-
-AM_INIT_AUTOMAKE([tar-pax dist-bzip2])
-AC_LANG(C)
-
-AC_PREFIX_DEFAULT("/opt/collectd")
-
-AC_SYS_LARGEFILE
-
-#
-# Checks for programs.
-#
-AC_PROG_CC
-AC_PROG_CPP
-AC_PROG_INSTALL
-AC_PROG_LN_S
-AC_PROG_MAKE_SET
-AM_PROG_CC_C_O
-AM_CONDITIONAL(COMPILER_IS_GCC, test "x$GCC" = "xyes")
-
-AC_DISABLE_STATIC
-AC_PROG_LIBTOOL
-AC_PROG_LEX
-AC_PROG_YACC
-PKG_PROG_PKG_CONFIG
-
-AC_CHECK_PROG([have_protoc_c], [protoc-c], [yes], [no])
-AC_CHECK_HEADERS([google/protobuf-c/protobuf-c.h],
-                 [have_protobuf_c_h="yes"],
-                 [have_protobuf_c_h="no"])
-if test "x$have_protoc_c" = "xyes" && test "x$have_protobuf_c_h" != "xyes"
-then
-       have_protoc_c="no (unable to find <google/protobuf-c/protobuf-c.h>)"
-fi
-AM_CONDITIONAL(HAVE_PROTOC_C, test "x$have_protoc_c" = "xyes")
-
-AC_MSG_CHECKING([for kernel type ($host_os)])
-case $host_os in
-       *linux*)
-       AC_DEFINE([KERNEL_LINUX], 1, [True if program is to be compiled for a Linux kernel])
-       ac_system="Linux"
-       ;;
-       *solaris*)
-       AC_DEFINE([KERNEL_SOLARIS], 1, [True if program is to be compiled for a Solaris kernel])
-       ac_system="Solaris"
-       ;;
-       *darwin*)
-       ac_system="Darwin"
-       ;;
-       *openbsd*)
-       ac_system="OpenBSD"
-       ;;
-       *aix*)
-       AC_DEFINE([KERNEL_AIX], 1, [True if program is to be compiled for a AIX kernel])
-       ac_system="AIX"
-       ;;
-       *freebsd*)
-       AC_DEFINE([KERNEL_FREEBSD], 1, [True if program is to be compiled for a FreeBSD kernel])
-       ac_system="FreeBSD"
-       ;;
-       *)
-       ac_system="unknown"
-esac
-AC_MSG_RESULT([$ac_system])
-
-if test "x$ac_system" = "xLinux"
-then
-       AC_ARG_VAR([KERNEL_DIR], [path to Linux kernel sources])
-       if test -z "$KERNEL_DIR"
-       then
-               KERNEL_DIR="/lib/modules/`uname -r`/source"
-       fi
-
-       KERNEL_CFLAGS="-I$KERNEL_DIR/include"
-       AC_SUBST(KERNEL_CFLAGS)
-fi
-
-if test "x$ac_system" = "xSolaris"
-then
-       AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1, [Define to enforce POSIX thread semantics under Solaris.])
-       AC_DEFINE(_REENTRANT,               1, [Define to enable reentrancy interfaces.])
-fi
-if test "x$ac_system" = "xAIX"
-then
-       AC_DEFINE(_THREAD_SAFE_ERRNO, 1, [Define to use the thread-safe version of errno under AIX.])
-fi
-
-# Where to install .pc files.
-pkgconfigdir="${libdir}/pkgconfig"
-AC_SUBST(pkgconfigdir)
-
-# Check for standards compliance mode
-AC_ARG_ENABLE(standards,
-             AS_HELP_STRING([--enable-standards], [Enable standards compliance mode]),
-             [enable_standards="$enableval"],
-             [enable_standards="no"])
-if test "x$enable_standards" = "xyes"
-then
-       AC_DEFINE(_ISOC99_SOURCE,        1, [Define to enforce ISO C99 compliance.])
-       AC_DEFINE(_POSIX_C_SOURCE, 200809L, [Define to enforce POSIX.1-2008 compliance.])
-       AC_DEFINE(_XOPEN_SOURCE,       700, [Define to enforce X/Open 7 (XSI) compliance.])
-       AC_DEFINE(_REENTRANT,            1, [Define to enable reentrancy interfaces.])
-       if test "x$GCC" = "xyes"
-       then
-               CFLAGS="$CFLAGS -std=c99"
-       fi
-fi
-AM_CONDITIONAL(BUILD_FEATURE_STANDARDS, test "x$enable_standards" = "xyes")
-
-#
-# Checks for header files.
-#
-AC_HEADER_STDC
-AC_HEADER_SYS_WAIT
-AC_HEADER_DIRENT
-AC_HEADER_STDBOOL
-
-AC_CHECK_HEADERS(stdio.h errno.h math.h stdarg.h syslog.h fcntl.h signal.h assert.h sys/types.h sys/socket.h sys/select.h poll.h netdb.h arpa/inet.h sys/resource.h sys/param.h kstat.h regex.h sys/ioctl.h endian.h sys/isa_defs.h fnmatch.h libgen.h)
-
-# For ping library
-AC_CHECK_HEADERS(netinet/in_systm.h, [], [],
-[#if HAVE_STDINT_H
-# include <stdint.h>
-#endif
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-])
-AC_CHECK_HEADERS(netinet/in.h, [], [],
-[#if HAVE_STDINT_H
-# include <stdint.h>
-#endif
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#if HAVE_NETINET_IN_SYSTM_H
-# include <netinet/in_systm.h>
-#endif
-])
-AC_CHECK_HEADERS(netinet/ip.h, [], [],
-[#if HAVE_STDINT_H
-# include <stdint.h>
-#endif
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#if HAVE_NETINET_IN_SYSTM_H
-# include <netinet/in_systm.h>
-#endif
-#if HAVE_NETINET_IN_H
-# include <netinet/in.h>
-#endif
-])
-AC_CHECK_HEADERS(netinet/ip_icmp.h, [], [],
-[#if HAVE_STDINT_H
-# include <stdint.h>
-#endif
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#if HAVE_NETINET_IN_SYSTM_H
-# include <netinet/in_systm.h>
-#endif
-#if HAVE_NETINET_IN_H
-# include <netinet/in.h>
-#endif
-#if HAVE_NETINET_IP_H
-# include <netinet/ip.h>
-#endif
-])
-AC_CHECK_HEADERS(netinet/ip_var.h, [], [],
-[#if HAVE_STDINT_H
-# include <stdint.h>
-#endif
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#if HAVE_NETINET_IN_SYSTM_H
-# include <netinet/in_systm.h>
-#endif
-#if HAVE_NETINET_IN_H
-# include <netinet/in.h>
-#endif
-#if HAVE_NETINET_IP_H
-# include <netinet/ip.h>
-#endif
-])
-AC_CHECK_HEADERS(netinet/ip6.h, [], [],
-[#if HAVE_STDINT_H
-# include <stdint.h>
-#endif
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#if HAVE_NETINET_IN_SYSTM_H
-# include <netinet/in_systm.h>
-#endif
-#if HAVE_NETINET_IN_H
-# include <netinet/in.h>
-#endif
-])
-AC_CHECK_HEADERS(netinet/icmp6.h, [], [],
-[#if HAVE_STDINT_H
-# include <stdint.h>
-#endif
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#if HAVE_NETINET_IN_SYSTM_H
-# include <netinet/in_systm.h>
-#endif
-#if HAVE_NETINET_IN_H
-# include <netinet/in.h>
-#endif
-#if HAVE_NETINET_IP6_H
-# include <netinet/ip6.h>
-#endif
-])
-AC_CHECK_HEADERS(netinet/tcp.h, [], [],
-[#if HAVE_STDINT_H
-# include <stdint.h>
-#endif
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#if HAVE_NETINET_IN_SYSTM_H
-# include <netinet/in_systm.h>
-#endif
-#if HAVE_NETINET_IN_H
-# include <netinet/in.h>
-#endif
-#if HAVE_NETINET_IP_H
-# include <netinet/ip.h>
-#endif
-])
-AC_CHECK_HEADERS(netinet/udp.h, [], [],
-[#if HAVE_STDINT_H
-# include <stdint.h>
-#endif
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#if HAVE_NETINET_IN_SYSTM_H
-# include <netinet/in_systm.h>
-#endif
-#if HAVE_NETINET_IN_H
-# include <netinet/in.h>
-#endif
-#if HAVE_NETINET_IP_H
-# include <netinet/ip.h>
-#endif
-])
-
-# For cpu modules
-AC_CHECK_HEADERS(sys/dkstat.h)
-if test "x$ac_system" = "xDarwin"
-then
-       AC_CHECK_HEADERS(mach/mach_init.h mach/host_priv.h mach/mach_error.h mach/mach_host.h mach/mach_port.h mach/mach_types.h mach/message.h mach/processor_set.h mach/processor.h mach/processor_info.h mach/task.h mach/thread_act.h mach/vm_region.h mach/vm_map.h mach/vm_prot.h mach/vm_statistics.h mach/kern_return.h)
-       AC_CHECK_HEADERS(CoreFoundation/CoreFoundation.h IOKit/IOKitLib.h IOKit/IOTypes.h IOKit/ps/IOPSKeys.h IOKit/IOBSD.h IOKit/storage/IOBlockStorageDriver.h)
-       # For the battery plugin
-       AC_CHECK_HEADERS(IOKit/ps/IOPowerSources.h, [], [],
-[
-#if HAVE_IOKIT_IOKITLIB_H
-#  include <IOKit/IOKitLib.h>
-#endif
-#if HAVE_IOKIT_IOTYPES_H
-#  include <IOKit/IOTypes.h>
-#endif
-])
-
-fi
-
-AC_CHECK_HEADERS(sys/sysctl.h, [], [],
-[
-#if HAVE_SYS_TYPES_H
-#  include <sys/types.h>
-#endif
-#if HAVE_SYS_PARAM_H
-# include <sys/param.h>
-#endif
-])
-
-AC_MSG_CHECKING([for sysctl kern.cp_times])
-if test -x /sbin/sysctl
-then
-       /sbin/sysctl kern.cp_times 2>/dev/null
-       if test $? -eq 0
-       then
-               AC_MSG_RESULT([yes])
-               AC_DEFINE(HAVE_SYSCTL_KERN_CP_TIMES, 1,
-               [Define if sysctl supports kern.cp_times])
-       else
-               AC_MSG_RESULT([no])
-       fi
-else
-       AC_MSG_RESULT([no])
-fi
-
-# For hddtemp module
-AC_CHECK_HEADERS(linux/major.h)
-
-# For md module (Linux only)
-if test "x$ac_system" = "xLinux"
-then
-       AC_CHECK_HEADERS(linux/raid/md_u.h,
-                        [have_linux_raid_md_u_h="yes"],
-                        [have_linux_raid_md_u_h="no"],
-[
-#include <sys/ioctl.h>
-#include <linux/major.h>
-#include <linux/types.h>
-])
-else
-       have_linux_raid_md_u_h="no"
-fi
-
-# For the swap module
-have_linux_wireless_h="no"
-if test "x$ac_system" = "xLinux"
-then
-  AC_CHECK_HEADERS(linux/wireless.h,
-                  [have_linux_wireless_h="yes"],
-                  [have_linux_wireless_h="no"],
-[
-#include <dirent.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-])
-fi
-
-# For the swap module
-have_sys_swap_h="yes"
-AC_CHECK_HEADERS(sys/swap.h vm/anon.h, [], [have_sys_swap_h="no"],
-[
-#undef _FILE_OFFSET_BITS
-#undef _LARGEFILE64_SOURCE
-#if HAVE_SYS_TYPES_H
-#  include <sys/types.h>
-#endif
-#if HAVE_SYS_PARAM_H
-# include <sys/param.h>
-#endif
-])
-
-if test "x$have_sys_swap_h$ac_system" = "xnoSolaris"
-then
-       hint_64=""
-       if test "x$GCC" = "xyes"
-       then
-               hint_64="CFLAGS='-m64'"
-       else
-               hint_64="CFLAGS='-xarch=v9'"
-       fi
-       AC_MSG_NOTICE([Solaris detected and sys/swap.h not usable. Try building a 64-bit binary ($hint_64 ./configure).])
-fi
-
-# For load module
-# For the processes plugin
-# For users module
-AC_CHECK_HEADERS(sys/loadavg.h linux/config.h utmp.h utmpx.h)
-
-# For interface plugin
-AC_CHECK_HEADERS(ifaddrs.h)
-AC_CHECK_HEADERS(net/if.h, [], [],
-[
-#if HAVE_SYS_TYPES_H
-#  include <sys/types.h>
-#endif
-#if HAVE_SYS_SOCKET_H
-#  include <sys/socket.h>
-#endif
-])
-AC_CHECK_HEADERS(linux/if.h, [], [],
-[
-#if HAVE_SYS_TYPES_H
-#  include <sys/types.h>
-#endif
-#if HAVE_SYS_SOCKET_H
-#  include <sys/socket.h>
-#endif
-])
-AC_CHECK_HEADERS(linux/netdevice.h, [], [],
-[
-#if HAVE_SYS_TYPES_H
-#  include <sys/types.h>
-#endif
-#if HAVE_SYS_SOCKET_H
-#  include <sys/socket.h>
-#endif
-#if HAVE_LINUX_IF_H
-# include <linux/if.h>
-#endif
-])
-
-# For ethstat module
-AC_CHECK_HEADERS(linux/sockios.h,
-    [have_linux_sockios_h="yes"],
-    [have_linux_sockios_h="no"],
-    [
-#if HAVE_SYS_IOCTL_H
-# include <sys/ioctl.h>
-#endif
-#if HAVE_NET_IF_H
-# include <net/if.h>
-#endif
-    ])
-AC_CHECK_HEADERS(linux/ethtool.h,
-    [have_linux_ethtool_h="yes"],
-    [have_linux_ethtool_h="no"],
-    [
-#if HAVE_SYS_IOCTL_H
-# include <sys/ioctl.h>
-#endif
-#if HAVE_NET_IF_H
-# include <net/if.h>
-#endif
-#if HAVE_LINUX_SOCKIOS_H
-# include <linux/sockios.h>
-#endif
-    ])
-
-# 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
-       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$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, [], [],
-[
-#if HAVE_SYS_TYPES_H
-#  include <sys/types.h>
-#endif
-#if HAVE_SYS_PARAM_H
-# include <sys/param.h>
-#endif
-])
-
-# For mount interface
-AC_CHECK_HEADERS(sys/mount.h, [], [],
-[
-#if HAVE_SYS_TYPES_H
-#  include <sys/types.h>
-#endif
-#if HAVE_SYS_PARAM_H
-# include <sys/param.h>
-#endif
-])
-
-# For the email plugin
-AC_CHECK_HEADERS(linux/un.h, [], [],
-[
-#if HAVE_SYS_SOCKET_H
-#      include <sys/socket.h>
-#endif
-])
-
-AC_CHECK_HEADERS(pwd.h grp.h sys/un.h ctype.h limits.h xfs/xqm.h fs_info.h fshelp.h paths.h mntent.h mnttab.h sys/fstyp.h sys/fs_types.h sys/mntent.h sys/mnttab.h sys/statfs.h sys/statvfs.h sys/vfs.h sys/vfstab.h kvm.h wordexp.h)
-
-# For the dns plugin
-AC_CHECK_HEADERS(arpa/nameser.h)
-AC_CHECK_HEADERS(arpa/nameser_compat.h, [], [],
-[
-#if HAVE_ARPA_NAMESER_H
-# include <arpa/nameser.h>
-#endif
-])
-
-AC_CHECK_HEADERS(net/if_arp.h, [], [],
-[#if HAVE_SYS_SOCKET_H
-# include <sys/socket.h>
-#endif
-])
-AC_CHECK_HEADERS(net/ppp_defs.h)
-AC_CHECK_HEADERS(net/if_ppp.h, [], [],
-[#if HAVE_NET_PPP_DEFS_H
-# include <net/ppp_defs.h>
-#endif
-])
-AC_CHECK_HEADERS(netinet/if_ether.h, [], [],
-[#if HAVE_STDINT_H
-# include <stdint.h>
-#endif
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#if HAVE_SYS_SOCKET_H
-# include <sys/socket.h>
-#endif
-#if HAVE_NET_IF_H
-# include <net/if.h>
-#endif
-#if HAVE_NETINET_IN_H
-# include <netinet/in.h>
-#endif
-])
-
-AC_CHECK_HEADERS(netinet/ip_compat.h)
-
-have_net_pfvar_h="no"
-AC_CHECK_HEADERS(net/pfvar.h,
-               [have_net_pfvar_h="yes"],
-               [have_net_pfvar_h="no"],
-[
-#if HAVE_SYS_IOCTL_H
-# include <sys/ioctl.h>
-#endif
-#if HAVE_SYS_SOCKET_H
-# include <sys/socket.h>
-#endif
-#if HAVE_NET_IF_H
-# include <net/if.h>
-#endif
-])
-
-# For the multimeter plugin
-have_termios_h="no"
-AC_CHECK_HEADERS(termios.h, [have_termios_h="yes"])
-
-#
-# Checks for typedefs, structures, and compiler characteristics.
-#
-AC_C_CONST
-AC_TYPE_PID_T
-AC_TYPE_SIZE_T
-AC_TYPE_UID_T
-AC_HEADER_TIME
-
-#
-# Checks for library functions.
-#
-AC_PROG_GCC_TRADITIONAL
-AC_CHECK_FUNCS(gettimeofday select strdup strtol getaddrinfo getnameinfo strchr memcpy strstr strcmp strncmp strncpy strlen strncasecmp strcasecmp openlog closelog sysconf setenv if_indextoname)
-
-AC_FUNC_STRERROR_R
-
-SAVE_CFLAGS="$CFLAGS"
-# Emulate behavior of src/Makefile.am
-if test "x$GCC" = "xyes"
-then
-       CFLAGS="$CFLAGS -Wall -Werror"
-fi
-
-AC_CACHE_CHECK([for strtok_r],
-  [c_cv_have_strtok_r_default],
-  AC_LINK_IFELSE(
-    [AC_LANG_PROGRAM(
-[[[
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-]]],
-[[[
-      char buffer[] = "foo,bar,baz";
-      char *token;
-      char *dummy;
-      char *saveptr;
-
-      dummy = buffer;
-      saveptr = NULL;
-      while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
-      {
-        dummy = NULL;
-        printf ("token = %s;\n", token);
-      }
-]]]
-    )],
-    [c_cv_have_strtok_r_default="yes"],
-    [c_cv_have_strtok_r_default="no"]
-  )
-)
-
-if test "x$c_cv_have_strtok_r_default" = "xno"
-then
-  CFLAGS="$CFLAGS -D_REENTRANT=1"
-
-  AC_CACHE_CHECK([if strtok_r needs _REENTRANT],
-    [c_cv_have_strtok_r_reentrant],
-    AC_LINK_IFELSE(
-      [AC_LANG_PROGRAM(
-[[[
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-]]],
-[[[
-        char buffer[] = "foo,bar,baz";
-        char *token;
-        char *dummy;
-        char *saveptr;
-
-        dummy = buffer;
-        saveptr = NULL;
-        while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
-        {
-          dummy = NULL;
-          printf ("token = %s;\n", token);
-        }
-]]]
-      )],
-      [c_cv_have_strtok_r_reentrant="yes"],
-      [AC_MSG_FAILURE([strtok_r isn't available. Please file a bugreport!])]
-    )
-  )
-fi
-
-CFLAGS="$SAVE_CFLAGS"
-if test "x$c_cv_have_strtok_r_reentrant" = "xyes"
-then
-       CFLAGS="$CFLAGS -D_REENTRANT=1"
-fi
-
-AC_CHECK_FUNCS(getpwnam_r getgrnam_r setgroups regcomp regerror regexec regfree)
-
-socket_needs_socket="no"
-AC_CHECK_FUNCS(socket, [], AC_CHECK_LIB(socket, socket, [socket_needs_socket="yes"], AC_MSG_ERROR(cannot find socket)))
-AM_CONDITIONAL(BUILD_WITH_LIBSOCKET, test "x$socket_needs_socket" = "xyes")
-
-clock_gettime_needs_rt="no"
-clock_gettime_needs_posix4="no"
-have_clock_gettime="no"
-AC_CHECK_FUNCS(clock_gettime, [have_clock_gettime="yes"])
-if test "x$have_clock_gettime" = "xno"
-then
-       AC_CHECK_LIB(rt, clock_gettime, [clock_gettime_needs_rt="yes"
-                                        have_clock_gettime="yes"])
-fi
-if test "x$have_clock_gettime" = "xno"
-then
-       AC_CHECK_LIB(posix4, clock_gettime, [clock_gettime_needs_posix4="yes"
-                                            have_clock_gettime="yes"])
-fi
-if test "x$have_clock_gettime" = "xyes"
-then
-       AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if the clock_gettime(2) function is available.])
-else
-       AC_MSG_WARN(cannot find clock_gettime)
-fi
-
-nanosleep_needs_rt="no"
-nanosleep_needs_posix4="no"
-AC_CHECK_FUNCS(nanosleep,
-    [],
-    AC_CHECK_LIB(rt, nanosleep,
-        [nanosleep_needs_rt="yes"],
-        AC_CHECK_LIB(posix4, nanosleep,
-            [nanosleep_needs_posix4="yes"],
-            AC_MSG_ERROR(cannot find nanosleep))))
-
-AM_CONDITIONAL(BUILD_WITH_LIBRT, test "x$clock_gettime_needs_rt" = "xyes" || test "x$nanosleep_needs_rt" = "xyes")
-AM_CONDITIONAL(BUILD_WITH_LIBPOSIX4, test "x$clock_gettime_needs_posix4" = "xyes" || test "x$nanosleep_needs_posix4" = "xyes")
-
-AC_CHECK_FUNCS(sysctl, [have_sysctl="yes"], [have_sysctl="no"])
-AC_CHECK_FUNCS(sysctlbyname, [have_sysctlbyname="yes"], [have_sysctlbyname="no"])
-AC_CHECK_FUNCS(host_statistics, [have_host_statistics="yes"], [have_host_statistics="no"])
-AC_CHECK_FUNCS(processor_info, [have_processor_info="yes"], [have_processor_info="no"])
-AC_CHECK_FUNCS(thread_info, [have_thread_info="yes"], [have_thread_info="no"])
-AC_CHECK_FUNCS(statfs, [have_statfs="yes"], [have_statfs="no"])
-AC_CHECK_FUNCS(statvfs, [have_statvfs="yes"], [have_statvfs="no"])
-AC_CHECK_FUNCS(getifaddrs, [have_getifaddrs="yes"], [have_getifaddrs="no"])
-AC_CHECK_FUNCS(getloadavg, [have_getloadavg="yes"], [have_getloadavg="no"])
-AC_CHECK_FUNCS(syslog, [have_syslog="yes"], [have_syslog="no"])
-AC_CHECK_FUNCS(getutent, [have_getutent="yes"], [have_getutent="no"])
-AC_CHECK_FUNCS(getutxent, [have_getutxent="yes"], [have_getutxent="no"])
-
-# Check for strptime {{{
-if test "x$GCC" = "xyes"
-then
-       SAVE_CFLAGS="$CFLAGS"
-       CFLAGS="$CFLAGS -Wall -Wextra -Werror"
-fi
-
-AC_CHECK_FUNCS(strptime, [have_strptime="yes"], [have_strptime="no"])
-if test "x$have_strptime" = "xyes"
-then
-       AC_CACHE_CHECK([whether strptime is exported by default],
-                      [c_cv_have_strptime_default],
-                      AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
-[[[
-#include <time.h>
-]]],
-[[[
- struct tm stm;
- (void) strptime ("2010-12-30%13:42:42", "%Y-%m-%dT%T", &stm);
-]]]
-                      )],
-                      [c_cv_have_strptime_default="yes"],
-                      [c_cv_have_strptime_default="no"]))
-fi
-if test "x$have_strptime" = "xyes" && test "x$c_cv_have_strptime_default" = "xno"
-then
-       AC_CACHE_CHECK([whether strptime needs standards mode],
-                      [c_cv_have_strptime_standards],
-                      AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
-[[[
-#ifndef _ISOC99_SOURCE
-# define _ISOC99_SOURCE 1
-#endif
-#ifndef _POSIX_C_SOURCE
-# define _POSIX_C_SOURCE 200112L
-#endif
-#ifndef _XOPEN_SOURCE
-# define _XOPEN_SOURCE 500
-#endif
-#include <time.h>
-]]],
-[[[
- struct tm stm;
- (void) strptime ("2010-12-30%13:42:42", "%Y-%m-%dT%T", &stm);
-]]]
-                      )],
-                      [c_cv_have_strptime_standards="yes"],
-                      [c_cv_have_strptime_standards="no"]))
-
-       if test "x$c_cv_have_strptime_standards" = "xyes"
-       then
-               AC_DEFINE([STRPTIME_NEEDS_STANDARDS], 1, [Set to true if strptime is only exported in X/Open mode (GNU libc).])
-       else
-               have_strptime="no"
-       fi
-fi
-
-if test "x$GCC" = "xyes"
-then
-       CFLAGS="$SAVE_CFLAGS"
-fi
-# }}} Check for strptime
-
-AC_CHECK_FUNCS(swapctl, [have_swapctl="yes"], [have_swapctl="no"])
-if test "x$have_swapctl" = "xyes"; then
-        AC_CACHE_CHECK([whether swapctl takes two arguments],
-                [c_cv_have_swapctl_two_args],
-                AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
-[[[
-#if HAVE_SYS_SWAP_H && !defined(_LP64) && _FILE_OFFSET_BITS == 64
-#  undef _FILE_OFFSET_BITS
-#  undef _LARGEFILE64_SOURCE
-#endif
-#include <sys/stat.h>
-#include <sys/swap.h>
-]]],
-[[[
-int num = swapctl(0, NULL);
-]]]
-                        )],
-                        [c_cv_have_swapctl_two_args="yes"],
-                        [c_cv_have_swapctl_two_args="no"]
-                )
-        )
-        AC_CACHE_CHECK([whether swapctl takes three arguments],
-                [c_cv_have_swapctl_three_args],
-                AC_COMPILE_IFELSE(
-                        [AC_LANG_PROGRAM(
-[[[
-#if HAVE_SYS_SWAP_H && !defined(_LP64) && _FILE_OFFSET_BITS == 64
-#  undef _FILE_OFFSET_BITS
-#  undef _LARGEFILE64_SOURCE
-#endif
-#include <sys/stat.h>
-#include <sys/swap.h>
-]]],
-[[[
-int num = swapctl(0, NULL, 0);
-]]]
-                        )],
-                        [c_cv_have_swapctl_three_args="yes"],
-                        [c_cv_have_swapctl_three_args="no"]
-                )
-        )
-fi
-# Check for different versions of `swapctl' here..
-if test "x$have_swapctl" = "xyes"; then
-        if test "x$c_cv_have_swapctl_two_args" = "xyes"; then
-                AC_DEFINE(HAVE_SWAPCTL_TWO_ARGS, 1,
-                          [Define if the function swapctl exists and takes two arguments.])
-        fi
-        if test "x$c_cv_have_swapctl_three_args" = "xyes"; then
-                AC_DEFINE(HAVE_SWAPCTL_THREE_ARGS, 1,
-                          [Define if the function swapctl exists and takes three arguments.])
-        fi
-fi
-
-# Check for NAN
-AC_ARG_WITH(nan-emulation, [AS_HELP_STRING([--with-nan-emulation], [use emulated NAN. For crosscompiling only.])],
-[
- if test "x$withval" = "xno"; then
-        nan_type="none"
- else if test "x$withval" = "xyes"; then
-        nan_type="zero"
- else
-        nan_type="$withval"
- fi; fi
-],
-[nan_type="none"])
-if test "x$nan_type" = "xnone"; then
-  AC_CACHE_CHECK([whether NAN is defined by default],
-    [c_cv_have_nan_default],
-    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
-[[[
-#include <stdlib.h>
-#include <math.h>
-static double foo = NAN;
-]]],
-[[[
-       if (isnan (foo))
-        return 0;
-       else
-       return 1;
-]]]
-      )],
-      [c_cv_have_nan_default="yes"],
-      [c_cv_have_nan_default="no"]
-    )
-  )
-  if test "x$c_cv_have_nan_default" = "xyes"
-  then
-    nan_type="default"
-  fi
-fi
-if test "x$nan_type" = "xnone"; then
-  AC_CACHE_CHECK([whether NAN is defined by __USE_ISOC99],
-    [c_cv_have_nan_isoc],
-    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
-[[[
-#include <stdlib.h>
-#define __USE_ISOC99 1
-#include <math.h>
-static double foo = NAN;
-]]],
-[[[
-       if (isnan (foo))
-        return 0;
-       else
-       return 1;
-]]]
-      )],
-      [c_cv_have_nan_isoc="yes"],
-      [c_cv_have_nan_isoc="no"]
-    )
-  )
-  if test "x$c_cv_have_nan_isoc" = "xyes"
-  then
-    nan_type="isoc99"
-  fi
-fi
-if test "x$nan_type" = "xnone"; then
-  SAVE_LDFLAGS=$LDFLAGS
-  LDFLAGS="$LDFLAGS -lm"
-  AC_CACHE_CHECK([whether NAN can be defined by 0/0],
-    [c_cv_have_nan_zero],
-    AC_RUN_IFELSE([AC_LANG_PROGRAM(
-[[[
-#include <stdlib.h>
-#include <math.h>
-#ifdef NAN
-# undef NAN
-#endif
-#define NAN (0.0 / 0.0)
-#ifndef isnan
-# define isnan(f) ((f) != (f))
-#endif
-static double foo = NAN;
-]]],
-[[[
-       if (isnan (foo))
-        return 0;
-       else
-       return 1;
-]]]
-      )],
-      [c_cv_have_nan_zero="yes"],
-      [c_cv_have_nan_zero="no"]
-    )
-  )
-  LDFLAGS=$SAVE_LDFLAGS
-  if test "x$c_cv_have_nan_zero" = "xyes"
-  then
-    nan_type="zero"
-  fi
-fi
-
-if test "x$nan_type" = "xdefault"; then
-  AC_DEFINE(NAN_STATIC_DEFAULT, 1,
-    [Define if NAN is defined by default and can initialize static variables.])
-else if test "x$nan_type" = "xisoc99"; then
-  AC_DEFINE(NAN_STATIC_ISOC, 1,
-    [Define if NAN is defined by __USE_ISOC99 and can initialize static variables.])
-else if test "x$nan_type" = "xzero"; then
-  AC_DEFINE(NAN_ZERO_ZERO, 1,
-    [Define if NAN can be defined as (0.0 / 0.0)])
-else
-  AC_MSG_ERROR([Didn't find out how to statically initialize variables to NAN. Sorry.])
-fi; fi; fi
-
-AC_ARG_WITH(fp-layout, [AS_HELP_STRING([--with-fp-layout], [set the memory layout of doubles. For crosscompiling only.])],
-[
- if test "x$withval" = "xnothing"; then
-       fp_layout_type="nothing"
- else if test "x$withval" = "xendianflip"; then
-       fp_layout_type="endianflip"
- else if test "x$withval" = "xintswap"; then
-       fp_layout_type="intswap"
- else
-       AC_MSG_ERROR([Invalid argument for --with-fp-layout. Valid arguments are: nothing, endianflip, intswap]);
-fi; fi; fi
-],
-[fp_layout_type="unknown"])
-
-if test "x$fp_layout_type" = "xunknown"; then
-  AC_CACHE_CHECK([if doubles are stored in x86 representation],
-    [c_cv_fp_layout_need_nothing],
-    AC_RUN_IFELSE([AC_LANG_PROGRAM(
-[[[
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#if HAVE_STDINT_H
-# include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H
-# include <inttypes.h>
-#endif
-#if HAVE_STDBOOL_H
-# include <stdbool.h>
-#endif
-]]],
-[[[
-       uint64_t i0;
-       uint64_t i1;
-       uint8_t c[8];
-       double d;
-
-       d = 8.642135e130; 
-       memcpy ((void *) &i0, (void *) &d, 8);
-
-       i1 = i0;
-       memcpy ((void *) c, (void *) &i1, 8);
-
-       if ((c[0] == 0x2f) && (c[1] == 0x25)
-                       && (c[2] == 0xc0) && (c[3] == 0xc7)
-                       && (c[4] == 0x43) && (c[5] == 0x2b)
-                       && (c[6] == 0x1f) && (c[7] == 0x5b))
-               return (0);
-       else
-               return (1);
-]]]
-      )],
-      [c_cv_fp_layout_need_nothing="yes"],
-      [c_cv_fp_layout_need_nothing="no"]
-    )
-  )
-  if test "x$c_cv_fp_layout_need_nothing" = "xyes"; then
-    fp_layout_type="nothing"
-  fi
-fi
-if test "x$fp_layout_type" = "xunknown"; then
-  AC_CACHE_CHECK([if endianflip converts to x86 representation],
-    [c_cv_fp_layout_need_endianflip],
-    AC_RUN_IFELSE([AC_LANG_PROGRAM(
-[[[
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#if HAVE_STDINT_H
-# include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H
-# include <inttypes.h>
-#endif
-#if HAVE_STDBOOL_H
-# include <stdbool.h>
-#endif
-#define endianflip(A) ((((uint64_t)(A) & 0xff00000000000000LL) >> 56) | \
-                       (((uint64_t)(A) & 0x00ff000000000000LL) >> 40) | \
-                       (((uint64_t)(A) & 0x0000ff0000000000LL) >> 24) | \
-                       (((uint64_t)(A) & 0x000000ff00000000LL) >> 8)  | \
-                       (((uint64_t)(A) & 0x00000000ff000000LL) << 8)  | \
-                       (((uint64_t)(A) & 0x0000000000ff0000LL) << 24) | \
-                       (((uint64_t)(A) & 0x000000000000ff00LL) << 40) | \
-                       (((uint64_t)(A) & 0x00000000000000ffLL) << 56))
-]]],
-[[[
-       uint64_t i0;
-       uint64_t i1;
-       uint8_t c[8];
-       double d;
-
-       d = 8.642135e130; 
-       memcpy ((void *) &i0, (void *) &d, 8);
-
-       i1 = endianflip (i0);
-       memcpy ((void *) c, (void *) &i1, 8);
-
-       if ((c[0] == 0x2f) && (c[1] == 0x25)
-                       && (c[2] == 0xc0) && (c[3] == 0xc7)
-                       && (c[4] == 0x43) && (c[5] == 0x2b)
-                       && (c[6] == 0x1f) && (c[7] == 0x5b))
-               return (0);
-       else
-               return (1);
-]]]
-      )],
-      [c_cv_fp_layout_need_endianflip="yes"],
-      [c_cv_fp_layout_need_endianflip="no"]
-    )
-  )
-  if test "x$c_cv_fp_layout_need_endianflip" = "xyes"; then
-    fp_layout_type="endianflip"
-  fi
-fi
-if test "x$fp_layout_type" = "xunknown"; then
-  AC_CACHE_CHECK([if intswap converts to x86 representation],
-    [c_cv_fp_layout_need_intswap],
-    AC_RUN_IFELSE([AC_LANG_PROGRAM(
-[[[
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#if HAVE_STDINT_H
-# include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H
-# include <inttypes.h>
-#endif
-#if HAVE_STDBOOL_H
-# include <stdbool.h>
-#endif
-#define intswap(A)    ((((uint64_t)(A) & 0xffffffff00000000LL) >> 32) | \
-                       (((uint64_t)(A) & 0x00000000ffffffffLL) << 32))
-]]],
-[[[
-       uint64_t i0;
-       uint64_t i1;
-       uint8_t c[8];
-       double d;
-
-       d = 8.642135e130; 
-       memcpy ((void *) &i0, (void *) &d, 8);
-
-       i1 = intswap (i0);
-       memcpy ((void *) c, (void *) &i1, 8);
-
-       if ((c[0] == 0x2f) && (c[1] == 0x25)
-                       && (c[2] == 0xc0) && (c[3] == 0xc7)
-                       && (c[4] == 0x43) && (c[5] == 0x2b)
-                       && (c[6] == 0x1f) && (c[7] == 0x5b))
-               return (0);
-       else
-               return (1);
-]]]
-      )],
-      [c_cv_fp_layout_need_intswap="yes"],
-      [c_cv_fp_layout_need_intswap="no"]
-    )
-  )
-  if test "x$c_cv_fp_layout_need_intswap" = "xyes"; then
-    fp_layout_type="intswap"
-  fi
-fi
-
-if test "x$fp_layout_type" = "xnothing"; then
-  AC_DEFINE(FP_LAYOUT_NEED_NOTHING, 1,
-  [Define if doubles are stored in x86 representation.])
-else if test "x$fp_layout_type" = "xendianflip"; then
-  AC_DEFINE(FP_LAYOUT_NEED_ENDIANFLIP, 1,
-  [Define if endianflip is needed to convert to x86 representation.])
-else if test "x$fp_layout_type" = "xintswap"; then
-  AC_DEFINE(FP_LAYOUT_NEED_INTSWAP, 1,
-  [Define if intswap is needed to convert to x86 representation.])
-else
-  AC_MSG_ERROR([Didn't find out how doubles are stored in memory. Sorry.])
-fi; fi; fi
-
-# --with-useragent {{{
-AC_ARG_WITH(useragent, [AS_HELP_STRING([--with-useragent@<:@=AGENT@:>@], [User agent to use on http requests])],
-[
-    if test "x$withval" != "xno" && test "x$withval" != "xyes"
-    then
-        AC_DEFINE_UNQUOTED(COLLECTD_USERAGENT, ["$withval"], [User agent for http requests])
-    fi
-])
-
-# }}}
-
-have_getfsstat="no"
-AC_CHECK_FUNCS(getfsstat, [have_getfsstat="yes"])
-have_getvfsstat="no"
-AC_CHECK_FUNCS(getvfsstat, [have_getvfsstat="yes"])
-have_listmntent="no"
-AC_CHECK_FUNCS(listmntent, [have_listmntent="yes"])
-
-have_getmntent="no"
-AC_CHECK_FUNCS(getmntent, [have_getmntent="c"])
-if test "x$have_getmntent" = "xno"; then
-       AC_CHECK_LIB(sun, getmntent, [have_getmntent="sun"])
-fi
-if test "x$have_getmntent" = "xno"; then
-       AC_CHECK_LIB(seq, getmntent, [have_getmntent="seq"])
-fi
-if test "x$have_getmntent" = "xno"; then
-       AC_CHECK_LIB(gen, getmntent, [have_getmntent="gen"])
-fi
-
-if test "x$have_getmntent" = "xc"; then
-       AC_CACHE_CHECK([whether getmntent takes one argument],
-               [c_cv_have_one_getmntent],
-               AC_COMPILE_IFELSE(
-                       [AC_LANG_PROGRAM(
-[[[
-#include "$srcdir/src/utils_mount.h"
-]]],
-[[[
-FILE *fh;
-struct mntent *me;
-fh = setmntent ("/etc/mtab", "r");
-me = getmntent (fh);
-]]]
-                       )],
-                       [c_cv_have_one_getmntent="yes"],
-                       [c_cv_have_one_getmntent="no"]
-               )
-       )
-       AC_CACHE_CHECK([whether getmntent takes two arguments],
-               [c_cv_have_two_getmntent],
-               AC_COMPILE_IFELSE(
-                       [AC_LANG_PROGRAM(
-[[[
-#include "$srcdir/src/utils_mount.h"
-]]],
-[[[
-                                FILE *fh;
-                                struct mnttab mt;
-                                int status;
-                                fh = fopen ("/etc/mnttab", "r");
-                                status = getmntent (fh, &mt);
-]]]
-                       )],
-                       [c_cv_have_two_getmntent="yes"],
-                       [c_cv_have_two_getmntent="no"]
-               )
-       )
-fi
-
-# Check for different versions of `getmntent' here..
-
-if test "x$have_getmntent" = "xc"; then
-       if test "x$c_cv_have_one_getmntent" = "xyes"; then
-               AC_DEFINE(HAVE_ONE_GETMNTENT, 1,
-                         [Define if the function getmntent exists and takes one argument.])
-       fi
-       if test "x$c_cv_have_two_getmntent" = "xyes"; then
-               AC_DEFINE(HAVE_TWO_GETMNTENT, 1,
-                         [Define if the function getmntent exists and takes two arguments.])
-       fi
-fi
-if test "x$have_getmntent" = "xsun"; then
-       AC_DEFINE(HAVE_SUN_GETMNTENT, 1,
-                 [Define if the function getmntent exists. It's the version from libsun.])
-fi
-if test "x$have_getmntent" = "xseq"; then
-       AC_DEFINE(HAVE_SEQ_GETMNTENT, 1,
-                 [Define if the function getmntent exists. It's the version from libseq.])
-fi
-if test "x$have_getmntent" = "xgen"; then
-       AC_DEFINE(HAVE_GEN_GETMNTENT, 1,
-                 [Define if the function getmntent exists. It's the version from libgen.])
-fi
-
-# Check for htonll
-AC_MSG_CHECKING([if have htonll defined])
-
-    have_htonll="no"
-    AC_LINK_IFELSE([AC_LANG_PROGRAM(
-[[[
-#include <sys/types.h>
-#include <netinet/in.h>
-#if HAVE_INTTYPES_H
-# include <inttypes.h>
-#endif
-]]],
-[[[
-          return htonll(0);
-]]]
-    )],
-    [
-      have_htonll="yes"
-      AC_DEFINE(HAVE_HTONLL, 1, [Define if the function htonll exists.])
-    ])
-AC_MSG_RESULT([$have_htonll])
-
-# Check for structures
-AC_CHECK_MEMBERS([struct if_data.ifi_ibytes, struct if_data.ifi_opackets, struct if_data.ifi_ierrors],
-       [AC_DEFINE(HAVE_STRUCT_IF_DATA, 1, [Define if struct if_data exists and is usable.])],
-       [],
-       [
-       #include <sys/types.h>
-       #include <sys/socket.h>
-       #include <net/if.h>
-       ])
-AC_CHECK_MEMBERS([struct net_device_stats.rx_bytes, struct net_device_stats.tx_packets, struct net_device_stats.rx_errors],
-       [AC_DEFINE(HAVE_STRUCT_NET_DEVICE_STATS, 1, [Define if struct net_device_stats exists and is usable.])],
-       [],
-       [
-       #include <sys/types.h>
-       #include <sys/socket.h>
-       #include <linux/if.h>
-       #include <linux/netdevice.h>
-       ])
-
-AC_CHECK_MEMBERS([struct ip_mreqn.imr_ifindex], [],
-       [],
-       [
-       #include <netinet/in.h>
-       #include <net/if.h>
-       ])
-
-AC_CHECK_MEMBERS([struct kinfo_proc.ki_pid, struct kinfo_proc.ki_rssize, struct kinfo_proc.ki_rusage],
-       [
-               AC_DEFINE(HAVE_STRUCT_KINFO_PROC_FREEBSD, 1,
-                       [Define if struct kinfo_proc exists in the FreeBSD variant.])
-               have_struct_kinfo_proc_freebsd="yes"
-       ],
-       [
-               have_struct_kinfo_proc_freebsd="no"
-       ],
-       [
-#include <kvm.h>
-#include <sys/param.h>
-#include <sys/sysctl.h>
-#include <sys/user.h>
-       ])
-
-AC_CHECK_MEMBERS([struct kinfo_proc.kp_proc, struct kinfo_proc.kp_eproc],
-       [
-               AC_DEFINE(HAVE_STRUCT_KINFO_PROC_OPENBSD, 1,
-                       [Define if struct kinfo_proc exists in the OpenBSD variant.])
-               have_struct_kinfo_proc_openbsd="yes"
-       ],
-       [
-               have_struct_kinfo_proc_openbsd="no"
-       ],
-       [
-#include <sys/param.h>
-#include <sys/sysctl.h>
-#include <kvm.h>
-       ])
-
-AC_CHECK_MEMBERS([struct udphdr.uh_dport, struct udphdr.uh_sport], [], [],
-[#define _BSD_SOURCE
-#if HAVE_STDINT_H
-# include <stdint.h>
-#endif
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#if HAVE_NETINET_IN_SYSTM_H
-# include <netinet/in_systm.h>
-#endif
-#if HAVE_NETINET_IN_H
-# include <netinet/in.h>
-#endif
-#if HAVE_NETINET_IP_H
-# include <netinet/ip.h>
-#endif
-#if HAVE_NETINET_UDP_H
-# include <netinet/udp.h>
-#endif
-])
-AC_CHECK_MEMBERS([struct udphdr.dest, struct udphdr.source], [], [],
-[#define _BSD_SOURCE
-#if HAVE_STDINT_H
-# include <stdint.h>
-#endif
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#if HAVE_NETINET_IN_SYSTM_H
-# include <netinet/in_systm.h>
-#endif
-#if HAVE_NETINET_IN_H
-# include <netinet/in.h>
-#endif
-#if HAVE_NETINET_IP_H
-# include <netinet/ip.h>
-#endif
-#if HAVE_NETINET_UDP_H
-# include <netinet/udp.h>
-#endif
-])
-
-AC_CHECK_MEMBERS([kstat_io_t.nwritten, kstat_io_t.writes, kstat_io_t.nwrites, kstat_io_t.wtime],
-       [],
-       [],
-       [
-#if HAVE_KSTAT_H
-# include <kstat.h>
-#endif
-       ])
-
-#
-# Checks for libraries begin here
-#
-
-with_libresolv="yes"
-AC_CHECK_LIB(resolv, res_search,
-[
-       AC_DEFINE(HAVE_LIBRESOLV, 1, [Define to 1 if you have the 'resolv' library (-lresolv).])
-],
-[with_libresolv="no"])
-AM_CONDITIONAL(BUILD_WITH_LIBRESOLV, test "x$with_libresolv" = "xyes")
-
-dnl Check for HAL (hardware abstraction library)
-with_libhal="yes"
-AC_CHECK_LIB(hal,libhal_device_property_exists,
-            [AC_DEFINE(HAVE_LIBHAL, 1, [Define to 1 if you have 'hal' library])],
-            [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`"
-               AC_SUBST(BUILD_WITH_LIBHAL_CFLAGS)
-               AC_SUBST(BUILD_WITH_LIBHAL_LIBS)
-       fi
-fi
-
-m4_divert_once([HELP_WITH], [
-collectd additional packages:])
-
-AM_CONDITIONAL([BUILD_FREEBSD],[test "x$x$ac_system" = "xFreeBSD"])
-
-AM_CONDITIONAL([BUILD_AIX],[test "x$x$ac_system" = "xAIX"]) 
-
-if test "x$ac_system" = "xAIX"
-then
-       with_perfstat="yes"
-       with_procinfo="yes"
-else
-       with_perfstat="no (AIX only)"
-       with_procinfo="no (AIX only)"
-fi
-
-if test "x$with_perfstat" = "xyes"
-then
-       AC_CHECK_LIB(perfstat, perfstat_reset, [with_perfstat="yes"], [with_perfstat="no (perfstat not found)"], [])
-#      AC_CHECK_HEADERS(sys/protosw.h libperfstat.h,, [with_perfstat="no (perfstat not found)"])
-fi
-if test "x$with_perfstat" = "xyes"
-then
-        AC_DEFINE(HAVE_PERFSTAT, 1, [Define to 1 if you have the 'perfstat' library (-lperfstat)])
-        # struct members pertaining to donation have been added to libperfstat somewhere between AIX5.3ML5 and AIX5.3ML9
-        AC_CHECK_MEMBER([perfstat_partition_type_t.b.donate_enabled], [], [], [[#include <libperfstat.h]])
-        if test "x$av_cv_member_perfstat_partition_type_t_b_donate_enabled" = "xyes"
-        then
-               AC_DEFINE(PERFSTAT_SUPPORTS_DONATION, 1, [Define to 1 if your version of the 'perfstat' library supports donation])
-        fi
-fi
-AM_CONDITIONAL(BUILD_WITH_PERFSTAT, test "x$with_perfstat" = "xyes")
-
-# Processes plugin under AIX.
-if test "x$with_procinfo" = "xyes"
-then
-       AC_CHECK_HEADERS(procinfo.h,, [with_procinfo="no (procinfo.h not found)"])
-fi
-if test "x$with_procinfo" = "xyes"
-then
-        AC_DEFINE(HAVE_PROCINFO_H, 1, [Define to 1 if you have the procinfo.h])
-fi
-
-if test "x$ac_system" = "xSolaris"
-then
-       with_kstat="yes"
-       with_devinfo="yes"
-else
-       with_kstat="no (Solaris only)"
-       with_devinfo="no (Solaris only)"
-fi
-
-if test "x$with_kstat" = "xyes"
-then
-       AC_CHECK_LIB(kstat, kstat_open, [with_kstat="yes"], [with_kstat="no (libkstat not found)"], [])
-fi
-if test "x$with_kstat" = "xyes"
-then
-       AC_CHECK_LIB(devinfo, di_init, [with_devinfo="yes"], [with_devinfo="no (not found)"], [])
-       AC_CHECK_HEADERS(kstat.h,, [with_kstat="no (kstat.h not found)"])
-fi
-if test "x$with_kstat" = "xyes"
-then
-       AC_DEFINE(HAVE_LIBKSTAT, 1,
-                 [Define to 1 if you have the 'kstat' library (-lkstat)])
-fi
-AM_CONDITIONAL(BUILD_WITH_LIBKSTAT, test "x$with_kstat" = "xyes")
-AM_CONDITIONAL(BUILD_WITH_LIBDEVINFO, test "x$with_devinfo" = "xyes")
-
-with_libiokit="no"
-AC_CHECK_LIB(IOKit, IOServiceGetMatchingServices,
-[
-       with_libiokit="yes"
-], 
-[
-       with_libiokit="no"
-])
-AM_CONDITIONAL(BUILD_WITH_LIBIOKIT, test "x$with_libiokit" = "xyes")
-
-with_libkvm="no"
-AC_CHECK_LIB(kvm, kvm_getprocs, [with_kvm_getprocs="yes"], [with_kvm_getprocs="no"])
-if test "x$with_kvm_getprocs" = "xyes"
-then
-       AC_DEFINE(HAVE_LIBKVM_GETPROCS, 1,
-                 [Define to 1 if you have the 'kvm' library with the 'kvm_getprocs' symbol (-lkvm)])
-       with_libkvm="yes"
-fi
-AM_CONDITIONAL(BUILD_WITH_LIBKVM_GETPROCS, test "x$with_kvm_getprocs" = "xyes")
-
-AC_CHECK_LIB(kvm, kvm_getswapinfo, [with_kvm_getswapinfo="yes"], [with_kvm_getswapinfo="no"])
-if test "x$with_kvm_getswapinfo" = "xyes"
-then
-       AC_DEFINE(HAVE_LIBKVM_GETSWAPINFO, 1,
-                 [Define to 1 if you have the 'kvm' library with the 'kvm_getswapinfo' symbol (-lkvm)])
-       with_libkvm="yes"
-fi
-AM_CONDITIONAL(BUILD_WITH_LIBKVM_GETSWAPINFO, test "x$with_kvm_getswapinfo" = "xyes")
-
-AC_CHECK_LIB(kvm, kvm_nlist, [with_kvm_nlist="yes"], [with_kvm_nlist="no"])
-if test "x$with_kvm_nlist" = "xyes"
-then
-       AC_CHECK_HEADERS(bsd/nlist.h nlist.h)
-       AC_DEFINE(HAVE_LIBKVM_NLIST, 1,
-                 [Define to 1 if you have the 'kvm' library with the 'kvm_nlist' symbol (-lkvm)])
-       with_libkvm="yes"
-fi
-AM_CONDITIONAL(BUILD_WITH_LIBKVM_NLIST, test "x$with_kvm_nlist" = "xyes")
-
-AC_CHECK_LIB(kvm, kvm_openfiles, [with_kvm_openfiles="yes"], [with_kvm_openfiles="no"])
-if test "x$with_kvm_openfiles" = "xyes"
-then
-       AC_DEFINE(HAVE_LIBKVM_NLIST, 1,
-                 [Define to 1 if you have the 'kvm' library with the 'kvm_openfiles' symbol (-lkvm)])
-       with_libkvm="yes"
-fi
-AM_CONDITIONAL(BUILD_WITH_LIBKVM_OPENFILES, test "x$with_kvm_openfiles" = "xyes")
-
-# --with-libaquaero5 {{{
-AC_ARG_WITH(libaquaero5, [AS_HELP_STRING([--with-libaquaero5@<:@=PREFIX@:>@], [Path to aquatools-ng source code.])],
-[
- if test "x$withval" = "xyes"
- then
-        with_libaquaero5="yes"
- else if test "x$withval" = "xno"
- then
-        with_libaquaero5="no"
- else
-        with_libaquaero5="yes"
-        LIBAQUAERO5_CFLAGS="$LIBAQUAERO5_CFLAGS -I$withval/src"
-        LIBAQUAERO5_LDFLAGS="$LIBAQUAERO5_LDFLAGS -L$withval/obj"
- fi; fi
-],
-[with_libaquaero5="yes"])
-
-SAVE_CPPFLAGS="$CPPFLAGS"
-SAVE_LDFLAGS="$LDFLAGS"
-
-CPPFLAGS="$CPPFLAGS $LIBAQUAERO5_CFLAGS"
-LDFLAGS="$LDFLAGS $LIBAQUAERO5_LDFLAGS"
-
-if test "x$with_libaquaero5" = "xyes"
-then
-       if test "x$LIBAQUAERO5_CFLAGS" != "x"
-       then
-               AC_MSG_NOTICE([libaquaero5 CPPFLAGS: $LIBAQUAERO5_CFLAGS])
-       fi
-       AC_CHECK_HEADERS(libaquaero5.h,
-       [with_libaquaero5="yes"],
-       [with_libaquaero5="no (libaquaero5.h not found)"])
-fi
-if test "x$with_libaquaero5" = "xyes"
-then
-       if test "x$LIBAQUAERO5_LDFLAGS" != "x"
-       then
-               AC_MSG_NOTICE([libaquaero5 LDFLAGS: $LIBAQUAERO5_LDFLAGS])
-       fi
-       AC_CHECK_LIB(aquaero5, libaquaero5_poll,
-       [with_libaquaero5="yes"],
-       [with_libaquaero5="no (symbol 'libaquaero5_poll' not found)"])
-fi
-
-CPPFLAGS="$SAVE_CPPFLAGS"
-LDFLAGS="$SAVE_LDFLAGS"
-
-if test "x$with_libaquaero5" = "xyes"
-then
-       BUILD_WITH_LIBAQUAERO5_CFLAGS="$LIBAQUAERO5_CFLAGS"
-       BUILD_WITH_LIBAQUAERO5_LDFLAGS="$LIBAQUAERO5_LDFLAGS"
-       AC_SUBST(BUILD_WITH_LIBAQUAERO5_CFLAGS)
-       AC_SUBST(BUILD_WITH_LIBAQUAERO5_LDFLAGS)
-fi
-AM_CONDITIONAL(BUILD_WITH_LIBAQUAERO5, test "x$with_libaquaero5" = "xyes")
-# }}}
-
-# --with-libcredis {{{
-AC_ARG_WITH(libcredis, [AS_HELP_STRING([--with-libcredis@<:@=PREFIX@:>@], [Path to libcredis.])],
-[
- if test "x$withval" = "xyes"
- then
-        with_libcredis="yes"
- else if test "x$withval" = "xno"
- then
-        with_libcredis="no"
- else
-        with_libcredis="yes"
-        LIBCREDIS_CPPFLAGS="$LIBCREDIS_CPPFLAGS -I$withval/include"
-        LIBCREDIS_LDFLAGS="$LIBCREDIS_LDFLAGS -L$withval/lib"
- fi; fi
-],
-[with_libcredis="yes"])
-
-SAVE_CPPFLAGS="$CPPFLAGS"
-SAVE_LDFLAGS="$LDFLAGS"
-
-CPPFLAGS="$CPPFLAGS $LIBCREDIS_CPPFLAGS"
-LDFLAGS="$LDFLAGS $LIBCREDIS_LDFLAGS"
-
-if test "x$with_libcredis" = "xyes"
-then
-       if test "x$LIBCREDIS_CPPFLAGS" != "x"
-       then
-               AC_MSG_NOTICE([libcredis CPPFLAGS: $LIBCREDIS_CPPFLAGS])
-       fi
-       AC_CHECK_HEADERS(credis.h,
-       [with_libcredis="yes"],
-       [with_libcredis="no (credis.h not found)"])
-fi
-if test "x$with_libcredis" = "xyes"
-then
-       if test "x$LIBCREDIS_LDFLAGS" != "x"
-       then
-               AC_MSG_NOTICE([libcredis LDFLAGS: $LIBCREDIS_LDFLAGS])
-       fi
-       AC_CHECK_LIB(credis, credis_info,
-       [with_libcredis="yes"],
-       [with_libcredis="no (symbol 'credis_info' not found)"])
-
-fi
-
-CPPFLAGS="$SAVE_CPPFLAGS"
-LDFLAGS="$SAVE_LDFLAGS"
-
-if test "x$with_libcredis" = "xyes"
-then
-       BUILD_WITH_LIBCREDIS_CPPFLAGS="$LIBCREDIS_CPPFLAGS"
-       BUILD_WITH_LIBCREDIS_LDFLAGS="$LIBCREDIS_LDFLAGS"
-       AC_SUBST(BUILD_WITH_LIBCREDIS_CPPFLAGS)
-       AC_SUBST(BUILD_WITH_LIBCREDIS_LDFLAGS)
-fi
-AM_CONDITIONAL(BUILD_WITH_LIBCREDIS, test "x$with_libcredis" = "xyes")
-# }}}
-
-# --with-libcurl {{{
-with_curl_config="curl-config"
-with_curl_cflags=""
-with_curl_libs=""
-AC_ARG_WITH(libcurl, [AS_HELP_STRING([--with-libcurl@<:@=PREFIX@:>@], [Path to libcurl.])],
-[
-       if test "x$withval" = "xno"
-       then
-               with_libcurl="no"
-       else if test "x$withval" = "xyes"
-       then
-               with_libcurl="yes"
-       else
-               if test -f "$withval" && test -x "$withval"
-               then
-                       with_curl_config="$withval"
-                       with_libcurl="yes"
-               else if test -x "$withval/bin/curl-config"
-               then
-                       with_curl_config="$withval/bin/curl-config"
-                       with_libcurl="yes"
-               fi; fi
-               with_libcurl="yes"
-       fi; fi
-],
-[
-       with_libcurl="yes"
-])
-if test "x$with_libcurl" = "xyes"
-then
-       with_curl_cflags=`$with_curl_config --cflags 2>/dev/null`
-       curl_config_status=$?
-
-       if test $curl_config_status -ne 0
-       then
-               with_libcurl="no ($with_curl_config failed)"
-       else
-               SAVE_CPPFLAGS="$CPPFLAGS"
-               CPPFLAGS="$CPPFLAGS $with_curl_cflags"
-
-               AC_CHECK_HEADERS(curl/curl.h, [], [with_libcurl="no (curl/curl.h not found)"], [])
-
-               CPPFLAGS="$SAVE_CPPFLAGS"
-       fi
-fi
-if test "x$with_libcurl" = "xyes"
-then
-       with_curl_libs=`$with_curl_config --libs 2>/dev/null`
-       curl_config_status=$?
-
-       if test $curl_config_status -ne 0
-       then
-               with_libcurl="no ($with_curl_config failed)"
-       else
-               AC_CHECK_LIB(curl, curl_easy_init,
-                [with_libcurl="yes"],
-                [with_libcurl="no (symbol 'curl_easy_init' not found)"],
-                [$with_curl_libs])
-       fi
-fi
-if test "x$with_libcurl" = "xyes"
-then
-       BUILD_WITH_LIBCURL_CFLAGS="$with_curl_cflags"
-       BUILD_WITH_LIBCURL_LIBS="$with_curl_libs"
-       AC_SUBST(BUILD_WITH_LIBCURL_CFLAGS)
-       AC_SUBST(BUILD_WITH_LIBCURL_LIBS)
-fi
-AM_CONDITIONAL(BUILD_WITH_LIBCURL, test "x$with_libcurl" = "xyes")
-# }}}
-
-# --with-libdbi {{{
-with_libdbi_cppflags=""
-with_libdbi_ldflags=""
-AC_ARG_WITH(libdbi, [AS_HELP_STRING([--with-libdbi@<:@=PREFIX@:>@], [Path to libdbi.])],
-[
-       if test "x$withval" != "xno" && test "x$withval" != "xyes"
-       then
-               with_libdbi_cppflags="-I$withval/include"
-               with_libdbi_ldflags="-L$withval/lib"
-               with_libdbi="yes"
-       else
-               with_libdbi="$withval"
-       fi
-],
-[
-       with_libdbi="yes"
-])
-if test "x$with_libdbi" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       CPPFLAGS="$CPPFLAGS $with_libdbi_cppflags"
-
-       AC_CHECK_HEADERS(dbi/dbi.h, [with_libdbi="yes"], [with_libdbi="no (dbi/dbi.h not found)"])
-
-       CPPFLAGS="$SAVE_CPPFLAGS"
-fi
-if test "x$with_libdbi" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       SAVE_LDFLAGS="$LDFLAGS"
-       CPPFLAGS="$CPPFLAGS $with_libdbi_cppflags"
-       LDFLAGS="$LDFLAGS $with_libdbi_ldflags"
-
-       AC_CHECK_LIB(dbi, dbi_initialize, [with_libdbi="yes"], [with_libdbi="no (Symbol 'dbi_initialize' not found)"])
-
-       CPPFLAGS="$SAVE_CPPFLAGS"
-       LDFLAGS="$SAVE_LDFLAGS"
-fi
-if test "x$with_libdbi" = "xyes"
-then
-       BUILD_WITH_LIBDBI_CPPFLAGS="$with_libdbi_cppflags"
-       BUILD_WITH_LIBDBI_LDFLAGS="$with_libdbi_ldflags"
-       BUILD_WITH_LIBDBI_LIBS="-ldbi"
-       AC_SUBST(BUILD_WITH_LIBDBI_CPPFLAGS)
-       AC_SUBST(BUILD_WITH_LIBDBI_LDFLAGS)
-       AC_SUBST(BUILD_WITH_LIBDBI_LIBS)
-fi
-AM_CONDITIONAL(BUILD_WITH_LIBDBI, test "x$with_libdbi" = "xyes")
-# }}}
-
-# --with-libesmtp {{{
-AC_ARG_WITH(libesmtp, [AS_HELP_STRING([--with-libesmtp@<:@=PREFIX@:>@], [Path to libesmtp.])],
-[
-       if test "x$withval" != "xno" && test "x$withval" != "xyes"
-       then
-               LDFLAGS="$LDFLAGS -L$withval/lib"
-               CPPFLAGS="$CPPFLAGS -I$withval/include -D_THREAD_SAFE"
-               with_libesmtp="yes"
-       else
-               with_libesmtp="$withval"
-       fi
-],
-[
-       with_libesmtp="yes"
-])
-if test "x$with_libesmtp" = "xyes"
-then
-       AC_CHECK_LIB(esmtp, smtp_create_session,
-       [
-               AC_DEFINE(HAVE_LIBESMTP, 1, [Define to 1 if you have the esmtp library (-lesmtp).])
-       ], [with_libesmtp="no (libesmtp not found)"])
-fi
-if test "x$with_libesmtp" = "xyes"
-then
-       AC_CHECK_HEADERS(libesmtp.h,
-       [
-               AC_DEFINE(HAVE_LIBESMTP_H, 1, [Define to 1 if you have the <libesmtp.h> header file.])
-       ], [with_libesmtp="no (libesmtp.h not found)"])
-fi
-if test "x$with_libesmtp" = "xyes"
-then
-       collect_libesmtp=1
-else
-       collect_libesmtp=0
-fi
-AC_DEFINE_UNQUOTED(COLLECT_LIBESMTP, [$collect_libesmtp],
-       [Wether or not to use the esmtp library])
-AM_CONDITIONAL(BUILD_WITH_LIBESMTP, test "x$with_libesmtp" = "xyes")
-# }}}
-
-# --with-libganglia {{{
-AC_ARG_WITH(libganglia, [AS_HELP_STRING([--with-libganglia@<:@=PREFIX@:>@], [Path to libganglia.])],
-[
- if test -f "$withval" && test -x "$withval"
- then
-        with_libganglia_config="$withval"
-        with_libganglia="yes"
- else if test -f "$withval/bin/ganglia-config" && test -x "$withval/bin/ganglia-config"
- then
-        with_libganglia_config="$withval/bin/ganglia-config"
-        with_libganglia="yes"
- else if test -d "$withval"
- then
-        GANGLIA_CPPFLAGS="-I$withval/include"
-        GANGLIA_LDFLAGS="-L$withval/lib"
-        with_libganglia="yes"
- else
-        with_libganglia_config="ganglia-config"
-        with_libganglia="$withval"
- fi; fi; fi
-],
-[
- with_libganglia_config="ganglia-config"
- with_libganglia="yes"
-])
-
-if test "x$with_libganglia" = "xyes" && test "x$with_libganglia_config" != "x"
-then
-       if test "x$GANGLIA_CPPFLAGS" = "x"
-       then
-               GANGLIA_CPPFLAGS=`"$with_libganglia_config" --cflags 2>/dev/null`
-       fi
-
-       if test "x$GANGLIA_LDFLAGS" = "x"
-       then
-               GANGLIA_LDFLAGS=`"$with_libganglia_config" --ldflags 2>/dev/null`
-       fi
-
-       if test "x$GANGLIA_LIBS" = "x"
-       then
-               GANGLIA_LIBS=`"$with_libganglia_config" --libs 2>/dev/null`
-       fi
-fi
-
-SAVE_CPPFLAGS="$CPPFLAGS"
-SAVE_LDFLAGS="$LDFLAGS"
-CPPFLAGS="$CPPFLAGS $GANGLIA_CPPFLAGS"
-LDFLAGS="$LDFLAGS $GANGLIA_LDFLAGS"
-
-if test "x$with_libganglia" = "xyes"
-then
-       AC_CHECK_HEADERS(gm_protocol.h,
-       [
-               AC_DEFINE(HAVE_GM_PROTOCOL_H, 1,
-                         [Define to 1 if you have the <gm_protocol.h> header file.])
-       ], [with_libganglia="no (gm_protocol.h not found)"])
-fi
-
-if test "x$with_libganglia" = "xyes"
-then
-       AC_CHECK_LIB(ganglia, xdr_Ganglia_value_msg,
-       [
-               AC_DEFINE(HAVE_LIBGANGLIA, 1,
-                         [Define to 1 if you have the ganglia library (-lganglia).])
-       ], [with_libganglia="no (symbol xdr_Ganglia_value_msg not found)"])
-fi
-
-CPPFLAGS="$SAVE_CPPFLAGS"
-LDFLAGS="$SAVE_LDFLAGS"
-
-AC_SUBST(GANGLIA_CPPFLAGS)
-AC_SUBST(GANGLIA_LDFLAGS)
-AC_SUBST(GANGLIA_LIBS)
-AM_CONDITIONAL(BUILD_WITH_LIBGANGLIA, test "x$with_libganglia" = "xyes")
-# }}}
-
-# --with-libgcrypt {{{
-GCRYPT_CPPFLAGS="$GCRYPT_CPPFLAGS"
-GCRYPT_LDFLAGS="$GCRYPT_LDFLAGS"
-GCRYPT_LIBS="$GCRYPT_LIBS"
-AC_ARG_WITH(libgcrypt, [AS_HELP_STRING([--with-libgcrypt@<:@=PREFIX@:>@], [Path to libgcrypt.])],
-[
- if test -f "$withval" && test -x "$withval"
- then
-        with_libgcrypt_config="$withval"
-        with_libgcrypt="yes"
- else if test -f "$withval/bin/gcrypt-config" && test -x "$withval/bin/gcrypt-config"
- then
-        with_libgcrypt_config="$withval/bin/gcrypt-config"
-        with_libgcrypt="yes"
- else if test -d "$withval"
- then
-        GCRYPT_CPPFLAGS="$GCRYPT_CPPFLAGS -I$withval/include"
-        GCRYPT_LDFLAGS="$GCRYPT_LDFLAGS -L$withval/lib"
-        with_libgcrypt="yes"
- else
-        with_libgcrypt_config="gcrypt-config"
-        with_libgcrypt="$withval"
- fi; fi; fi
-],
-[
- with_libgcrypt_config="libgcrypt-config"
- with_libgcrypt="yes"
-])
-
-if test "x$with_libgcrypt" = "xyes" && test "x$with_libgcrypt_config" != "x"
-then
-       if test "x$GCRYPT_CPPFLAGS" = "x"
-       then
-               GCRYPT_CPPFLAGS=`"$with_libgcrypt_config" --cflags 2>/dev/null`
-       fi
-
-       if test "x$GCRYPT_LDFLAGS" = "x"
-       then
-               gcrypt_exec_prefix=`"$with_libgcrypt_config" --exec-prefix 2>/dev/null`
-               GCRYPT_LDFLAGS="-L$gcrypt_exec_prefix/lib"
-       fi
-
-       if test "x$GCRYPT_LIBS" = "x"
-       then
-               GCRYPT_LIBS=`"$with_libgcrypt_config" --libs 2>/dev/null`
-       fi
-fi
-
-SAVE_CPPFLAGS="$CPPFLAGS"
-SAVE_LDFLAGS="$LDFLAGS"
-CPPFLAGS="$CPPFLAGS $GCRYPT_CPPFLAGS"
-LDFLAGS="$LDFLAGS $GCRYPT_LDFLAGS"
-
-if test "x$with_libgcrypt" = "xyes"
-then
-       if test "x$GCRYPT_CPPFLAGS" != "x"
-       then
-               AC_MSG_NOTICE([gcrypt CPPFLAGS: $GCRYPT_CPPFLAGS])
-       fi
-       AC_CHECK_HEADERS(gcrypt.h,
-               [with_libgcrypt="yes"],
-               [with_libgcrypt="no (gcrypt.h not found)"])
-fi
-
-if test "x$with_libgcrypt" = "xyes"
-then
-       if test "x$GCRYPT_LDFLAGS" != "x"
-       then
-               AC_MSG_NOTICE([gcrypt LDFLAGS: $GCRYPT_LDFLAGS])
-       fi
-       AC_CHECK_LIB(gcrypt, gcry_md_hash_buffer,
-               [with_libgcrypt="yes"],
-               [with_libgcrypt="no (symbol gcry_md_hash_buffer not found)"])
-
-       if test "$with_libgcrypt" != "no"; then
-               AM_PATH_LIBGCRYPT(1:1.2.0,,with_libgcrypt="no (version 1.2.0+ required)")
-               GCRYPT_CPPFLAGS="$LIBGCRYPT_CPPFLAGS $LIBGCRYPT_CFLAGS"
-               GCRYPT_LIBS="$LIBGCRYPT_LIBS"
-       fi
-fi
-
-CPPFLAGS="$SAVE_CPPFLAGS"
-LDFLAGS="$SAVE_LDFLAGS"
-
-if test "x$with_libgcrypt" = "xyes"
-then
-       AC_DEFINE(HAVE_LIBGCRYPT, 1, [Define to 1 if you have the gcrypt library (-lgcrypt).])
-fi
-
-AC_SUBST(GCRYPT_CPPFLAGS)
-AC_SUBST(GCRYPT_LDFLAGS)
-AC_SUBST(GCRYPT_LIBS)
-AM_CONDITIONAL(BUILD_WITH_LIBGCRYPT, test "x$with_libgcrypt" = "xyes")
-# }}}
-
-# --with-libiptc {{{
-AC_ARG_WITH(libiptc, [AS_HELP_STRING([--with-libiptc@<:@=PREFIX@:>@], [Path to libiptc.])],
-[
-       if test "x$withval" = "xshipped"
-       then
-               with_libiptc="own"
-       else if test "x$withval" = "xyes"
-       then
-               with_libiptc="pkgconfig"
-       else if test "x$withval" = "xno"
-       then
-               with_libiptc="no"
-       else
-               with_libiptc="yes"
-               with_libiptc_cflags="-I$withval/include"
-               with_libiptc_libs="-L$withval/lib"
-       fi; fi; fi
-],
-[
-       if test "x$ac_system" = "xLinux"
-       then
-               with_libiptc="pkgconfig"
-       else
-               with_libiptc="no (Linux only)"
-       fi
-])
-
-if test "x$with_libiptc" = "xpkgconfig" && test "x$PKG_CONFIG" = "x"
-then
-       with_libiptc="no (Don't have pkg-config)"
-fi
-
-if test "x$with_libiptc" = "xpkgconfig"
-then
-       $PKG_CONFIG --exists 'libiptc' 2>/dev/null
-       if test $? -ne 0
-       then
-               with_libiptc="no (pkg-config doesn't know libiptc)"
-       fi
-fi
-if test "x$with_libiptc" = "xpkgconfig"
-then
-       with_libiptc_cflags="`$PKG_CONFIG --cflags 'libiptc'`"
-       if test $? -ne 0
-       then
-               with_libiptc="no ($PKG_CONFIG failed)"
-       fi
-       with_libiptc_libs="`$PKG_CONFIG --libs 'libiptc'`"
-       if test $? -ne 0
-       then
-               with_libiptc="no ($PKG_CONFIG failed)"
-       fi
-fi
-
-SAVE_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $with_libiptc_cflags"
-
-# check whether the header file for libiptc is available.
-if test "x$with_libiptc" = "xpkgconfig"
-then
-       AC_CHECK_HEADERS(libiptc/libiptc.h libiptc/libip6tc.h, ,
-                       [with_libiptc="no (header file missing)"])
-fi
-# If the header file is available, check for the required type declaractions.
-# They may be missing in old versions of libiptc. In that case, they will be
-# declared in the iptables plugin.
-if test "x$with_libiptc" = "xpkgconfig"
-then
-       AC_CHECK_TYPES([iptc_handle_t, ip6tc_handle_t], [], [])
-fi
-# Check for the iptc_init symbol in the library.
-# This could be in iptc or ip4tc
-if test "x$with_libiptc" = "xpkgconfig"
-then
-       SAVE_LIBS="$LIBS"
-       AC_SEARCH_LIBS(iptc_init, [iptc ip4tc],
-                       [with_libiptc="pkgconfig"],
-                       [with_libiptc="no"],
-                       [$with_libiptc_libs])
-       LIBS="$SAVE_LIBS"
-fi
-if test "x$with_libiptc" = "xpkgconfig"
-then
-       with_libiptc="yes"
-fi
-
-CPPFLAGS="$SAVE_CPPFLAGS"
-
-if test "x$with_libiptc" = "xown"
-then
-       with_libiptc_cflags=""
-       with_libiptc_libs=""
-fi
-if test "x$with_libiptc" = "xown"
-then
-       AC_CHECK_HEADERS(linux/netfilter_ipv4/ip_tables.h linux/netfilter_ipv6/ip6_tables.h linux/netfilter/x_tables.h, [],
-       [
-               with_libiptc="no (Linux iptables headers not found)"
-       ],
-       [
-#include "$srcdir/src/owniptc/ipt_kernel_headers.h"
-       ])
-fi
-AM_CONDITIONAL(BUILD_WITH_OWN_LIBIPTC, test "x$with_libiptc" = "xown")
-if test "x$with_libiptc" = "xown"
-then
-       AC_DEFINE(OWN_LIBIPTC, 1, [Define to 1 if we use the shipped iptc library.])
-       with_libiptc="yes"
-fi
-
-AM_CONDITIONAL(BUILD_WITH_LIBIPTC, test "x$with_libiptc" = "xyes")
-if test "x$with_libiptc" = "xyes"
-then
-       BUILD_WITH_LIBIPTC_CPPFLAGS="$with_libiptc_cflags"
-       BUILD_WITH_LIBIPTC_LDFLAGS="$with_libiptc_libs"
-       AC_SUBST(BUILD_WITH_LIBIPTC_CPPFLAGS)
-       AC_SUBST(BUILD_WITH_LIBIPTC_LDFLAGS)
-fi
-# }}}
-
-# --with-java {{{
-with_java_home="$JAVA_HOME"
-with_java_vmtype="client"
-with_java_cflags=""
-with_java_libs=""
-JAVAC="$JAVAC"
-JAR="$JAR"
-AC_ARG_WITH(java, [AS_HELP_STRING([--with-java@<:@=PREFIX@:>@], [Path to Java home.])],
-[
-       if test "x$withval" = "xno"
-       then
-               with_java="no"
-       else if test "x$withval" = "xyes"
-       then
-               with_java="yes"
-       else
-               with_java_home="$withval"
-               with_java="yes"
-       fi; fi
-],
-[with_java="yes"])
-if test "x$with_java" = "xyes"
-then
-       if test -d "$with_java_home"
-       then
-               AC_MSG_CHECKING([for jni.h])
-               TMPVAR=`find "$with_java_home" -name jni.h -type f -exec 'dirname' '{}' ';' 2>/dev/null | head -n 1`
-               if test "x$TMPVAR" != "x"
-               then
-                       AC_MSG_RESULT([found in $TMPVAR])
-                       JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPVAR"
-               else
-                       AC_MSG_RESULT([not found])
-               fi
-
-               AC_MSG_CHECKING([for jni_md.h])
-               TMPVAR=`find "$with_java_home" -name jni_md.h -type f -exec 'dirname' '{}' ';' 2>/dev/null | head -n 1`
-               if test "x$TMPVAR" != "x"
-               then
-                       AC_MSG_RESULT([found in $TMPVAR])
-                       JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPVAR"
-               else
-                       AC_MSG_RESULT([not found])
-               fi
-
-               AC_MSG_CHECKING([for libjvm.so])
-               TMPVAR=`find "$with_java_home" -name libjvm.so -type f -exec 'dirname' '{}' ';' 2>/dev/null | head -n 1`
-               if test "x$TMPVAR" != "x"
-               then
-                       AC_MSG_RESULT([found in $TMPVAR])
-                       JAVA_LDFLAGS="$JAVA_LDFLAGS -L$TMPVAR -Wl,-rpath -Wl,$TMPVAR"
-               else
-                       AC_MSG_RESULT([not found])
-               fi
-
-               if test "x$JAVAC" = "x"
-               then
-                       AC_MSG_CHECKING([for javac])
-                       TMPVAR=`find "$with_java_home" -name javac -type f 2>/dev/null | head -n 1`
-                       if test "x$TMPVAR" != "x"
-                       then
-                               JAVAC="$TMPVAR"
-                               AC_MSG_RESULT([$JAVAC])
-                       else
-                               AC_MSG_RESULT([not found])
-                       fi
-               fi
-               if test "x$JAR" = "x"
-               then
-                       AC_MSG_CHECKING([for jar])
-                       TMPVAR=`find "$with_java_home" -name jar -type f 2>/dev/null | head -n 1`
-                       if test "x$TMPVAR" != "x"
-                       then
-                               JAR="$TMPVAR"
-                               AC_MSG_RESULT([$JAR])
-                       else
-                               AC_MSG_RESULT([not found])
-                       fi
-               fi
-       else if test "x$with_java_home" != "x"
-       then
-               AC_MSG_WARN([JAVA_HOME: No such directory: $with_java_home])
-       fi; fi
-fi
-
-if test "x$JAVA_CPPFLAGS" != "x"
-then
-       AC_MSG_NOTICE([Building with JAVA_CPPFLAGS set to: $JAVA_CPPFLAGS])
-fi
-if test "x$JAVA_CFLAGS" != "x"
-then
-       AC_MSG_NOTICE([Building with JAVA_CFLAGS set to: $JAVA_CFLAGS])
-fi
-if test "x$JAVA_LDFLAGS" != "x"
-then
-       AC_MSG_NOTICE([Building with JAVA_LDFLAGS set to: $JAVA_LDFLAGS])
-fi
-if test "x$JAVAC" = "x"
-then
-       with_javac_path="$PATH"
-       if test "x$with_java_home" != "x"
-       then
-               with_javac_path="$with_java_home:with_javac_path"
-               if test -d "$with_java_home/bin"
-               then
-                       with_javac_path="$with_java_home/bin:with_javac_path"
-               fi
-       fi
-
-       AC_PATH_PROG(JAVAC, javac, [], "$with_javac_path")
-fi
-if test "x$JAVAC" = "x"
-then
-       with_java="no (javac not found)"
-fi
-if test "x$JAR" = "x"
-then
-       with_jar_path="$PATH"
-       if test "x$with_java_home" != "x"
-       then
-               with_jar_path="$with_java_home:$with_jar_path"
-               if test -d "$with_java_home/bin"
-               then
-                       with_jar_path="$with_java_home/bin:$with_jar_path"
-               fi
-       fi
-
-       AC_PATH_PROG(JAR, jar, [], "$with_jar_path")
-fi
-if test "x$JAR" = "x"
-then
-       with_java="no (jar not found)"
-fi
-
-SAVE_CPPFLAGS="$CPPFLAGS"
-SAVE_CFLAGS="$CFLAGS"
-SAVE_LDFLAGS="$LDFLAGS"
-CPPFLAGS="$CPPFLAGS $JAVA_CPPFLAGS"
-CFLAGS="$CFLAGS $JAVA_CFLAGS"
-LDFLAGS="$LDFLAGS $JAVA_LDFLAGS"
-
-if test "x$with_java" = "xyes"
-then
-       AC_CHECK_HEADERS(jni.h, [], [with_java="no (jni.h not found)"])
-fi
-if test "x$with_java" = "xyes"
-then
-       AC_CHECK_LIB(jvm, JNI_CreateJavaVM,
-       [with_java="yes"],
-       [with_java="no (libjvm not found)"],
-       [$JAVA_LIBS])
-fi
-if test "x$with_java" = "xyes"
-then
-       JAVA_LIBS="$JAVA_LIBS -ljvm"
-       AC_MSG_NOTICE([Building with JAVA_LIBS set to: $JAVA_LIBS])
-fi
-
-CPPFLAGS="$SAVE_CPPFLAGS"
-CFLAGS="$SAVE_CFLAGS"
-LDFLAGS="$SAVE_LDFLAGS"
-
-AC_SUBST(JAVA_CPPFLAGS)
-AC_SUBST(JAVA_CFLAGS)
-AC_SUBST(JAVA_LDFLAGS)
-AC_SUBST(JAVA_LIBS)
-AM_CONDITIONAL(BUILD_WITH_JAVA, test "x$with_java" = "xyes")
-# }}}
-
-# --with-liblvm2app {{{
-with_liblvm2app_cppflags=""
-with_liblvm2app_ldflags=""
-AC_ARG_WITH(liblvm2app, [AS_HELP_STRING([--with-liblvm2app@<:@=PREFIX@:>@], [Path to liblvm2app.])],
-[
-        if test "x$withval" != "xno" && test "x$withval" != "xyes"
-        then
-                with_liblvm2app_cppflags="-I$withval/include"
-                with_liblvm2app_ldflags="-L$withval/lib"
-                with_liblvm2app="yes"
-        else
-                with_liblvm2app="$withval"
-        fi
-],
-[
-        with_liblvm2app="yes"
-])
-if test "x$with_liblvm2app" = "xyes"
-then
-        SAVE_CPPFLAGS="$CPPFLAGS"
-        CPPFLAGS="$CPPFLAGS $with_liblvm2app_cppflags"
-
-        AC_CHECK_HEADERS(lvm2app.h, [with_liblvm2app="yes"], [with_liblvm2app="no (lvm2app.h not found)"])
-
-        CPPFLAGS="$SAVE_CPPFLAGS"
-fi
-
-if test "x$with_liblvm2app" = "xyes"
-then
-        SAVE_CPPFLAGS="$CPPFLAGS"
-        SAVE_LDFLAGS="$LDFLAGS"
-        CPPFLAGS="$CPPFLAGS $with_liblvm2app_cppflags"
-        LDFLAGS="$LDFLAGS $with_liblvm2app_ldflags"
-
-        AC_CHECK_LIB(lvm2app, lvm_init, [with_liblvm2app="yes"], [with_liblvm2app="no (Symbol 'lvm_init' not found)"])
-
-        CPPFLAGS="$SAVE_CPPFLAGS"
-        LDFLAGS="$SAVE_LDFLAGS"
-fi
-if test "x$with_liblvm2app" = "xyes"
-then
-        BUILD_WITH_LIBLVM2APP_CPPFLAGS="$with_liblvm2app_cppflags"
-        BUILD_WITH_LIBLVM2APP_LDFLAGS="$with_liblvm2app_ldflags"
-        BUILD_WITH_LIBLVM2APP_LIBS="-llvm2app"
-        AC_SUBST(BUILD_WITH_LIBLVM2APP_CPPFLAGS)
-        AC_SUBST(BUILD_WITH_LIBLVM2APP_LDFLAGS)
-        AC_SUBST(BUILD_WITH_LIBLVM2APP_LIBS)
-        AC_DEFINE(HAVE_LIBLVM2APP, 1, [Define if liblvm2app is present and usable.])
-fi
-AM_CONDITIONAL(BUILD_WITH_LIBLVM2APP, test "x$with_liblvm2app" = "xyes")
-# }}}
-
-# --with-libmemcached {{{
-with_libmemcached_cppflags=""
-with_libmemcached_ldflags=""
-AC_ARG_WITH(libmemcached, [AS_HELP_STRING([--with-libmemcached@<:@=PREFIX@:>@], [Path to libmemcached.])],
-[
-       if test "x$withval" != "xno" && test "x$withval" != "xyes"
-       then
-               with_libmemcached_cppflags="-I$withval/include"
-               with_libmemcached_ldflags="-L$withval/lib"
-               with_libmemcached="yes"
-       else
-               with_libmemcached="$withval"
-       fi
-],
-[
-       with_libmemcached="yes"
-])
-if test "x$with_libmemcached" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       CPPFLAGS="$CPPFLAGS $with_libmemcached_cppflags"
-
-       AC_CHECK_HEADERS(libmemcached/memcached.h, [with_libmemcached="yes"], [with_libmemcached="no (libmemcached/memcached.h not found)"])
-
-       CPPFLAGS="$SAVE_CPPFLAGS"
-fi
-if test "x$with_libmemcached" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       SAVE_LDFLAGS="$LDFLAGS"
-       CPPFLAGS="$CPPFLAGS $with_libmemcached_cppflags"
-       LDFLAGS="$LDFLAGS $with_libmemcached_ldflags"
-
-       AC_CHECK_LIB(memcached, memcached_create, [with_libmemcached="yes"], [with_libmemcached="no (Symbol 'memcached_create' not found)"])
-
-       CPPFLAGS="$SAVE_CPPFLAGS"
-       LDFLAGS="$SAVE_LDFLAGS"
-fi
-if test "x$with_libmemcached" = "xyes"
-then
-       BUILD_WITH_LIBMEMCACHED_CPPFLAGS="$with_libmemcached_cppflags"
-       BUILD_WITH_LIBMEMCACHED_LDFLAGS="$with_libmemcached_ldflags"
-       BUILD_WITH_LIBMEMCACHED_LIBS="-lmemcached"
-       AC_SUBST(BUILD_WITH_LIBMEMCACHED_CPPFLAGS)
-       AC_SUBST(BUILD_WITH_LIBMEMCACHED_LDFLAGS)
-       AC_SUBST(BUILD_WITH_LIBMEMCACHED_LIBS)
-       AC_DEFINE(HAVE_LIBMEMCACHED, 1, [Define if libmemcached is present and usable.])
-fi
-AM_CONDITIONAL(BUILD_WITH_LIBMEMCACHED, test "x$with_libmemcached" = "xyes")
-# }}}
-
-# --with-libmodbus {{{
-with_libmodbus_config=""
-with_libmodbus_cflags=""
-with_libmodbus_libs=""
-AC_ARG_WITH(libmodbus, [AS_HELP_STRING([--with-libmodbus@<:@=PREFIX@:>@], [Path to the modbus library.])],
-[
-       if test "x$withval" = "xno"
-       then
-               with_libmodbus="no"
-       else if test "x$withval" = "xyes"
-       then
-               with_libmodbus="use_pkgconfig"
-       else if test -d "$with_libmodbus/lib"
-       then
-               AC_MSG_NOTICE([Not checking for libmodbus: Manually configured])
-               with_libmodbus_cflags="-I$withval/include"
-               with_libmodbus_libs="-L$withval/lib -lmodbus"
-               with_libmodbus="yes"
-       fi; fi; fi
-],
-[with_libmodbus="use_pkgconfig"])
-
-# configure using pkg-config
-if test "x$with_libmodbus" = "xuse_pkgconfig"
-then
-       if test "x$PKG_CONFIG" = "x"
-       then
-               with_libmodbus="no (Don't have pkg-config)"
-       fi
-fi
-if test "x$with_libmodbus" = "xuse_pkgconfig"
-then
-       AC_MSG_NOTICE([Checking for libmodbus using $PKG_CONFIG])
-       $PKG_CONFIG --exists 'libmodbus' 2>/dev/null
-       if test $? -ne 0
-       then
-               with_libmodbus="no (pkg-config doesn't know libmodbus)"
-       fi
-fi
-if test "x$with_libmodbus" = "xuse_pkgconfig"
-then
-       with_libmodbus_cflags="`$PKG_CONFIG --cflags 'libmodbus'`"
-       if test $? -ne 0
-       then
-               with_libmodbus="no ($PKG_CONFIG failed)"
-       fi
-       with_libmodbus_libs="`$PKG_CONFIG --libs 'libmodbus'`"
-       if test $? -ne 0
-       then
-               with_libmodbus="no ($PKG_CONFIG failed)"
-       fi
-fi
-if test "x$with_libmodbus" = "xuse_pkgconfig"
-then
-       with_libmodbus="yes"
-fi
-
-# with_libmodbus_cflags and with_libmodbus_libs are set up now, let's do
-# the actual checks.
-if test "x$with_libmodbus" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       CPPFLAGS="$CPPFLAGS $with_libmodbus_cflags"
-
-       AC_CHECK_HEADERS(modbus/modbus.h, [], [with_libmodbus="no (modbus/modbus.h not found)"])
-
-       CPPFLAGS="$SAVE_CPPFLAGS"
-fi
-if test "x$with_libmodbus" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       SAVE_LDFLAGS="$LDFLAGS"
-
-       CPPFLAGS="$CPPFLAGS $with_libmodbus_cflags"
-       LDFLAGS="$LDFLAGS $with_libmodbus_libs"
-
-       AC_CHECK_LIB(modbus, modbus_connect,
-                    [with_libmodbus="yes"],
-                    [with_libmodbus="no (symbol modbus_connect not found)"])
-
-       CPPFLAGS="$SAVE_CPPFLAGS"
-       LDFLAGS="$SAVE_LDFLAGS"
-fi
-if test "x$with_libmodbus" = "xyes"
-then
-       BUILD_WITH_LIBMODBUS_CFLAGS="$with_libmodbus_cflags"
-       BUILD_WITH_LIBMODBUS_LIBS="$with_libmodbus_libs"
-       AC_SUBST(BUILD_WITH_LIBMODBUS_CFLAGS)
-       AC_SUBST(BUILD_WITH_LIBMODBUS_LIBS)
-fi
-# }}}
-
-# --with-libmongoc {{{
-AC_ARG_WITH(libmongoc, [AS_HELP_STRING([--with-libmongoc@<:@=PREFIX@:>@], [Path to libmongoc.])],
-[
- if test "x$withval" = "xyes"
- then
-        with_libmongoc="yes"
- else if test "x$withval" = "xno"
- then
-        with_libmongoc="no"
- else
-        with_libmongoc="yes"
-        LIBMONGOC_CPPFLAGS="$LIBMONGOC_CPPFLAGS -I$withval/include"
-        LIBMONGOC_LDFLAGS="$LIBMONGOC_LDFLAGS -L$withval/lib"
- fi; fi
-],
-[with_libmongoc="yes"])
-
-SAVE_CPPFLAGS="$CPPFLAGS"
-SAVE_LDFLAGS="$LDFLAGS"
-
-CPPFLAGS="$CPPFLAGS $LIBMONGOC_CPPFLAGS"
-LDFLAGS="$LDFLAGS $LIBMONGOC_LDFLAGS"
-
-if test "x$with_libmongoc" = "xyes"
-then
-       if test "x$LIBMONGOC_CPPFLAGS" != "x"
-       then
-               AC_MSG_NOTICE([libmongoc CPPFLAGS: $LIBMONGOC_CPPFLAGS])
-       fi
-       AC_CHECK_HEADERS(mongo.h,
-       [with_libmongoc="yes"],
-       [with_libmongoc="no ('mongo.h' not found)"],
-[#if HAVE_STDINT_H
-# define MONGO_HAVE_STDINT 1
-#else
-# define MONGO_USE_LONG_LONG_INT 1
-#endif
-])
-fi
-if test "x$with_libmongoc" = "xyes"
-then
-       if test "x$LIBMONGOC_LDFLAGS" != "x"
-       then
-               AC_MSG_NOTICE([libmongoc LDFLAGS: $LIBMONGOC_LDFLAGS])
-       fi
-       AC_CHECK_LIB(mongoc, mongo_run_command,
-       [with_libmongoc="yes"],
-       [with_libmongoc="no (symbol 'mongo_run_command' not found)"])
-fi
-
-CPPFLAGS="$SAVE_CPPFLAGS"
-LDFLAGS="$SAVE_LDFLAGS"
-
-if test "x$with_libmongoc" = "xyes"
-then
-       BUILD_WITH_LIBMONGOC_CPPFLAGS="$LIBMONGOC_CPPFLAGS"
-       BUILD_WITH_LIBMONGOC_LDFLAGS="$LIBMONGOC_LDFLAGS"
-       AC_SUBST(BUILD_WITH_LIBMONGOC_CPPFLAGS)
-       AC_SUBST(BUILD_WITH_LIBMONGOC_LDFLAGS)
-fi
-AM_CONDITIONAL(BUILD_WITH_LIBMONGOC, test "x$with_libmongoc" = "xyes")
-# }}}
-
-# --with-libmysql {{{
-with_mysql_config="mysql_config"
-with_mysql_cflags=""
-with_mysql_libs=""
-AC_ARG_WITH(libmysql, [AS_HELP_STRING([--with-libmysql@<:@=PREFIX@:>@], [Path to libmysql.])],
-[
-       if test "x$withval" = "xno"
-       then
-               with_libmysql="no"
-       else if test "x$withval" = "xyes"
-       then
-               with_libmysql="yes"
-       else
-               if test -f "$withval" && test -x "$withval";
-               then
-                       with_mysql_config="$withval"
-               else if test -x "$withval/bin/mysql_config"
-               then
-                       with_mysql_config="$withval/bin/mysql_config"
-               fi; fi
-               with_libmysql="yes"
-       fi; fi
-],
-[
-       with_libmysql="yes"
-])
-if test "x$with_libmysql" = "xyes"
-then
-       with_mysql_cflags=`$with_mysql_config --cflags 2>/dev/null`
-       mysql_config_status=$?
-
-       if test $mysql_config_status -ne 0
-       then
-               with_libmysql="no ($with_mysql_config failed)"
-       else
-               SAVE_CPPFLAGS="$CPPFLAGS"
-               CPPFLAGS="$CPPFLAGS $with_mysql_cflags"
-
-               have_mysql_h="no"
-               have_mysql_mysql_h="no"
-               AC_CHECK_HEADERS(mysql.h, [have_mysql_h="yes"])
-
-               if test "x$have_mysql_h" = "xno"
-               then
-                       AC_CHECK_HEADERS(mysql/mysql.h, [have_mysql_mysql_h="yes"])
-               fi
-
-               if test "x$have_mysql_h$have_mysql_mysql_h" = "xnono"
-               then
-                       with_libmysql="no (mysql.h not found)"
-               fi
-
-               CPPFLAGS="$SAVE_CPPFLAGS"
-       fi
-fi
-if test "x$with_libmysql" = "xyes"
-then
-       with_mysql_libs=`$with_mysql_config --libs_r 2>/dev/null`
-       mysql_config_status=$?
-
-       if test $mysql_config_status -ne 0
-       then
-               with_libmysql="no ($with_mysql_config failed)"
-       else
-               AC_CHECK_LIB(mysqlclient, mysql_init,
-                [with_libmysql="yes"],
-                [with_libmysql="no (symbol 'mysql_init' not found)"],
-                [$with_mysql_libs])
-
-               AC_CHECK_LIB(mysqlclient, mysql_get_server_version,
-                [with_libmysql="yes"],
-                [with_libmysql="no (symbol 'mysql_get_server_version' not found)"],
-                [$with_mysql_libs])
-       fi
-fi
-if test "x$with_libmysql" = "xyes"
-then
-       BUILD_WITH_LIBMYSQL_CFLAGS="$with_mysql_cflags"
-       BUILD_WITH_LIBMYSQL_LIBS="$with_mysql_libs"
-       AC_SUBST(BUILD_WITH_LIBMYSQL_CFLAGS)
-       AC_SUBST(BUILD_WITH_LIBMYSQL_LIBS)
-fi
-AM_CONDITIONAL(BUILD_WITH_LIBMYSQL, test "x$with_libmysql" = "xyes")
-# }}}
-
-# --with-libmnl {{{
-with_libmnl_cflags=""
-with_libmnl_libs=""
-AC_ARG_WITH(libmnl, [AS_HELP_STRING([--with-libmnl@<:@=PREFIX@:>@], [Path to libmnl.])],
-[
- echo "libmnl: withval = $withval"
- if test "x$withval" = "xyes"
- then
-        with_libmnl="yes"
- else if test "x$withval" = "xno"
- then
-        with_libmnl="no"
- else
-        if test -d "$withval/include"
-        then
-                with_libmnl_cflags="-I$withval/include"
-                with_libmnl_libs="-L$withval/lib -lmnl"
-                with_libmnl="yes"
-        else
-                AC_MSG_ERROR("no such directory: $withval/include")
-        fi
- fi; fi
-],
-[
- if test "x$ac_system" = "xLinux"
- then
-        with_libmnl="yes"
- else
-        with_libmnl="no (Linux only library)"
- fi
-])
-if test "x$PKG_CONFIG" = "x"
-then
-       with_libmnl="no (Don't have pkg-config)"
-fi
-if test "x$with_libmnl" = "xyes"
-then
-       if $PKG_CONFIG --exists libmnl 2>/dev/null; then
-         with_libmnl_cflags="$with_libmnl_ldflags `$PKG_CONFIG --cflags libmnl`"
-         with_libmnl_libs="$with_libmnl_libs `$PKG_CONFIG --libs libmnl`"
-       fi
-
-       AC_CHECK_HEADERS(libmnl.h libmnl/libmnl.h,
-       [
-        with_libmnl="yes"
-        break
-       ], [],
-[#include <stdio.h>
-#include <sys/types.h>
-#include <asm/types.h>
-#include <sys/socket.h>
-#include <linux/netlink.h>
-#include <linux/rtnetlink.h>])
-       AC_CHECK_HEADERS(linux/gen_stats.h linux/pkt_sched.h, [], [],
-[#include <stdio.h>
-#include <sys/types.h>
-#include <asm/types.h>
-#include <sys/socket.h>])
-
-        AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
-[[
-#include <stdio.h>
-#include <sys/types.h>
-#include <asm/types.h>
-#include <sys/socket.h>
-#include <linux/netlink.h>
-#include <linux/rtnetlink.h>
-]],
-[[
-int retval = TCA_STATS2;
-return (retval);
-]]
-       )],
-       [AC_DEFINE([HAVE_TCA_STATS2], [1], [True if the enum-member TCA_STATS2 exists])])
-
-       AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
-[[
-#include <stdio.h>
-#include <sys/types.h>
-#include <asm/types.h>
-#include <sys/socket.h>
-#include <linux/netlink.h>
-#include <linux/rtnetlink.h>
-]],
-[[
-int retval = TCA_STATS;
-return (retval);
-]]
-       )],
-       [AC_DEFINE([HAVE_TCA_STATS], 1, [True if the enum-member TCA_STATS exists])])
-fi
-if test "x$with_libmnl" = "xyes"
-then
-       AC_CHECK_MEMBERS([struct rtnl_link_stats64.tx_window_errors],
-       [AC_DEFINE(HAVE_RTNL_LINK_STATS64, 1, [Define if struct rtnl_link_stats64 exists and is usable.])],
-       [],
-       [
-       #include <linux/if_link.h>
-       ])
-fi
-if test "x$with_libmnl" = "xyes"
-then
-       AC_CHECK_LIB(mnl, mnl_nlmsg_get_payload,
-                    [with_libmnl="yes"],
-                    [with_libmnl="no (symbol 'mnl_nlmsg_get_payload' not found)"],
-                    [$with_libmnl_libs])
-fi
-if test "x$with_libmnl" = "xyes"
-then
-       AC_DEFINE(HAVE_LIBMNL, 1, [Define if libmnl is present and usable.])
-       BUILD_WITH_LIBMNL_CFLAGS="$with_libmnl_cflags"
-       BUILD_WITH_LIBMNL_LIBS="$with_libmnl_libs"
-       AC_SUBST(BUILD_WITH_LIBMNL_CFLAGS)
-       AC_SUBST(BUILD_WITH_LIBMNL_LIBS)
-fi
-AM_CONDITIONAL(BUILD_WITH_LIBMNL, test "x$with_libmnl" = "xyes")
-# }}}
-
-# --with-libnetapp {{{
-AC_ARG_VAR([LIBNETAPP_CPPFLAGS], [C preprocessor flags required to build with libnetapp])
-AC_ARG_VAR([LIBNETAPP_LDFLAGS],  [Linker flags required to build with libnetapp])
-AC_ARG_VAR([LIBNETAPP_LIBS],     [Other libraries required to link against libnetapp])
-LIBNETAPP_CPPFLAGS="$LIBNETAPP_CPPFLAGS"
-LIBNETAPP_LDFLAGS="$LIBNETAPP_LDFLAGS"
-LIBNETAPP_LIBS="$LIBNETAPP_LIBS"
-AC_ARG_WITH(libnetapp, [AS_HELP_STRING([--with-libnetapp@<:@=PREFIX@:>@], [Path to libnetapp.])],
-[
- if test -d "$withval"
- then
-        LIBNETAPP_CPPFLAGS="$LIBNETAPP_CPPFLAGS -I$withval/include"
-        LIBNETAPP_LDFLAGS="$LIBNETAPP_LDFLAGS -L$withval/lib"
-        with_libnetapp="yes"
- else
-        with_libnetapp="$withval"
- fi
-],
-[
- with_libnetapp="yes"
-])
-
-SAVE_CPPFLAGS="$CPPFLAGS"
-SAVE_LDFLAGS="$LDFLAGS"
-CPPFLAGS="$CPPFLAGS $LIBNETAPP_CPPFLAGS"
-LDFLAGS="$LDFLAGS $LIBNETAPP_LDFLAGS"
-
-if test "x$with_libnetapp" = "xyes"
-then
-       if test "x$LIBNETAPP_CPPFLAGS" != "x"
-       then
-               AC_MSG_NOTICE([netapp CPPFLAGS: $LIBNETAPP_CPPFLAGS])
-       fi
-       AC_CHECK_HEADERS(netapp_api.h,
-               [with_libnetapp="yes"],
-               [with_libnetapp="no (netapp_api.h not found)"])
-fi
-
-if test "x$with_libnetapp" = "xyes"
-then
-       if test "x$LIBNETAPP_LDFLAGS" != "x"
-       then
-               AC_MSG_NOTICE([netapp LDFLAGS: $LIBNETAPP_LDFLAGS])
-       fi
-
-       if test "x$LIBNETAPP_LIBS" = "x"
-       then
-               LIBNETAPP_LIBS="-lpthread -lxml -ladt -lssl -lm -lcrypto -lz"
-       fi
-       AC_MSG_NOTICE([netapp LIBS: $LIBNETAPP_LIBS])
-
-       AC_CHECK_LIB(netapp, na_server_invoke_elem,
-               [with_libnetapp="yes"],
-               [with_libnetapp="no (symbol na_server_invoke_elem not found)"],
-               [$LIBNETAPP_LIBS])
-       LIBNETAPP_LIBS="-lnetapp $LIBNETAPP_LIBS"
-fi
-
-CPPFLAGS="$SAVE_CPPFLAGS"
-LDFLAGS="$SAVE_LDFLAGS"
-
-if test "x$with_libnetapp" = "xyes"
-then
-       AC_DEFINE(HAVE_LIBNETAPP, 1, [Define to 1 if you have the netapp library (-lnetapp).])
-fi
-
-AC_SUBST(LIBNETAPP_CPPFLAGS)
-AC_SUBST(LIBNETAPP_LDFLAGS)
-AC_SUBST(LIBNETAPP_LIBS)
-AM_CONDITIONAL(BUILD_WITH_LIBNETAPP, test "x$with_libnetapp" = "xyes")
-# }}}
-
-# --with-libnetsnmp {{{
-with_snmp_config="net-snmp-config"
-with_snmp_cflags=""
-with_snmp_libs=""
-AC_ARG_WITH(libnetsnmp, [AS_HELP_STRING([--with-libnetsnmp@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
-[
-       if test "x$withval" = "xno"
-       then
-               with_libnetsnmp="no"
-       else if test "x$withval" = "xyes"
-       then
-               with_libnetsnmp="yes"
-       else
-               if test -x "$withval"
-               then
-                       with_snmp_config="$withval"
-                       with_libnetsnmp="yes"
-               else
-                       with_snmp_config="$withval/bin/net-snmp-config"
-                       with_libnetsnmp="yes"
-               fi
-       fi; fi
-],
-[with_libnetsnmp="yes"])
-if test "x$with_libnetsnmp" = "xyes"
-then
-       with_snmp_cflags=`$with_snmp_config --cflags 2>/dev/null`
-       snmp_config_status=$?
-
-       if test $snmp_config_status -ne 0
-       then
-               with_libnetsnmp="no ($with_snmp_config failed)"
-       else
-               SAVE_CPPFLAGS="$CPPFLAGS"
-               CPPFLAGS="$CPPFLAGS $with_snmp_cflags"
-               
-               AC_CHECK_HEADERS(net-snmp/net-snmp-config.h, [], [with_libnetsnmp="no (net-snmp/net-snmp-config.h not found)"])
-
-               CPPFLAGS="$SAVE_CPPFLAGS"
-       fi
-fi
-if test "x$with_libnetsnmp" = "xyes"
-then
-       with_snmp_libs=`$with_snmp_config --libs 2>/dev/null`
-       snmp_config_status=$?
-
-       if test $snmp_config_status -ne 0
-       then
-               with_libnetsnmp="no ($with_snmp_config failed)"
-       else
-               AC_CHECK_LIB(netsnmp, init_snmp,
-               [with_libnetsnmp="yes"],
-               [with_libnetsnmp="no (libnetsnmp not found)"],
-               [$with_snmp_libs])
-       fi
-fi
-if test "x$with_libnetsnmp" = "xyes"
-then
-       BUILD_WITH_LIBSNMP_CFLAGS="$with_snmp_cflags"
-       BUILD_WITH_LIBSNMP_LIBS="$with_snmp_libs"
-       AC_SUBST(BUILD_WITH_LIBSNMP_CFLAGS)
-       AC_SUBST(BUILD_WITH_LIBSNMP_LIBS)
-fi
-AM_CONDITIONAL(BUILD_WITH_LIBNETSNMP, test "x$with_libnetsnmp" = "xyes")
-# }}}
-
-# --with-liboconfig {{{
-with_own_liboconfig="no"
-liboconfig_LDFLAGS="$LDFLAGS"
-liboconfig_CPPFLAGS="$CPPFLAGS"
-AC_ARG_WITH(liboconfig, [AS_HELP_STRING([--with-liboconfig@<:@=PREFIX@:>@], [Path to liboconfig.])],
-[
-       if test "x$withval" != "xno" && test "x$withval" != "xyes"
-       then
-               if test -d "$withval/lib"
-               then
-                       liboconfig_LDFLAGS="$LDFLAGS -L$withval/lib"
-               fi
-               if test -d "$withval/include"
-               then
-                       liboconfig_CPPFLAGS="$CPPFLAGS -I$withval/include"
-               fi
-       fi
-       if test "x$withval" = "xno"
-       then
-               AC_MSG_ERROR("liboconfig is required")
-       fi
-],
-[
-       with_liboconfig="yes"
-])
-
-save_LDFLAGS="$LDFLAGS"
-save_CPPFLAGS="$CPPFLAGS"
-LDFLAGS="$liboconfig_LDFLAGS"
-CPPFLAGS="$liboconfig_CPPFLAGS"
-AC_CHECK_LIB(oconfig, oconfig_parse_fh,
-[
-       with_liboconfig="yes"
-       with_own_liboconfig="no"
-],
-[
-       with_liboconfig="yes"
-       with_own_liboconfig="yes"
-       LDFLAGS="$save_LDFLAGS"
-       CPPFLAGS="$save_CPPFLAGS"
-])
-
-AM_CONDITIONAL(BUILD_WITH_OWN_LIBOCONFIG, test "x$with_own_liboconfig" = "xyes")
-if test "x$with_own_liboconfig" = "xyes"
-then
-       with_liboconfig="yes (shipped version)"
-fi
-# }}}
-
-# --with-liboping {{{
-AC_ARG_WITH(liboping, [AS_HELP_STRING([--with-liboping@<:@=PREFIX@:>@], [Path to liboping.])],
-[
- if test "x$withval" = "xyes"
- then
-        with_liboping="yes"
- else if test "x$withval" = "xno"
- then
-        with_liboping="no"
- else
-        with_liboping="yes"
-        LIBOPING_CPPFLAGS="$LIBOPING_CPPFLAGS -I$withval/include"
-        LIBOPING_LDFLAGS="$LIBOPING_LDFLAGS -L$withval/lib"
- fi; fi
-],
-[with_liboping="yes"])
-
-SAVE_CPPFLAGS="$CPPFLAGS"
-SAVE_LDFLAGS="$LDFLAGS"
-
-CPPFLAGS="$CPPFLAGS $LIBOPING_CPPFLAGS"
-LDFLAGS="$LDFLAGS $LIBOPING_LDFLAGS"
-
-if test "x$with_liboping" = "xyes"
-then
-       if test "x$LIBOPING_CPPFLAGS" != "x"
-       then
-               AC_MSG_NOTICE([liboping CPPFLAGS: $LIBOPING_CPPFLAGS])
-       fi
-       AC_CHECK_HEADERS(oping.h,
-       [with_liboping="yes"],
-       [with_liboping="no (oping.h not found)"])
-fi
-if test "x$with_liboping" = "xyes"
-then
-       if test "x$LIBOPING_LDFLAGS" != "x"
-       then
-               AC_MSG_NOTICE([liboping LDFLAGS: $LIBOPING_LDFLAGS])
-       fi
-       AC_CHECK_LIB(oping, ping_construct,
-       [with_liboping="yes"],
-       [with_liboping="no (symbol 'ping_construct' not found)"])
-fi
-
-CPPFLAGS="$SAVE_CPPFLAGS"
-LDFLAGS="$SAVE_LDFLAGS"
-
-if test "x$with_liboping" = "xyes"
-then
-       BUILD_WITH_LIBOPING_CPPFLAGS="$LIBOPING_CPPFLAGS"
-       BUILD_WITH_LIBOPING_LDFLAGS="$LIBOPING_LDFLAGS"
-       AC_SUBST(BUILD_WITH_LIBOPING_CPPFLAGS)
-       AC_SUBST(BUILD_WITH_LIBOPING_LDFLAGS)
-fi
-AM_CONDITIONAL(BUILD_WITH_LIBOPING, test "x$with_liboping" = "xyes")
-# }}}
-
-# --with-oracle {{{
-with_oracle_cppflags=""
-with_oracle_libs=""
-AC_ARG_WITH(oracle, [AS_HELP_STRING([--with-oracle@<:@=ORACLE_HOME@:>@], [Path to Oracle.])],
-[
-       if test "x$withval" = "xyes"
-       then
-               if test "x$ORACLE_HOME" = "x"
-               then
-                       AC_MSG_WARN([Use of the Oracle library has been forced, but the environment variable ORACLE_HOME is not set.])
-               fi
-               with_oracle="yes"
-       else if test "x$withval" = "xno"
-       then
-               with_oracle="no"
-       else
-               with_oracle="yes"
-               ORACLE_HOME="$withval"
-       fi; fi
-],
-[
-       if test "x$ORACLE_HOME" = "x"
-       then
-               with_oracle="no (ORACLE_HOME is not set)"
-       else
-               with_oracle="yes"
-       fi
-])
-if test "x$ORACLE_HOME" != "x"
-then
-       with_oracle_cppflags="-I$ORACLE_HOME/rdbms/public"
-
-       if test -e "$ORACLE_HOME/lib/ldflags"
-       then
-               with_oracle_libs=`cat "$ORACLE_HOME/lib/ldflags"`
-       fi
-       #with_oracle_libs="-L$ORACLE_HOME/lib $with_oracle_libs -lclntsh"
-       with_oracle_libs="-L$ORACLE_HOME/lib -lclntsh"
-fi
-if test "x$with_oracle" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       CPPFLAGS="$CPPFLAGS $with_oracle_cppflags"
-
-       AC_CHECK_HEADERS(oci.h, [with_oracle="yes"], [with_oracle="no (oci.h not found)"])
-
-       CPPFLAGS="$SAVE_CPPFLAGS"
-fi
-if test "x$with_oracle" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       SAVE_LDFLAGS="$LDFLAGS"
-       CPPFLAGS="$CPPFLAGS $with_oracle_cppflags"
-       LDFLAGS="$LDFLAGS $with_oracle_libs"
-
-       AC_CHECK_FUNC(OCIEnvCreate, [with_oracle="yes"], [with_oracle="no (Symbol 'OCIEnvCreate' not found)"])
-
-       CPPFLAGS="$SAVE_CPPFLAGS"
-       LDFLAGS="$SAVE_LDFLAGS"
-fi
-if test "x$with_oracle" = "xyes"
-then
-       BUILD_WITH_ORACLE_CFLAGS="$with_oracle_cppflags"
-       BUILD_WITH_ORACLE_LIBS="$with_oracle_libs"
-       AC_SUBST(BUILD_WITH_ORACLE_CFLAGS)
-       AC_SUBST(BUILD_WITH_ORACLE_LIBS)
-fi
-# }}}
-
-# --with-libowcapi {{{
-with_libowcapi_cppflags=""
-with_libowcapi_libs="-lowcapi"
-AC_ARG_WITH(libowcapi, [AS_HELP_STRING([--with-libowcapi@<:@=PREFIX@:>@], [Path to libowcapi.])],
-[
-       if test "x$withval" != "xno" && test "x$withval" != "xyes"
-       then
-               with_libowcapi_cppflags="-I$withval/include"
-               with_libowcapi_libs="-L$withval/lib -lowcapi"
-               with_libowcapi="yes"
-       else
-               with_libowcapi="$withval"
-       fi
-],
-[
-       with_libowcapi="yes"
-])
-if test "x$with_libowcapi" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       CPPFLAGS="$with_libowcapi_cppflags"
-       
-       AC_CHECK_HEADERS(owcapi.h, [with_libowcapi="yes"], [with_libowcapi="no (owcapi.h not found)"])
-
-       CPPFLAGS="$SAVE_CPPFLAGS"
-fi
-if test "x$with_libowcapi" = "xyes"
-then
-       SAVE_LDFLAGS="$LDFLAGS"
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       LDFLAGS="$with_libowcapi_libs"
-       CPPFLAGS="$with_libowcapi_cppflags"
-       
-       AC_CHECK_LIB(owcapi, OW_get, [with_libowcapi="yes"], [with_libowcapi="no (libowcapi not found)"])
-
-       LDFLAGS="$SAVE_LDFLAGS"
-       CPPFLAGS="$SAVE_CPPFLAGS"
-fi
-if test "x$with_libowcapi" = "xyes"
-then
-       BUILD_WITH_LIBOWCAPI_CPPFLAGS="$with_libowcapi_cppflags"
-       BUILD_WITH_LIBOWCAPI_LIBS="$with_libowcapi_libs"
-       AC_SUBST(BUILD_WITH_LIBOWCAPI_CPPFLAGS)
-       AC_SUBST(BUILD_WITH_LIBOWCAPI_LIBS)
-fi
-# }}}
-
-# --with-libpcap {{{
-AC_ARG_WITH(libpcap, [AS_HELP_STRING([--with-libpcap@<:@=PREFIX@:>@], [Path to libpcap.])],
-[
-       if test "x$withval" != "xno" && test "x$withval" != "xyes"
-       then
-               LDFLAGS="$LDFLAGS -L$withval/lib"
-               CPPFLAGS="$CPPFLAGS -I$withval/include"
-               with_libpcap="yes"
-       else
-               with_libpcap="$withval"
-       fi
-],
-[
-       with_libpcap="yes"
-])
-if test "x$with_libpcap" = "xyes"
-then
-       AC_CHECK_LIB(pcap, pcap_open_live,
-       [
-               AC_DEFINE(HAVE_LIBPCAP, 1, [Define to 1 if you have the pcap library (-lpcap).])
-       ], [with_libpcap="no (libpcap not found)"])
-fi
-if test "x$with_libpcap" = "xyes"
-then
-       AC_CHECK_HEADERS(pcap.h,,
-                        [with_libpcap="no (pcap.h not found)"])
-fi
-if test "x$with_libpcap" = "xyes"
-then
-       AC_CHECK_HEADERS(pcap-bpf.h,,
-                        [with_libpcap="no (pcap-bpf.h not found)"])
-fi
-AM_CONDITIONAL(BUILD_WITH_LIBPCAP, test "x$with_libpcap" = "xyes")
-# }}}
-
-# --with-libperl {{{
-perl_interpreter="perl"
-AC_ARG_WITH(libperl, [AS_HELP_STRING([--with-libperl@<:@=PREFIX@:>@], [Path to libperl.])],
-[
-       if test -f "$withval" && test -x "$withval"
-       then
-               perl_interpreter="$withval"
-               with_libperl="yes"
-       else if test "x$withval" != "xno" && test "x$withval" != "xyes"
-       then
-               LDFLAGS="$LDFLAGS -L$withval/lib"
-               CPPFLAGS="$CPPFLAGS -I$withval/include"
-               perl_interpreter="$withval/bin/perl"
-               with_libperl="yes"
-       else
-               with_libperl="$withval"
-       fi; fi
-],
-[
-       with_libperl="yes"
-])
-
-AC_MSG_CHECKING([for perl])
-perl_interpreter=`which "$perl_interpreter" 2> /dev/null`
-if test -x "$perl_interpreter"
-then
-       AC_MSG_RESULT([yes ($perl_interpreter)])
-else
-       perl_interpreter=""
-       AC_MSG_RESULT([no])
-fi
-
-AC_SUBST(PERL, "$perl_interpreter")
-
-if test "x$with_libperl" = "xyes" \
-       && test -n "$perl_interpreter"
-then
-  SAVE_CFLAGS="$CFLAGS"
-  SAVE_LDFLAGS="$LDFLAGS"
-dnl ARCHFLAGS="" -> disable multi -arch on OSX (see Config_heavy.pl:fetch_string)
-  PERL_CFLAGS=`ARCHFLAGS="" $perl_interpreter -MExtUtils::Embed -e ccopts`
-  PERL_LDFLAGS=`ARCHFLAGS="" $perl_interpreter -MExtUtils::Embed -e ldopts`
-  CFLAGS="$CFLAGS $PERL_CFLAGS"
-  LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
-
-  AC_CACHE_CHECK([for libperl],
-    [c_cv_have_libperl],
-    AC_LINK_IFELSE([AC_LANG_PROGRAM(
-[[[
-#define PERL_NO_GET_CONTEXT
-#include <EXTERN.h>
-#include <perl.h>
-#include <XSUB.h>
-]]],
-[[[
-       dTHX;
-       load_module (PERL_LOADMOD_NOIMPORT,
-                        newSVpv ("Collectd::Plugin::FooBar", 24),
-                        Nullsv);
-]]]
-      )],
-      [c_cv_have_libperl="yes"],
-      [c_cv_have_libperl="no"]
-    )
-  )
-
-  if test "x$c_cv_have_libperl" = "xyes"
-  then
-         AC_DEFINE(HAVE_LIBPERL, 1, [Define if libperl is present and usable.])
-         AC_SUBST(PERL_CFLAGS)
-         AC_SUBST(PERL_LDFLAGS)
-  else
-         with_libperl="no"
-  fi
-
-  CFLAGS="$SAVE_CFLAGS"
-  LDFLAGS="$SAVE_LDFLAGS"
-else if test -z "$perl_interpreter"; then
-  with_libperl="no (no perl interpreter found)"
-  c_cv_have_libperl="no"
-fi; fi
-AM_CONDITIONAL(BUILD_WITH_LIBPERL, test "x$with_libperl" = "xyes")
-
-if test "x$with_libperl" = "xyes"
-then
-       SAVE_CFLAGS="$CFLAGS"
-       SAVE_LDFLAGS="$LDFLAGS"
-       CFLAGS="$CFLAGS $PERL_CFLAGS"
-       LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
-
-       AC_CACHE_CHECK([if perl supports ithreads],
-               [c_cv_have_perl_ithreads],
-               AC_LINK_IFELSE([AC_LANG_PROGRAM(
-[[[
-#include <EXTERN.h>
-#include <perl.h>
-#include <XSUB.h>
-
-#if !defined(USE_ITHREADS)
-# error "Perl does not support ithreads!"
-#endif /* !defined(USE_ITHREADS) */
-]]],
-[[[ ]]]
-                       )],
-                       [c_cv_have_perl_ithreads="yes"],
-                       [c_cv_have_perl_ithreads="no"]
-               )
-       )
-
-       if test "x$c_cv_have_perl_ithreads" = "xyes"
-       then
-               AC_DEFINE(HAVE_PERL_ITHREADS, 1, [Define if Perl supports ithreads.])
-       fi
-
-       CFLAGS="$SAVE_CFLAGS"
-       LDFLAGS="$SAVE_LDFLAGS"
-fi
-
-if test "x$with_libperl" = "xyes"
-then
-       SAVE_CFLAGS="$CFLAGS"
-       SAVE_LDFLAGS="$LDFLAGS"
-       # trigger an error if Perl_load_module*() uses __attribute__nonnull__(3)
-       # (see issues #41 and #42)
-       CFLAGS="$CFLAGS $PERL_CFLAGS -Wall -Werror"
-       LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
-
-       AC_CACHE_CHECK([for broken Perl_load_module()],
-               [c_cv_have_broken_perl_load_module],
-               AC_LINK_IFELSE([AC_LANG_PROGRAM(
-[[[
-#define PERL_NO_GET_CONTEXT
-#include <EXTERN.h>
-#include <perl.h>
-#include <XSUB.h>
-]]],
-[[[
-                        dTHX;
-                        load_module (PERL_LOADMOD_NOIMPORT,
-                            newSVpv ("Collectd::Plugin::FooBar", 24),
-                            Nullsv);
-]]]
-                       )],
-                       [c_cv_have_broken_perl_load_module="no"],
-                       [c_cv_have_broken_perl_load_module="yes"]
-               )
-       )
-
-       CFLAGS="$SAVE_CFLAGS"
-       LDFLAGS="$SAVE_LDFLAGS"
-fi
-AM_CONDITIONAL(HAVE_BROKEN_PERL_LOAD_MODULE,
-               test "x$c_cv_have_broken_perl_load_module" = "xyes")
-
-if test "x$with_libperl" = "xyes"
-then
-       SAVE_CFLAGS="$CFLAGS"
-       SAVE_LDFLAGS="$LDFLAGS"
-       CFLAGS="$CFLAGS $PERL_CFLAGS"
-       LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
-
-       AC_CHECK_MEMBER(
-               [struct mgvtbl.svt_local],
-               [have_struct_mgvtbl_svt_local="yes"],
-               [have_struct_mgvtbl_svt_local="no"],
-               [
-#include <EXTERN.h>
-#include <perl.h>
-#include <XSUB.h>
-               ])
-
-       if test "x$have_struct_mgvtbl_svt_local" = "xyes"
-       then
-               AC_DEFINE(HAVE_PERL_STRUCT_MGVTBL_SVT_LOCAL, 1,
-                                 [Define if Perl's struct mgvtbl has member svt_local.])
-       fi
-
-       CFLAGS="$SAVE_CFLAGS"
-       LDFLAGS="$SAVE_LDFLAGS"
-fi
-# }}}
-
-# --with-libpq {{{
-with_pg_config="pg_config"
-with_libpq_includedir=""
-with_libpq_libdir=""
-with_libpq_cppflags=""
-with_libpq_ldflags=""
-AC_ARG_WITH(libpq, [AS_HELP_STRING([--with-libpq@<:@=PREFIX@:>@],
-       [Path to libpq.])],
-[
-       if test "x$withval" = "xno"
-       then
-               with_libpq="no"
-       else if test "x$withval" = "xyes"
-       then
-               with_libpq="yes"
-       else
-               if test -f "$withval" && test -x "$withval";
-               then
-                       with_pg_config="$withval"
-               else if test -x "$withval/bin/pg_config"
-               then
-                       with_pg_config="$withval/bin/pg_config"
-               fi; fi
-               with_libpq="yes"
-       fi; fi
-],
-[
-       with_libpq="yes"
-])
-if test "x$with_libpq" = "xyes"
-then
-       with_libpq_includedir=`$with_pg_config --includedir 2> /dev/null`
-       pg_config_status=$?
-
-       if test $pg_config_status -eq 0
-       then
-               if test -n "$with_libpq_includedir"; then
-                       for dir in $with_libpq_includedir; do
-                               with_libpq_cppflags="$with_libpq_cppflags -I$dir"
-                       done
-               fi
-       else
-               AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
-       fi
-
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       CPPFLAGS="$CPPFLAGS $with_libpq_cppflags"
-
-       AC_CHECK_HEADERS(libpq-fe.h, [],
-               [with_libpq="no (libpq-fe.h not found)"], [])
-
-       CPPFLAGS="$SAVE_CPPFLAGS"
-fi
-if test "x$with_libpq" = "xyes"
-then
-       with_libpq_libdir=`$with_pg_config --libdir 2> /dev/null`
-       pg_config_status=$?
-
-       if test $pg_config_status -eq 0
-       then
-               if test -n "$with_libpq_libdir"; then
-                       for dir in $with_libpq_libdir; do
-                               with_libpq_ldflags="$with_libpq_ldflags -L$dir"
-                       done
-               fi
-       else
-               AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
-       fi
-
-       SAVE_LDFLAGS="$LDFLAGS"
-       LDFLAGS="$LDFLAGS $with_libpq_ldflags"
-
-       AC_CHECK_LIB(pq, PQconnectdb,
-               [with_libpq="yes"],
-               [with_libpq="no (symbol 'PQconnectdb' not found)"])
-
-       AC_CHECK_LIB(pq, PQserverVersion,
-               [with_libpq="yes"],
-               [with_libpq="no (symbol 'PQserverVersion' not found)"])
-
-       LDFLAGS="$SAVE_LDFLAGS"
-fi
-if test "x$with_libpq" = "xyes"
-then
-       BUILD_WITH_LIBPQ_CPPFLAGS="$with_libpq_cppflags"
-       BUILD_WITH_LIBPQ_LDFLAGS="$with_libpq_ldflags"
-       AC_SUBST(BUILD_WITH_LIBPQ_CPPFLAGS)
-       AC_SUBST(BUILD_WITH_LIBPQ_LDFLAGS)
-fi
-AM_CONDITIONAL(BUILD_WITH_LIBPQ, test "x$with_libpq" = "xyes")
-# }}}
-
-# --with-libpthread {{{
-AC_ARG_WITH(libpthread, [AS_HELP_STRING([--with-libpthread=@<:@=PREFIX@:>@], [Path to libpthread.])],
-[      if test "x$withval" != "xno" \
-               && test "x$withval" != "xyes"
-       then
-               LDFLAGS="$LDFLAGS -L$withval/lib"
-               CPPFLAGS="$CPPFLAGS -I$withval/include"
-               with_libpthread="yes"
-       else
-               if test "x$withval" = "xno"
-               then
-                       with_libpthread="no (disabled)"
-               fi
-       fi
-], [with_libpthread="yes"])
-if test "x$with_libpthread" = "xyes"
-then
-       AC_CHECK_LIB(pthread, pthread_create, [with_libpthread="yes"], [with_libpthread="no (libpthread not found)"], [])
-fi
-
-if test "x$with_libpthread" = "xyes"
-then
-       AC_CHECK_HEADERS(pthread.h,, [with_libpthread="no (pthread.h not found)"])
-fi
-if test "x$with_libpthread" = "xyes"
-then
-       collect_pthread=1
-else
-       collect_pthread=0
-fi
-AC_DEFINE_UNQUOTED(HAVE_LIBPTHREAD, [$collect_pthread],
-       [Wether or not to use pthread (POSIX threads) library])
-AM_CONDITIONAL(BUILD_WITH_LIBPTHREAD, test "x$with_libpthread" = "xyes")
-# }}}
-
-# --with-python {{{
-with_python_prog=""
-with_python_path="$PATH"
-AC_ARG_WITH(python, [AS_HELP_STRING([--with-python@<:@=PREFIX@:>@], [Path to the python interpreter.])],
-[
- if test "x$withval" = "xyes" || test "x$withval" = "xno"
- then
-        with_python="$withval"
- else if test -x "$withval"
- then
-        with_python_prog="$withval"
-        with_python_path="`dirname \"$withval\"`$PATH_SEPARATOR$with_python_path"
-        with_python="yes"
- else if test -d "$withval"
- then
-        with_python_path="$withval$PATH_SEPARATOR$with_python_path"
-        with_python="yes"
- else
-        AC_MSG_WARN([Argument not recognized: $withval])
- fi; fi; fi
-], [with_python="yes"])
-
-SAVE_PATH="$PATH"
-SAVE_CPPFLAGS="$CPPFLAGS"
-SAVE_LDFLAGS="$LDFLAGS"
-SAVE_LIBS="$LIBS"
-
-PATH="$with_python_path"
-
-if test "x$with_python" = "xyes" && test "x$with_python_prog" = "x"
-then
-       AC_MSG_CHECKING([for python])
-       with_python_prog="`which python 2>/dev/null`"
-       if test "x$with_python_prog" = "x"
-       then
-               AC_MSG_RESULT([not found])
-               with_python="no (interpreter not found)"
-       else
-               AC_MSG_RESULT([$with_python_prog])
-       fi
-fi
-
-if test "x$with_python" = "xyes"
-then
-       AC_MSG_CHECKING([for Python CPPFLAGS])
-       python_include_path=`echo "import distutils.sysconfig;import sys;sys.stdout.write(distutils.sysconfig.get_python_inc())" | "$with_python_prog" 2>&1`
-       python_config_status=$?
-
-       if test "$python_config_status" -ne 0 || test "x$python_include_path" = "x"
-       then
-               AC_MSG_RESULT([failed with status $python_config_status (output: $python_include_path)])
-               with_python="no"
-       else
-               AC_MSG_RESULT([$python_include_path])
-       fi
-fi
-
-if test "x$with_python" = "xyes"
-then
-       CPPFLAGS="-I$python_include_path $CPPFLAGS"
-       AC_CHECK_HEADERS(Python.h,
-                        [with_python="yes"],
-                        [with_python="no ('Python.h' not found)"])
-fi
-
-if test "x$with_python" = "xyes"
-then
-       AC_MSG_CHECKING([for Python LDFLAGS])
-       python_library_path=`echo "import distutils.sysconfig;import sys;sys.stdout.write(distutils.sysconfig.get_config_vars(\"LIBDIR\").__getitem__(0))" | "$with_python_prog" 2>&1`
-       python_config_status=$?
-
-       if test "$python_config_status" -ne 0 || test "x$python_library_path" = "x"
-       then
-               AC_MSG_RESULT([failed with status $python_config_status (output: $python_library_path)])
-               with_python="no"
-       else
-               AC_MSG_RESULT([$python_library_path])
-       fi
-fi
-
-if test "x$with_python" = "xyes"
-then
-       AC_MSG_CHECKING([for Python LIBS])
-       python_library_flags=`echo "import distutils.sysconfig;import sys;sys.stdout.write(distutils.sysconfig.get_config_vars(\"BLDLIBRARY\").__getitem__(0))" | "$with_python_prog" 2>&1`
-       python_config_status=$?
-
-       if test "$python_config_status" -ne 0 || test "x$python_library_flags" = "x"
-       then
-               AC_MSG_RESULT([failed with status $python_config_status (output: $python_library_flags)])
-               with_python="no"
-       else
-               AC_MSG_RESULT([$python_library_flags])
-       fi
-fi
-
-if test "x$with_python" = "xyes"
-then
-       LDFLAGS="-L$python_library_path $LDFLAGS"
-       LIBS="$python_library_flags $LIBS"
-
-       AC_CHECK_FUNC(PyObject_CallFunction,
-                     [with_python="yes"],
-                     [with_python="no (Symbol 'PyObject_CallFunction' not found)"])
-fi
-
-PATH="$SAVE_PATH"
-CPPFLAGS="$SAVE_CPPFLAGS"
-LDFLAGS="$SAVE_LDFLAGS"
-LIBS="$SAVE_LIBS"
-
-if test "x$with_python" = "xyes"
-then
-       BUILD_WITH_PYTHON_CPPFLAGS="-I$python_include_path"
-       BUILD_WITH_PYTHON_LDFLAGS="-L$python_library_path"
-       BUILD_WITH_PYTHON_LIBS="$python_library_flags"
-       AC_SUBST(BUILD_WITH_PYTHON_CPPFLAGS)
-       AC_SUBST(BUILD_WITH_PYTHON_LDFLAGS)
-       AC_SUBST(BUILD_WITH_PYTHON_LIBS)
-fi
-# }}} --with-python
-
-# --with-librabbitmq {{{
-with_librabbitmq_cppflags=""
-with_librabbitmq_ldflags=""
-AC_ARG_WITH(librabbitmq, [AS_HELP_STRING([--with-librabbitmq@<:@=PREFIX@:>@], [Path to librabbitmq.])],
-[
-       if test "x$withval" != "xno" && test "x$withval" != "xyes"
-       then
-               with_librabbitmq_cppflags="-I$withval/include"
-               with_librabbitmq_ldflags="-L$withval/lib"
-               with_librabbitmq="yes"
-       else
-               with_librabbitmq="$withval"
-       fi
-],
-[
-       with_librabbitmq="yes"
-])
-SAVE_CPPFLAGS="$CPPFLAGS"
-SAVE_LDFLAGS="$LDFLAGS"
-CPPFLAGS="$CPPFLAGS $with_librabbitmq_cppflags"
-LDFLAGS="$LDFLAGS $with_librabbitmq_ldflags"
-if test "x$with_librabbitmq" = "xyes"
-then
-       AC_CHECK_HEADERS(amqp.h, [with_librabbitmq="yes"], [with_librabbitmq="no (amqp.h not found)"])
-fi
-if test "x$with_librabbitmq" = "xyes"
-then
-       # librabbitmq up to version 0.9.1 provides "library_errno", later
-       # versions use "library_error". The library does not provide a version
-       # macro :( Use "AC_CHECK_MEMBERS" (plural) for automatic defines.
-       AC_CHECK_MEMBERS([amqp_rpc_reply_t.library_errno],,,
-                        [
-#if HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
-#if HAVE_STDIO_H
-# include <stdio.h>
-#endif
-#if HAVE_STDINT_H
-# include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H
-# include <inttypes.h>
-#endif
-#include <amqp.h>
-                         ])
-fi
-if test "x$with_librabbitmq" = "xyes"
-then
-       AC_CHECK_LIB(rabbitmq, amqp_basic_publish, [with_librabbitmq="yes"], [with_librabbitmq="no (Symbol 'amqp_basic_publish' not found)"])
-fi
-if test "x$with_librabbitmq" = "xyes"
-then
-       BUILD_WITH_LIBRABBITMQ_CPPFLAGS="$with_librabbitmq_cppflags"
-       BUILD_WITH_LIBRABBITMQ_LDFLAGS="$with_librabbitmq_ldflags"
-       BUILD_WITH_LIBRABBITMQ_LIBS="-lrabbitmq"
-       AC_SUBST(BUILD_WITH_LIBRABBITMQ_CPPFLAGS)
-       AC_SUBST(BUILD_WITH_LIBRABBITMQ_LDFLAGS)
-       AC_SUBST(BUILD_WITH_LIBRABBITMQ_LIBS)
-       AC_DEFINE(HAVE_LIBRABBITMQ, 1, [Define if librabbitmq is present and usable.])
-fi
-CPPFLAGS="$SAVE_CPPFLAGS"
-LDFLAGS="$SAVE_LDFLAGS"
-AM_CONDITIONAL(BUILD_WITH_LIBRABBITMQ, test "x$with_librabbitmq" = "xyes")
-# }}}
-
-# --with-librouteros {{{
-AC_ARG_WITH(librouteros, [AS_HELP_STRING([--with-librouteros@<:@=PREFIX@:>@], [Path to librouteros.])],
-[
- if test "x$withval" = "xyes"
- then
-        with_librouteros="yes"
- else if test "x$withval" = "xno"
- then
-        with_librouteros="no"
- else
-        with_librouteros="yes"
-        LIBROUTEROS_CPPFLAGS="$LIBROUTEROS_CPPFLAGS -I$withval/include"
-        LIBROUTEROS_LDFLAGS="$LIBROUTEROS_LDFLAGS -L$withval/lib"
- fi; fi
-],
-[with_librouteros="yes"])
-
-SAVE_CPPFLAGS="$CPPFLAGS"
-SAVE_LDFLAGS="$LDFLAGS"
-
-CPPFLAGS="$CPPFLAGS $LIBROUTEROS_CPPFLAGS"
-LDFLAGS="$LDFLAGS $LIBROUTEROS_LDFLAGS"
-
-if test "x$with_librouteros" = "xyes"
-then
-       if test "x$LIBROUTEROS_CPPFLAGS" != "x"
-       then
-               AC_MSG_NOTICE([librouteros CPPFLAGS: $LIBROUTEROS_CPPFLAGS])
-       fi
-       AC_CHECK_HEADERS(routeros_api.h,
-       [with_librouteros="yes"],
-       [with_librouteros="no (routeros_api.h not found)"])
-fi
-if test "x$with_librouteros" = "xyes"
-then
-       if test "x$LIBROUTEROS_LDFLAGS" != "x"
-       then
-               AC_MSG_NOTICE([librouteros LDFLAGS: $LIBROUTEROS_LDFLAGS])
-       fi
-       AC_CHECK_LIB(routeros, ros_interface,
-       [with_librouteros="yes"],
-       [with_librouteros="no (symbol 'ros_interface' not found)"])
-fi
-
-CPPFLAGS="$SAVE_CPPFLAGS"
-LDFLAGS="$SAVE_LDFLAGS"
-
-if test "x$with_librouteros" = "xyes"
-then
-       BUILD_WITH_LIBROUTEROS_CPPFLAGS="$LIBROUTEROS_CPPFLAGS"
-       BUILD_WITH_LIBROUTEROS_LDFLAGS="$LIBROUTEROS_LDFLAGS"
-       AC_SUBST(BUILD_WITH_LIBROUTEROS_CPPFLAGS)
-       AC_SUBST(BUILD_WITH_LIBROUTEROS_LDFLAGS)
-fi
-AM_CONDITIONAL(BUILD_WITH_LIBROUTEROS, test "x$with_librouteros" = "xyes")
-# }}}
-
-# --with-librrd {{{
-# AC_ARG_WITH (package, help-string, [action-if-given], [action-if-not-given])
-librrd_cflags=""
-librrd_ldflags=""
-librrd_threadsafe="yes"
-librrd_rrdc_update="no"
-AC_ARG_WITH(librrd, [AS_HELP_STRING([--with-librrd@<:@=PREFIX@:>@], [Path to rrdtool.])],
-[      if test "x$withval" != "xno" && test "x$withval" != "xyes"
-       then
-               librrd_cflags="-I$withval/include"
-               librrd_ldflags="-L$withval/lib"
-               with_librrd="yes"
-       else
-               with_librrd="$withval"
-       fi
-], [with_librrd="yes"])
-if test "x$with_librrd" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       SAVE_LDFLAGS="$LDFLAGS"
-
-       CPPFLAGS="$CPPFLAGS $librrd_cflags"
-       LDFLAGS="$LDFLAGS $librrd_ldflags"
-
-       AC_CHECK_HEADERS(rrd.h,, [with_librrd="no (rrd.h not found)"])
-
-       CPPFLAGS="$SAVE_CPPFLAGS"
-       LDFLAGS="$SAVE_LDFLAGS"
-fi
-if test "x$with_librrd" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       SAVE_LDFLAGS="$LDFLAGS"
-
-       CPPFLAGS="$CPPFLAGS $librrd_cflags"
-       LDFLAGS="$LDFLAGS $librrd_ldflags"
-
-       AC_CHECK_LIB(rrd_th, rrd_update_r,
-       [with_librrd="yes"
-        librrd_ldflags="$librrd_ldflags -lrrd_th -lm"
-       ],
-       [librrd_threadsafe="no"
-        AC_CHECK_LIB(rrd, rrd_update,
-        [with_librrd="yes"
-         librrd_ldflags="$librrd_ldflags -lrrd -lm"
-        ],
-        [with_librrd="no (symbol 'rrd_update' not found)"],
-        [-lm])
-       ],
-       [-lm])
-
-       if test "x$librrd_threadsafe" = "xyes"
-       then
-               AC_CHECK_LIB(rrd_th, rrdc_update, [librrd_rrdc_update="yes"], [librrd_rrdc_update="no"])
-       else
-               AC_CHECK_LIB(rrd, rrdc_update, [librrd_rrdc_update="yes"], [librrd_rrdc_update="no"])
-       fi
-
-       CPPFLAGS="$SAVE_CPPFLAGS"
-       LDFLAGS="$SAVE_LDFLAGS"
-fi
-if test "x$with_librrd" = "xyes"
-then
-       BUILD_WITH_LIBRRD_CFLAGS="$librrd_cflags"
-       BUILD_WITH_LIBRRD_LDFLAGS="$librrd_ldflags"
-       AC_SUBST(BUILD_WITH_LIBRRD_CFLAGS)
-       AC_SUBST(BUILD_WITH_LIBRRD_LDFLAGS)
-fi
-if test "x$librrd_threadsafe" = "xyes"
-then
-       AC_DEFINE(HAVE_THREADSAFE_LIBRRD, 1, [Define to 1 if you have the threadsafe rrd library (-lrrd_th).])
-fi
-# }}}
-
-# --with-libsensors {{{
-with_sensors_cflags=""
-with_sensors_ldflags=""
-AC_ARG_WITH(libsensors, [AS_HELP_STRING([--with-libsensors@<:@=PREFIX@:>@], [Path to lm_sensors.])],
-[
-       if test "x$withval" = "xno"
-       then
-               with_libsensors="no"
-       else
-               with_libsensors="yes"
-               if test "x$withval" != "xyes"
-               then
-                       with_sensors_cflags="-I$withval/include"
-                       with_sensors_ldflags="-L$withval/lib"
-                       with_libsensors="yes"
-               fi
-       fi
-],
-[
-       if test "x$ac_system" = "xLinux"
-       then
-               with_libsensors="yes"
-       else
-               with_libsensors="no (Linux only library)"
-       fi
-])
-if test "x$with_libsensors" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
-
-#      AC_CHECK_HEADERS(sensors/sensors.h,
-#      [
-#              AC_DEFINE(HAVE_SENSORS_SENSORS_H, 1, [Define to 1 if you have the <sensors/sensors.h> header file.])
-#      ],
-#      [with_libsensors="no (sensors/sensors.h not found)"])
-       AC_CHECK_HEADERS(sensors/sensors.h, [], [with_libsensors="no (sensors/sensors.h not found)"])
-
-       CPPFLAGS="$SAVE_CPPFLAGS"
-fi
-if test "x$with_libsensors" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       SAVE_LDFLAGS="$LDFLAGS"
-       CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
-       LDFLAGS="$LDFLAGS $with_sensors_ldflags"
-
-       AC_CHECK_LIB(sensors, sensors_init,
-       [
-               AC_DEFINE(HAVE_LIBSENSORS, 1, [Define to 1 if you have the sensors library (-lsensors).])
-       ],
-       [with_libsensors="no (libsensors not found)"])
-
-       CPPFLAGS="$SAVE_CPPFLAGS"
-       LDFLAGS="$SAVE_LDFLAGS"
-fi
-if test "x$with_libsensors" = "xyes"
-then
-       BUILD_WITH_LIBSENSORS_CFLAGS="$with_sensors_cflags"
-       BUILD_WITH_LIBSENSORS_LDFLAGS="$with_sensors_ldflags"
-       AC_SUBST(BUILD_WITH_LIBSENSORS_CFLAGS)
-       AC_SUBST(BUILD_WITH_LIBSENSORS_LDFLAGS)
-fi
-AM_CONDITIONAL(BUILD_WITH_LM_SENSORS, test "x$with_libsensors" = "xyes")
-# }}}
-
-# --with-libsigrok {{{
-with_libsigrok_cflags=""
-with_libsigrok_ldflags=""
-AC_ARG_WITH(libsigrok, [AS_HELP_STRING([--with-libsigrok@<:@=PREFIX@:>@], [Path to libsigrok.])],
-[
-       if test "x$withval" = "xno"
-       then
-               with_libsigrok="no"
-       else
-               with_libsigrok="yes"
-               if test "x$withval" != "xyes"
-               then
-                       with_libsigrok_cflags="-I$withval/include"
-                       with_libsigrok_ldflags="-L$withval/lib"
-               fi
-       fi
-],[])
-
-# libsigrok has a glib dependency
-if test "x$with_libsigrok" = "xyes"
-then
-       if test -z "m4_ifdef([AM_PATH_GLIB_2_0], [yes], [])"
-       then
-               with_libsigrok="no (glib not available)"
-       else
-               AM_PATH_GLIB_2_0([2.28.0],
-                       [with_libsigrok_cflags="$with_libsigrok_cflags $GLIB_CFLAGS"; with_libsigrok_ldflags="$with_libsigrok_ldflags $GLIB_LIBS"])
-       fi
-fi
-
-# libsigrok headers
-if test "x$with_libsigrok" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       CPPFLAGS="$CPPFLAGS $with_libsigrok_cflags"
-
-       AC_CHECK_HEADERS(libsigrok/libsigrok.h, [], [with_libsigrok="no (libsigrok/libsigrok.h not found)"])
-
-       CPPFLAGS="$SAVE_CPPFLAGS"
-fi
-
-# libsigrok library
-if test "x$with_libsigrok" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       SAVE_LDFLAGS="$LDFLAGS"
-       CPPFLAGS="$CPPFLAGS $with_libsigrok_cflags"
-       LDFLAGS="$LDFLAGS $with_libsigrok_ldflags"
-
-       AC_CHECK_LIB(sigrok, sr_init,
-       [
-               AC_DEFINE(HAVE_LIBSIGROK, 1, [Define to 1 if you have the sigrok library (-lsigrok).])
-       ],
-       [with_libsigrok="no (libsigrok not found)"])
-
-       CPPFLAGS="$SAVE_CPPFLAGS"
-       LDFLAGS="$SAVE_LDFLAGS"
-fi
-if test "x$with_libsigrok" = "xyes"
-then
-       BUILD_WITH_LIBSIGROK_CFLAGS="$with_libsigrok_cflags"
-       BUILD_WITH_LIBSIGROK_LDFLAGS="$with_libsigrok_ldflags"
-       AC_SUBST(BUILD_WITH_LIBSIGROK_CFLAGS)
-       AC_SUBST(BUILD_WITH_LIBSIGROK_LDFLAGS)
-fi
-AM_CONDITIONAL(BUILD_WITH_LIBSIGROK, test "x$with_libsigrok" = "xyes")
-# }}}
-
-# --with-libstatgrab {{{
-with_libstatgrab_cflags=""
-with_libstatgrab_ldflags=""
-AC_ARG_WITH(libstatgrab, [AS_HELP_STRING([--with-libstatgrab@<:@=PREFIX@:>@], [Path to libstatgrab.])],
-[
- if test "x$withval" != "xno" \
-   && test "x$withval" != "xyes"
- then
-   with_libstatgrab_cflags="-I$withval/include"
-   with_libstatgrab_ldflags="-L$withval/lib -lstatgrab"
-   with_libstatgrab="yes"
-   with_libstatgrab_pkg_config="no"
- else
-   with_libstatgrab="$withval"
-   with_libstatgrab_pkg_config="yes"
- fi
- ],
-[
- with_libstatgrab="yes"
- with_libstatgrab_pkg_config="yes"
-])
-
-if test "x$with_libstatgrab" = "xyes" \
-  && test "x$with_libstatgrab_pkg_config" = "xyes"
-then
-  if test "x$PKG_CONFIG" != "x"
-  then
-    AC_MSG_CHECKING([pkg-config for libstatgrab])
-    temp_result="found"
-    $PKG_CONFIG --exists libstatgrab 2>/dev/null
-    if test "$?" != "0"
-    then
-      with_libstatgrab_pkg_config="no"
-      with_libstatgrab="no (pkg-config doesn't know libstatgrab)"
-      temp_result="not found"
-    fi
-    AC_MSG_RESULT([$temp_result])
-  else
-    AC_MSG_NOTICE([pkg-config not available, trying to guess flags for the statgrab library.])
-    with_libstatgrab_pkg_config="no"
-    with_libstatgrab_ldflags="$with_libstatgrab_ldflags -lstatgrab"
-  fi
-fi
-
-if test "x$with_libstatgrab" = "xyes" \
-  && test "x$with_libstatgrab_pkg_config" = "xyes" \
-  && test "x$with_libstatgrab_cflags" = "x"
-then
-  AC_MSG_CHECKING([for libstatgrab CFLAGS])
-  temp_result="`$PKG_CONFIG --cflags libstatgrab`"
-  if test "$?" = "0"
-  then
-    with_libstatgrab_cflags="$temp_result"
-  else
-    with_libstatgrab="no ($PKG_CONFIG --cflags libstatgrab failed)"
-    temp_result="$PKG_CONFIG --cflags libstatgrab failed"
-  fi
-  AC_MSG_RESULT([$temp_result])
-fi
-
-if test "x$with_libstatgrab" = "xyes" \
-  && test "x$with_libstatgrab_pkg_config" = "xyes" \
-  && test "x$with_libstatgrab_ldflags" = "x"
-then
-  AC_MSG_CHECKING([for libstatgrab LDFLAGS])
-  temp_result="`$PKG_CONFIG --libs libstatgrab`"
-  if test "$?" = "0"
-  then
-    with_libstatgrab_ldflags="$temp_result"
-  else
-    with_libstatgrab="no ($PKG_CONFIG --libs libstatgrab failed)"
-    temp_result="$PKG_CONFIG --libs libstatgrab failed"
-  fi
-  AC_MSG_RESULT([$temp_result])
-fi
-
-if test "x$with_libstatgrab" = "xyes"
-then
-  SAVE_CPPFLAGS="$CPPFLAGS"
-  CPPFLAGS="$CPPFLAGS $with_libstatgrab_cflags"
-
-  AC_CHECK_HEADERS(statgrab.h,
-                  [with_libstatgrab="yes"],
-                  [with_libstatgrab="no (statgrab.h not found)"])
-
-  CPPFLAGS="$SAVE_CPPFLAGS"
-fi
-
-if test "x$with_libstatgrab" = "xyes"
-then
-  SAVE_CFLAGS="$CFLAGS"
-  SAVE_LDFLAGS="$LDFLAGS"
-
-  CFLAGS="$CFLAGS $with_libstatgrab_cflags"
-  LDFLAGS="$LDFLAGS $with_libstatgrab_ldflags"
-
-  AC_CHECK_LIB(statgrab, sg_init,
-              [with_libstatgrab="yes"],
-              [with_libstatgrab="no (symbol sg_init not found)"])
-
-  CFLAGS="$SAVE_CFLAGS"
-  LDFLAGS="$SAVE_LDFLAGS"
-fi
-
-AM_CONDITIONAL(BUILD_WITH_LIBSTATGRAB, test "x$with_libstatgrab" = "xyes")
-if test "x$with_libstatgrab" = "xyes"
-then
-  AC_DEFINE(HAVE_LIBSTATGRAB, 1, [Define to 1 if you have the 'statgrab' library (-lstatgrab)])
-  BUILD_WITH_LIBSTATGRAB_CFLAGS="$with_libstatgrab_cflags"
-  BUILD_WITH_LIBSTATGRAB_LDFLAGS="$with_libstatgrab_ldflags"
-  AC_SUBST(BUILD_WITH_LIBSTATGRAB_CFLAGS)
-  AC_SUBST(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
-fi
-# }}}
-
-# --with-libtokyotyrant {{{
-with_libtokyotyrant_cppflags=""
-with_libtokyotyrant_ldflags=""
-with_libtokyotyrant_libs=""
-AC_ARG_WITH(libtokyotyrant, [AS_HELP_STRING([--with-libtokyotyrant@<:@=PREFIX@:>@], [Path to libtokyotyrant.])],
-[
-  if test "x$withval" = "xno"
-  then
-    with_libtokyotyrant="no"
-  else if test "x$withval" = "xyes"
-  then
-    with_libtokyotyrant="yes"
-  else
-    with_libtokyotyrant_cppflags="-I$withval/include"
-    with_libtokyotyrant_ldflags="-L$withval/include"
-    with_libtokyotyrant_libs="-ltokyotyrant"
-    with_libtokyotyrant="yes"
-  fi; fi
-],
-[
-  with_libtokyotyrant="yes"
-])
-
-if test "x$with_libtokyotyrant" = "xyes"
-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`"
-  fi
-fi
-
-SAVE_CPPFLAGS="$CPPFLAGS"
-SAVE_LDFLAGS="$LDFLAGS"
-CPPFLAGS="$CPPFLAGS $with_libtokyotyrant_cppflags"
-LDFLAGS="$LDFLAGS $with_libtokyotyrant_ldflags"
-
-if test "x$with_libtokyotyrant" = "xyes"
-then
-  AC_CHECK_HEADERS(tcrdb.h,
-  [
-          AC_DEFINE(HAVE_TCRDB_H, 1,
-                    [Define to 1 if you have the <tcrdb.h> header file.])
-  ], [with_libtokyotyrant="no (tcrdb.h not found)"])
-fi
-
-if test "x$with_libtokyotyrant" = "xyes"
-then
-  AC_CHECK_LIB(tokyotyrant, tcrdbrnum,
-  [
-          AC_DEFINE(HAVE_LIBTOKYOTYRANT, 1,
-                    [Define to 1 if you have the tokyotyrant library (-ltokyotyrant).])
-  ],
-  [with_libtokyotyrant="no (symbol tcrdbrnum not found)"],
-  [$with_libtokyotyrant_libs])
-fi
-
-CPPFLAGS="$SAVE_CPPFLAGS"
-LDFLAGS="$SAVE_LDFLAGS"
-
-if test "x$with_libtokyotyrant" = "xyes"
-then 
-  BUILD_WITH_LIBTOKYOTYRANT_CPPFLAGS="$with_libtokyotyrant_cppflags"
-  BUILD_WITH_LIBTOKYOTYRANT_LDFLAGS="$with_libtokyotyrant_ldflags"
-  BUILD_WITH_LIBTOKYOTYRANT_LIBS="$with_libtokyotyrant_libs"
-  AC_SUBST(BUILD_WITH_LIBTOKYOTYRANT_CPPFLAGS)
-  AC_SUBST(BUILD_WITH_LIBTOKYOTYRANT_LDFLAGS)
-  AC_SUBST(BUILD_WITH_LIBTOKYOTYRANT_LIBS)
-fi
-AM_CONDITIONAL(BUILD_WITH_LIBTOKYOTYRANT, test "x$with_libtokyotyrant" = "xyes")
-# }}}
-
-# --with-libupsclient {{{
-with_libupsclient_config=""
-with_libupsclient_cflags=""
-with_libupsclient_libs=""
-AC_ARG_WITH(libupsclient, [AS_HELP_STRING([--with-libupsclient@<:@=PREFIX@:>@], [Path to the upsclient library.])],
-[
-       if test "x$withval" = "xno"
-       then
-               with_libupsclient="no"
-       else if test "x$withval" = "xyes"
-       then
-               with_libupsclient="use_pkgconfig"
-       else
-               if test -x "$withval"
-               then
-                       with_libupsclient_config="$withval"
-                       with_libupsclient="use_libupsclient_config"
-               else if test -x "$withval/bin/libupsclient-config"
-               then
-                       with_libupsclient_config="$withval/bin/libupsclient-config"
-                       with_libupsclient="use_libupsclient_config"
-               else
-                       AC_MSG_NOTICE([Not checking for libupsclient: Manually configured])
-                       with_libupsclient_cflags="-I$withval/include"
-                       with_libupsclient_libs="-L$withval/lib -lupsclient"
-                       with_libupsclient="yes"
-               fi; fi
-       fi; fi
-],
-[with_libupsclient="use_pkgconfig"])
-
-# configure using libupsclient-config
-if test "x$with_libupsclient" = "xuse_libupsclient_config"
-then
-       AC_MSG_NOTICE([Checking for libupsclient using $with_libupsclient_config])
-       with_libupsclient_cflags="`$with_libupsclient_config --cflags`"
-       if test $? -ne 0
-       then
-               with_libupsclient="no ($with_libupsclient_config failed)"
-       fi
-       with_libupsclient_libs="`$with_libupsclient_config --libs`"
-       if test $? -ne 0
-       then
-               with_libupsclient="no ($with_libupsclient_config failed)"
-       fi
-fi
-if test "x$with_libupsclient" = "xuse_libupsclient_config"
-then
-       with_libupsclient="yes"
-fi
-
-# configure using pkg-config
-if test "x$with_libupsclient" = "xuse_pkgconfig"
-then
-       if test "x$PKG_CONFIG" = "x"
-       then
-               with_libupsclient="no (Don't have pkg-config)"
-       fi
-fi
-if test "x$with_libupsclient" = "xuse_pkgconfig"
-then
-       AC_MSG_NOTICE([Checking for libupsclient using $PKG_CONFIG])
-       $PKG_CONFIG --exists 'libupsclient' 2>/dev/null
-       if test $? -ne 0
-       then
-               with_libupsclient="no (pkg-config doesn't know libupsclient)"
-       fi
-fi
-if test "x$with_libupsclient" = "xuse_pkgconfig"
-then
-       with_libupsclient_cflags="`$PKG_CONFIG --cflags 'libupsclient'`"
-       if test $? -ne 0
-       then
-               with_libupsclient="no ($PKG_CONFIG failed)"
-       fi
-       with_libupsclient_libs="`$PKG_CONFIG --libs 'libupsclient'`"
-       if test $? -ne 0
-       then
-               with_libupsclient="no ($PKG_CONFIG failed)"
-       fi
-fi
-if test "x$with_libupsclient" = "xuse_pkgconfig"
-then
-       with_libupsclient="yes"
-fi
-
-# with_libupsclient_cflags and with_libupsclient_libs are set up now, let's do
-# the actual checks.
-if test "x$with_libupsclient" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
-
-       AC_CHECK_HEADERS(upsclient.h, [], [with_libupsclient="no (upsclient.h not found)"])
-
-       CPPFLAGS="$SAVE_CPPFLAGS"
-fi
-if test "x$with_libupsclient" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       SAVE_LDFLAGS="$LDFLAGS"
-
-       CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
-       LDFLAGS="$LDFLAGS $with_libupsclient_libs"
-
-       AC_CHECK_LIB(upsclient, upscli_connect,
-                    [with_libupsclient="yes"],
-                    [with_libupsclient="no (symbol upscli_connect not found)"])
-
-       CPPFLAGS="$SAVE_CPPFLAGS"
-       LDFLAGS="$SAVE_LDFLAGS"
-fi
-if test "x$with_libupsclient" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
-
-       AC_CHECK_TYPES([UPSCONN_t, UPSCONN], [], [],
-[#include <stdlib.h>
-#include <stdio.h>
-#include <upsclient.h>])
-
-       CPPFLAGS="$SAVE_CPPFLAGS"
-fi
-if test "x$with_libupsclient" = "xyes"
-then
-       BUILD_WITH_LIBUPSCLIENT_CFLAGS="$with_libupsclient_cflags"
-       BUILD_WITH_LIBUPSCLIENT_LIBS="$with_libupsclient_libs"
-       AC_SUBST(BUILD_WITH_LIBUPSCLIENT_CFLAGS)
-       AC_SUBST(BUILD_WITH_LIBUPSCLIENT_LIBS)
-fi
-# }}}
-
-# --with-libxmms {{{
-with_xmms_config="xmms-config"
-with_xmms_cflags=""
-with_xmms_libs=""
-AC_ARG_WITH(libxmms, [AS_HELP_STRING([--with-libxmms@<:@=PREFIX@:>@], [Path to libxmms.])],
-[
-       if test "x$withval" != "xno" \
-               && test "x$withval" != "xyes"
-       then
-               if test -f "$withval" && test -x "$withval";
-               then
-                       with_xmms_config="$withval"
-               else if test -x "$withval/bin/xmms-config"
-               then
-                       with_xmms_config="$withval/bin/xmms-config"
-               fi; fi
-               with_libxmms="yes"
-       else if test "x$withval" = "xno"
-       then
-               with_libxmms="no"
-       else
-               with_libxmms="yes"
-       fi; fi
-],
-[
-       with_libxmms="yes"
-])
-if test "x$with_libxmms" = "xyes"
-then
-       with_xmms_cflags=`$with_xmms_config --cflags 2>/dev/null`
-       xmms_config_status=$?
-
-       if test $xmms_config_status -ne 0
-       then
-               with_libxmms="no"
-       fi
-fi
-if test "x$with_libxmms" = "xyes"
-then
-       with_xmms_libs=`$with_xmms_config --libs 2>/dev/null`
-       xmms_config_status=$?
-
-       if test $xmms_config_status -ne 0
-       then
-               with_libxmms="no"
-       fi
-fi
-if test "x$with_libxmms" = "xyes"
-then
-       AC_CHECK_LIB(xmms, xmms_remote_get_info,
-       [
-               BUILD_WITH_LIBXMMS_CFLAGS="$with_xmms_cflags"
-               BUILD_WITH_LIBXMMS_LIBS="$with_xmms_libs"
-               AC_SUBST(BUILD_WITH_LIBXMMS_CFLAGS)
-               AC_SUBST(BUILD_WITH_LIBXMMS_LIBS)
-       ],
-       [
-               with_libxmms="no"
-       ],
-       [$with_xmms_libs])
-fi
-with_libxmms_numeric=0
-if test "x$with_libxmms" = "xyes"
-then
-       with_libxmms_numeric=1
-fi
-AC_DEFINE_UNQUOTED(HAVE_LIBXMMS, [$with_libxmms_numeric], [Define to 1 if you have the 'xmms' library (-lxmms).])
-AM_CONDITIONAL(BUILD_WITH_LIBXMMS, test "x$with_libxmms" = "xyes")
-# }}}
-
-# --with-libyajl {{{
-with_libyajl_cppflags=""
-with_libyajl_ldflags=""
-AC_ARG_WITH(libyajl, [AS_HELP_STRING([--with-libyajl@<:@=PREFIX@:>@], [Path to libyajl.])],
-[
-       if test "x$withval" != "xno" && test "x$withval" != "xyes"
-       then
-               with_libyajl_cppflags="-I$withval/include"
-               with_libyajl_ldflags="-L$withval/lib"
-               with_libyajl="yes"
-       else
-               with_libyajl="$withval"
-       fi
-],
-[
-       with_libyajl="yes"
-])
-if test "x$with_libyajl" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       CPPFLAGS="$CPPFLAGS $with_libyajl_cppflags"
-
-       AC_CHECK_HEADERS(yajl/yajl_parse.h, [with_libyajl="yes"], [with_libyajl="no (yajl/yajl_parse.h not found)"])
-       AC_CHECK_HEADERS(yajl/yajl_version.h)
-
-       CPPFLAGS="$SAVE_CPPFLAGS"
-fi
-if test "x$with_libyajl" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       SAVE_LDFLAGS="$LDFLAGS"
-       CPPFLAGS="$CPPFLAGS $with_libyajl_cppflags"
-       LDFLAGS="$LDFLAGS $with_libyajl_ldflags"
-
-       AC_CHECK_LIB(yajl, yajl_alloc, [with_libyajl="yes"], [with_libyajl="no (Symbol 'yajl_alloc' not found)"])
-
-       CPPFLAGS="$SAVE_CPPFLAGS"
-       LDFLAGS="$SAVE_LDFLAGS"
-fi
-if test "x$with_libyajl" = "xyes"
-then
-       BUILD_WITH_LIBYAJL_CPPFLAGS="$with_libyajl_cppflags"
-       BUILD_WITH_LIBYAJL_LDFLAGS="$with_libyajl_ldflags"
-       BUILD_WITH_LIBYAJL_LIBS="-lyajl"
-       AC_SUBST(BUILD_WITH_LIBYAJL_CPPFLAGS)
-       AC_SUBST(BUILD_WITH_LIBYAJL_LDFLAGS)
-       AC_SUBST(BUILD_WITH_LIBYAJL_LIBS)
-       AC_DEFINE(HAVE_LIBYAJL, 1, [Define if libyajl is present and usable.])
-fi
-AM_CONDITIONAL(BUILD_WITH_LIBYAJL, test "x$with_libyajl" = "xyes")
-# }}}
-
-# --with-mic {{{
-with_mic_cflags="-I/opt/intel/mic/sysmgmt/sdk/include"
-with_mic_ldpath="-L/opt/intel/mic/sysmgmt/sdk/lib/Linux"
-with_mic_libs=""
-AC_ARG_WITH(mic,[AS_HELP_STRING([--with-mic@<:@=PREFIX@:>@], [Path to Intel MIC Access API.])],
-[
-       if test "x$withval" = "xno"
-       then
-               with_mic="no"
-       else if test "x$withval" = "xyes"
-       then
-               with_mic="yes"
-       else if test -d "$with_mic/lib"
-       then
-               AC_MSG_NOTICE([Not checking for Intel Mic: Manually configured])
-               with_mic_cflags="-I$withval/include"
-               with_mic_ldpath="-L$withval/lib/Linux"
-               with_mic_libs="-lMicAccessSDK -lscif -lpthread"
-               with_mic="yes"
-       fi; fi; fi
-],
-[with_mic="yes"])
-if test "x$with_mic" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       CPPFLAGS="$CPPFLAGS $with_mic_cflags"
-       AC_CHECK_HEADERS(MicAccessApi.h,[],[with_mic="no (MicAccessApi not found)"])
-       CPPFLAGS="$SAVE_CPPFLAGS"
-fi
-if test "x$with_mic" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       SAVE_LDFLAGS="$LDFLAGS"
-
-       CPPFLAGS="$CPPFLAGS $with_mic_cflags"
-       LDFLAGS="$LDFLAGS $with_mic_ldpath"
-
-       AC_CHECK_LIB(MicAccessSDK, MicInitAPI,
-                       [with_mic_ldpath="$with_mic_ldpath"
-                       with_mic_libs="-lMicAccessSDK -lscif -lpthread"],
-                       [with_mic="no (symbol MicInitAPI not found)"],[-lscif -lpthread])
-
-       CPPFLAGS="$SAVE_CPPFLAGS"
-       LDFLAGS="$SAVE_LDFLAGS"
-fi
-
-if test "x$with_mic" = "xyes"
-then
-       BUILD_WITH_MIC_CPPFLAGS="$with_mic_cflags"
-       BUILD_WITH_MIC_LIBPATH="$with_mic_ldpath"
-       BUILD_WITH_MIC_LDADD="$with_mic_libs"
-       AC_SUBST(BUILD_WITH_MIC_CPPFLAGS)
-       AC_SUBST(BUILD_WITH_MIC_LIBPATH)
-       AC_SUBST(BUILD_WITH_MIC_LDADD)
-fi
-#}}}
-
-# --with-libvarnish {{{
-with_libvarnish_cppflags=""
-with_libvarnish_cflags=""
-with_libvarnish_libs=""
-AC_ARG_WITH(libvarnish, [AS_HELP_STRING([--with-libvarnish@<:@=PREFIX@:>@], [Path to libvarnish.])],
-[
-       if test "x$withval" = "xno"
-       then
-               with_libvarnish="no"
-       else if test "x$withval" = "xyes"
-       then
-               with_libvarnish="use_pkgconfig"
-       else if test -d "$with_libvarnish/lib"
-       then
-               AC_MSG_NOTICE([Not checking for libvarnish: Manually configured])
-               with_libvarnish_cflags="-I$withval/include"
-               with_libvarnish_libs="-L$withval/lib -lvarnishapi"
-               with_libvarnish="yes"
-       fi; fi; fi
-],
-[with_libvarnish="use_pkgconfig"])
-
-# configure using pkg-config
-if test "x$with_libvarnish" = "xuse_pkgconfig"
-then
-       if test "x$PKG_CONFIG" = "x"
-       then
-               with_libvarnish="no (Don't have pkg-config)"
-       fi
-fi
-if test "x$with_libvarnish" = "xuse_pkgconfig"
-then
-       AC_MSG_NOTICE([Checking for varnishapi using $PKG_CONFIG])
-       $PKG_CONFIG --exists 'varnishapi' 2>/dev/null
-       if test $? -ne 0
-       then
-               with_libvarnish="no (pkg-config doesn't know varnishapi)"
-       fi
-fi
-if test "x$with_libvarnish" = "xuse_pkgconfig"
-then
-       with_libvarnish_cflags="`$PKG_CONFIG --cflags 'varnishapi'`"
-       if test $? -ne 0
-       then
-               with_libvarnish="no ($PKG_CONFIG failed)"
-       fi
-       with_libvarnish_libs="`$PKG_CONFIG --libs 'varnishapi'`"
-       if test $? -ne 0
-       then
-               with_libvarnish="no ($PKG_CONFIG failed)"
-       fi
-fi
-if test "x$with_libvarnish" = "xuse_pkgconfig"
-then
-       with_libvarnish="yes"
-fi
-
-# with_libvarnish_cflags and with_libvarnish_libs are set up now, let's do
-# the actual checks.
-if test "x$with_libvarnish" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       CPPFLAGS="$CPPFLAGS $with_libvarnish_cflags"
-       AC_CHECK_HEADERS(varnish/varnishapi.h, [], [with_libvarnish="no (varnish/varnishapi.h not found)"])
-
-       CPPFLAGS="$SAVE_CPPFLAGS"
-fi
-if test "x$with_libvarnish" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       #SAVE_LDFLAGS="$LDFLAGS"
-
-       CPPFLAGS="$CPPFLAGS $with_libvarnish_cflags"
-       #LDFLAGS="$LDFLAGS $with_libvarnish_libs"
-
-    AC_CHECK_HEADERS(varnish/vsc.h,
-        [AC_DEFINE([HAVE_VARNISH_V3], [1], [Varnish 3 API support])],
-        [AC_DEFINE([HAVE_VARNISH_V2], [1], [Varnish 2 API support])])
-
-       CPPFLAGS="$SAVE_CPPFLAGS"
-       #LDFLAGS="$SAVE_LDFLAGS"
-fi
-if test "x$with_libvarnish" = "xyes"
-then
-       BUILD_WITH_LIBVARNISH_CFLAGS="$with_libvarnish_cflags"
-       BUILD_WITH_LIBVARNISH_LIBS="$with_libvarnish_libs"
-       AC_SUBST(BUILD_WITH_LIBVARNISH_CFLAGS)
-       AC_SUBST(BUILD_WITH_LIBVARNISH_LIBS)
-fi
-# }}}
-
-# pkg-config --exists 'libxml-2.0'; pkg-config --exists libvirt {{{
-with_libxml2="no (pkg-config isn't available)"
-with_libxml2_cflags=""
-with_libxml2_ldflags=""
-with_libvirt="no (pkg-config isn't available)"
-with_libvirt_cflags=""
-with_libvirt_ldflags=""
-if test "x$PKG_CONFIG" != "x"
-then
-       pkg-config --exists 'libxml-2.0' 2>/dev/null
-       if test "$?" = "0"
-       then
-               with_libxml2="yes"
-       else
-               with_libxml2="no (pkg-config doesn't know libxml-2.0)"
-       fi
-
-       pkg-config --exists libvirt 2>/dev/null
-       if test "$?" = "0"
-       then
-               with_libvirt="yes"
-       else
-               with_libvirt="no (pkg-config doesn't know libvirt)"
-       fi
-fi
-if test "x$with_libxml2" = "xyes"
-then
-       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`"
-       if test $? -ne 0
-       then
-               with_libxml2="no"
-       fi
-fi
-if test "x$with_libxml2" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       CPPFLAGS="$CPPFLAGS $with_libxml2_cflags"
-
-       AC_CHECK_HEADERS(libxml/parser.h, [],
-                     [with_libxml2="no (libxml/parser.h not found)"])
-
-       CPPFLAGS="$SAVE_CPPFLAGS"
-fi
-if test "x$with_libxml2" = "xyes"
-then
-       SAVE_CFLAGS="$CFLAGS"
-       SAVE_LDFLAGS="$LDFLAGS"
-
-       CFLAGS="$CFLAGS $with_libxml2_cflags"
-       LDFLAGS="$LDFLAGS $with_libxml2_ldflags"
-
-       AC_CHECK_LIB(xml2, xmlXPathEval,
-                    [with_libxml2="yes"],
-                    [with_libxml2="no (symbol xmlXPathEval not found)"])
-
-       CFLAGS="$SAVE_CFLAGS"
-       LDFLAGS="$SAVE_LDFLAGS"
-fi
-dnl Add the right compiler flags and libraries.
-if test "x$with_libxml2" = "xyes"; then
-       BUILD_WITH_LIBXML2_CFLAGS="$with_libxml2_cflags"
-       BUILD_WITH_LIBXML2_LIBS="$with_libxml2_ldflags"
-       AC_SUBST(BUILD_WITH_LIBXML2_CFLAGS)
-       AC_SUBST(BUILD_WITH_LIBXML2_LIBS)
-fi
-if test "x$with_libvirt" = "xyes"
-then
-       with_libvirt_cflags="`pkg-config --cflags libvirt`"
-       if test $? -ne 0
-       then
-               with_libvirt="no"
-       fi
-       with_libvirt_ldflags="`pkg-config --libs libvirt`"
-       if test $? -ne 0
-       then
-               with_libvirt="no"
-       fi
-fi
-if test "x$with_libvirt" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       CPPFLAGS="$CPPFLAGS $with_libvirt_cflags"
-
-       AC_CHECK_HEADERS(libvirt/libvirt.h, [],
-                     [with_libvirt="no (libvirt/libvirt.h not found)"])
-
-       CPPFLAGS="$SAVE_CPPFLAGS"
-fi
-if test "x$with_libvirt" = "xyes"
-then
-       SAVE_CFLAGS="$CFLAGS"
-       SAVE_LDFLAGS="$LDFLAGS"
-
-       CFLAGS="$CFLAGS $with_libvirt_cflags"
-       LDFLAGS="$LDFLAGS $with_libvirt_ldflags"
-
-       AC_CHECK_LIB(virt, virDomainBlockStats,
-                    [with_libvirt="yes"],
-                    [with_libvirt="no (symbol virDomainBlockStats not found)"])
-
-       CFLAGS="$SAVE_CFLAGS"
-       LDFLAGS="$SAVE_LDFLAGS"
-fi
-dnl Add the right compiler flags and libraries.
-if test "x$with_libvirt" = "xyes"; then
-       BUILD_WITH_LIBVIRT_CFLAGS="$with_libvirt_cflags"
-       BUILD_WITH_LIBVIRT_LIBS="$with_libvirt_ldflags"
-       AC_SUBST(BUILD_WITH_LIBVIRT_CFLAGS)
-       AC_SUBST(BUILD_WITH_LIBVIRT_LIBS)
-fi
-# }}}
-
-# $PKG_CONFIG --exists OpenIPMIpthread {{{
-with_libopenipmipthread="yes"
-with_libopenipmipthread_cflags=""
-with_libopenipmipthread_libs=""
-
-AC_MSG_CHECKING([for pkg-config])
-temp_result="no"
-if test "x$PKG_CONFIG" = "x"
-then
-       with_libopenipmipthread="no"
-       temp_result="no"
-else
-       temp_result="$PKG_CONFIG"
-fi
-AC_MSG_RESULT([$temp_result])
-
-if test "x$with_libopenipmipthread" = "xyes"
-then
-       AC_MSG_CHECKING([for libOpenIPMIpthread])
-       $PKG_CONFIG --exists OpenIPMIpthread 2>/dev/null
-       if test "$?" != "0"
-       then
-               with_libopenipmipthread="no (pkg-config doesn't know OpenIPMIpthread)"
-       fi
-       AC_MSG_RESULT([$with_libopenipmipthread])
-fi
-
-if test "x$with_libopenipmipthread" = "xyes"
-then
-       AC_MSG_CHECKING([for libOpenIPMIpthread CFLAGS])
-       temp_result="`$PKG_CONFIG --cflags OpenIPMIpthread`"
-       if test "$?" = "0"
-       then
-               with_libopenipmipthread_cflags="$temp_result"
-       else
-               with_libopenipmipthread="no ($PKG_CONFIG --cflags OpenIPMIpthread failed)"
-               temp_result="$PKG_CONFIG --cflags OpenIPMIpthread failed"
-       fi
-       AC_MSG_RESULT([$temp_result])
-fi
-
-if test "x$with_libopenipmipthread" = "xyes"
-then
-       AC_MSG_CHECKING([for libOpenIPMIpthread LDFLAGS])
-       temp_result="`$PKG_CONFIG --libs OpenIPMIpthread`"
-       if test "$?" = "0"
-       then
-               with_libopenipmipthread_ldflags="$temp_result"
-       else
-               with_libopenipmipthread="no ($PKG_CONFIG --libs OpenIPMIpthread failed)"
-               temp_result="$PKG_CONFIG --libs OpenIPMIpthread failed"
-       fi
-       AC_MSG_RESULT([$temp_result])
-fi
-
-if test "x$with_libopenipmipthread" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       CPPFLAGS="$CPPFLAGS $with_libopenipmipthread_cflags"
-
-       AC_CHECK_HEADERS(OpenIPMI/ipmi_smi.h,
-                        [with_libopenipmipthread="yes"],
-                        [with_libopenipmipthread="no (OpenIPMI/ipmi_smi.h not found)"],
-[#include <OpenIPMI/ipmiif.h>
-#include <OpenIPMI/ipmi_err.h>
-#include <OpenIPMI/ipmi_posix.h>
-#include <OpenIPMI/ipmi_conn.h>
-])
-
-       CPPFLAGS="$SAVE_CPPFLAGS"
-fi
-
-if test "x$with_libopenipmipthread" = "xyes"
-then
-       BUILD_WITH_OPENIPMI_CFLAGS="$with_libopenipmipthread_cflags"
-       BUILD_WITH_OPENIPMI_LIBS="$with_libopenipmipthread_ldflags"
-       AC_SUBST(BUILD_WITH_OPENIPMI_CFLAGS)
-       AC_SUBST(BUILD_WITH_OPENIPMI_LIBS)
-fi
-# }}}
-
-PKG_CHECK_MODULES([LIBNOTIFY], [libnotify],
-               [with_libnotify="yes"],
-               [if test "x$LIBNOTIFY_PKG_ERRORS" = "x"; then
-                        with_libnotify="no"
-                else
-                        with_libnotify="no ($LIBNOTIFY_PKG_ERRORS)"
-                fi])
-
-# Check for enabled/disabled features
-#
-
-# AC_COLLECTD(name, enable/disable, info-text, feature/module)
-# ------------------------------------------------------------
-dnl
-m4_define([my_toupper], [m4_translit([$1], m4_defn([m4_cr_letters]), m4_defn([m4_cr_LETTERS]))])
-dnl
-AC_DEFUN(
-       [AC_COLLECTD],
-       [
-       m4_if([$1], [], [AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 1st argument must not be empty])])dnl
-       m4_if(
-               [$2],
-               [enable],
-               [dnl
-               m4_define([EnDis],[disabled])dnl
-               m4_define([YesNo],[no])dnl
-               ],dnl
-               [m4_if(
-                       [$2],
-                       [disable],
-                       [dnl
-                       m4_define([EnDis],[enabled])dnl
-                       m4_define([YesNo],[yes])dnl
-                       ],
-                       [dnl
-                       AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 2nd argument must be either enable or disable])dnl
-                       ]dnl
-               )]dnl
-       )dnl
-       m4_if([$3], [feature], [],
-               [m4_if(
-                       [$3], [module], [],
-                       [dnl
-                       AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 3rd argument must be either feature or disable])dnl
-                       ]dnl
-               )]dnl
-       )dnl
-       AC_ARG_ENABLE(
-               [$1],
-               AS_HELP_STRING([--$2-$1], [$2 $4 (EnDis by def)]),
-               [],
-               enable_$1='[YesNo]'dnl
-       )# AC_ARG_ENABLE
-if test "x$enable_$1" = "xno"
-then
-       collectd_$1=0
-else
-       if test "x$enable_$1" = "xyes"
-       then
-               collectd_$1=1
-       else
-               AC_MSG_NOTICE([please specify either --enable-$1 or --disable-$1; enabling $1.])
-               collectd_$1=1
-               enable_$1='yes'
-       fi
-fi
-       AC_DEFINE_UNQUOTED([COLLECT_]my_toupper([$1]), [$collectd_$1], [wether or not to enable $3 $4])
-       AM_CONDITIONAL([BUILD_]my_toupper([$3])[_]my_toupper([$1]), [test "x$enable_$1" = "xyes"])dnl
-       ]dnl
-)# AC_COLLECTD(name, enable/disable, info-text, feature/module)
-
-# AC_PLUGIN(name, default, info)
-# ------------------------------------------------------------
-dnl
-AC_DEFUN(
-  [AC_PLUGIN],
-  [
-    enable_plugin="no"
-    force="no"
-    AC_ARG_ENABLE([$1], AC_HELP_STRING([--enable-$1], [$3]),
-    [
-     if test "x$enableval" = "xyes"
-     then
-            enable_plugin="yes"
-     else if test "x$enableval" = "xforce"
-     then
-            enable_plugin="yes"
-            force="yes"
-     else
-            enable_plugin="no (disabled on command line)"
-     fi; fi
-    ],
-    [
-        if test "x$enable_all_plugins" = "xauto"
-        then
-            if test "x$2" = "xyes"
-            then
-                    enable_plugin="yes"
-            else
-                    enable_plugin="no"
-            fi
-        else
-            enable_plugin="$enable_all_plugins"
-        fi
-    ])
-    if test "x$enable_plugin" = "xyes"
-    then
-           if test "x$2" = "xyes" || test "x$force" = "xyes"
-           then
-                   AC_DEFINE([HAVE_PLUGIN_]my_toupper([$1]), 1, [Define to 1 if the $1 plugin is enabled.])
-                   if test "x$2" != "xyes"
-                   then
-                           dependency_warning="yes"
-                   fi
-           else # User passed "yes" but dependency checking yielded "no" => Dependency problem.
-                   dependency_error="yes"
-                   enable_plugin="no (dependency error)"
-           fi
-    fi
-    AM_CONDITIONAL([BUILD_PLUGIN_]my_toupper([$1]), test "x$enable_plugin" = "xyes")
-    enable_$1="$enable_plugin"
-  ]
-)# AC_PLUGIN(name, default, info)
-
-m4_divert_once([HELP_ENABLE], [
-collectd features:])
-# FIXME: Remove these calls to `AC_COLLECTD' and then remove that macro.
-AC_COLLECTD([debug],     [enable],  [feature], [debugging])
-AC_COLLECTD([daemon],    [disable], [feature], [daemon mode])
-AC_COLLECTD([getifaddrs],[enable],  [feature], [getifaddrs under Linux])
-
-dependency_warning="no"
-dependency_error="no"
-
-plugin_ascent="no"
-plugin_battery="no"
-plugin_bind="no"
-plugin_cgroups="no"
-plugin_conntrack="no"
-plugin_contextswitch="no"
-plugin_cpu="no"
-plugin_cpufreq="no"
-plugin_curl_json="no"
-plugin_curl_xml="no"
-plugin_df="no"
-plugin_disk="no"
-plugin_entropy="no"
-plugin_ethstat="no"
-plugin_fscache="no"
-plugin_interface="no"
-plugin_ipmi="no"
-plugin_ipvs="no"
-plugin_irq="no"
-plugin_libvirt="no"
-plugin_load="no"
-plugin_memory="no"
-plugin_multimeter="no"
-plugin_nfs="no"
-plugin_numa="no"
-plugin_perl="no"
-plugin_processes="no"
-plugin_protocols="no"
-plugin_serial="no"
-plugin_swap="no"
-plugin_tape="no"
-plugin_tcpconns="no"
-plugin_ted="no"
-plugin_thermal="no"
-plugin_users="no"
-plugin_uptime="no"
-plugin_vmem="no"
-plugin_vserver="no"
-plugin_wireless="no"
-plugin_zfs_arc="no"
-
-# Linux
-if test "x$ac_system" = "xLinux"
-then
-       plugin_battery="yes"
-       plugin_conntrack="yes"
-       plugin_contextswitch="yes"
-       plugin_cgroups="yes"
-       plugin_cpu="yes"
-       plugin_cpufreq="yes"
-       plugin_disk="yes"
-       plugin_entropy="yes"
-       plugin_fscache="yes"
-       plugin_interface="yes"
-       plugin_irq="yes"
-       plugin_load="yes"
-       plugin_lvm="yes"
-       plugin_memory="yes"
-       plugin_nfs="yes"
-       plugin_numa="yes"
-       plugin_processes="yes"
-       plugin_protocols="yes"
-       plugin_serial="yes"
-       plugin_swap="yes"
-       plugin_tcpconns="yes"
-       plugin_thermal="yes"
-       plugin_uptime="yes"
-       plugin_vmem="yes"
-       plugin_vserver="yes"
-       plugin_wireless="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
-               plugin_ipvs="yes"
-       fi
-fi
-
-if test "x$ac_system" = "xOpenBSD"
-then
-       plugin_tcpconns="yes"
-fi
-
-# Mac OS X devices
-if test "x$with_libiokit" = "xyes"
-then
-       plugin_battery="yes"
-       plugin_disk="yes"
-fi
-
-# AIX
-
-if test "x$ac_system" = "xAIX"
-then
-        plugin_tcpconns="yes"
-fi
-
-# FreeBSD
-
-if test "x$ac_system" = "xFreeBSD"
-then
-        plugin_zfs_arc="yes"
-fi
-
-
-if test "x$with_perfstat" = "xyes"
-then
-       plugin_cpu="yes"
-       plugin_contextswitch="yes"
-       plugin_disk="yes"
-       plugin_memory="yes"
-       plugin_swap="yes"
-       plugin_interface="yes"
-       plugin_load="yes"
-       plugin_uptime="yes"
-fi
-
-if test "x$with_procinfo" = "xyes"
-then
-       plugin_processes="yes"
-fi
-
-# Solaris
-if test "x$with_kstat" = "xyes"
-then
-       plugin_nfs="yes"
-       plugin_uptime="yes"
-       plugin_zfs_arc="yes"
-fi
-
-if test "x$with_devinfo$with_kstat" = "xyesyes"
-then
-       plugin_cpu="yes"
-       plugin_disk="yes"
-       plugin_interface="yes"
-       plugin_memory="yes"
-       plugin_tape="yes"
-fi
-
-# libstatgrab
-if test "x$with_libstatgrab" = "xyes"
-then
-       plugin_cpu="yes"
-       plugin_disk="yes"
-       plugin_interface="yes"
-       plugin_load="yes"
-       plugin_memory="yes"
-       plugin_swap="yes"
-       plugin_users="yes"
-fi
-
-if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes"
-then
-       plugin_ascent="yes"
-       if test "x$have_strptime" = "xyes"
-       then
-               plugin_bind="yes"
-       fi
-fi
-
-if test "x$with_libopenipmipthread" = "xyes"
-then
-       plugin_ipmi="yes"
-fi
-
-if test "x$with_libcurl" = "xyes" && test "x$with_libyajl" = "xyes"
-then
-       plugin_curl_json="yes"
-fi
-
-if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes"
-then
-       plugin_curl_xml="yes"
-fi
-
-if test "x$have_processor_info" = "xyes"
-then
-       plugin_cpu="yes"
-fi
-if test "x$have_sysctl" = "xyes"
-then
-       plugin_cpu="yes"
-       plugin_memory="yes"
-       plugin_uptime="yes"
-       if test "x$ac_system" = "xDarwin"
-       then
-               plugin_swap="yes"
-       fi
-fi
-if test "x$have_sysctlbyname" = "xyes"
-then
-       plugin_contextswitch="yes"
-       plugin_cpu="yes"
-       plugin_memory="yes"
-       plugin_tcpconns="yes"
-fi
-
-# Df plugin: Check if we know how to determine mount points first.
-#if test "x$have_listmntent" = "xyes"; then
-#      plugin_df="yes"
-#fi
-if test "x$have_getvfsstat" = "xyes" || test "x$have_getfsstat" = "xyes"
-then
-       plugin_df="yes"
-fi
-if test "x$c_cv_have_two_getmntent" = "xyes" || test "x$have_getmntent" = "xgen" || test "x$have_getmntent" = "xsun"
-then
-       plugin_df="yes"
-fi
-#if test "x$have_getmntent" = "xseq"
-#then
-#      plugin_df="yes"
-#fi
-if test "x$c_cv_have_one_getmntent" = "xyes"
-then
-       plugin_df="yes"
-fi
-
-# Df plugin: Check if we have either `statfs' or `statvfs' second.
-if test "x$plugin_df" = "xyes"
-then
-       plugin_df="no"
-       if test "x$have_statfs" = "xyes"
-       then
-               plugin_df="yes"
-       fi
-       if test "x$have_statvfs" = "xyes"
-       then
-               plugin_df="yes"
-       fi
-fi
-
-if test "x$have_linux_sockios_h$have_linux_ethtool_h" = "xyesyes"
-then
-       plugin_ethstat="yes"
-fi
-
-if test "x$have_getifaddrs" = "xyes"
-then
-       plugin_interface="yes"
-fi
-
-if test "x$with_libxml2" = "xyes" && test "x$with_libvirt" = "xyes"
-then
-       plugin_libvirt="yes"
-fi
-
-if test "x$have_getloadavg" = "xyes"
-then
-       plugin_load="yes"
-fi
-
-if test "x$c_cv_have_libperl$c_cv_have_perl_ithreads" = "xyesyes"
-then
-       plugin_perl="yes"
-fi
-
-# Mac OS X memory interface
-if test "x$have_host_statistics" = "xyes"
-then
-       plugin_memory="yes"
-fi
-
-if test "x$have_termios_h" = "xyes"
-then
-       plugin_multimeter="yes"
-       plugin_ted="yes"
-fi
-
-if test "x$have_thread_info" = "xyes"
-then
-       plugin_processes="yes"
-fi
-
-if test "x$with_kvm_getprocs" = "xyes" && test "x$have_struct_kinfo_proc_freebsd" = "xyes"
-then
-       plugin_processes="yes"
-fi
-
-if test "x$with_kvm_getswapinfo" = "xyes"
-then
-       plugin_swap="yes"
-fi
-
-if test "x$have_swapctl" = "xyes" && test "x$c_cv_have_swapctl_two_args" = "xyes"
-then
-       plugin_swap="yes"
-fi
-
-if test "x$with_kvm_openfiles$with_kvm_nlist" = "xyesyes"
-then
-       plugin_tcpconns="yes"
-fi
-
-if test "x$have_getutent" = "xyes"
-then
-       plugin_users="yes"
-fi
-if test "x$have_getutxent" = "xyes"
-then
-       plugin_users="yes"
-fi
-
-m4_divert_once([HELP_ENABLE], [
-collectd plugins:])
-
-AC_ARG_ENABLE([all-plugins],
-               AC_HELP_STRING([--enable-all-plugins],
-                               [enable all plugins (auto by def)]),
-               [
-                if test "x$enableval" = "xyes"
-                then
-                        enable_all_plugins="yes"
-                else if test "x$enableval" = "xauto"
-                then
-                        enable_all_plugins="auto"
-                else
-                        enable_all_plugins="no"
-                fi; fi
-               ],
-               [enable_all_plugins="auto"])
-
-m4_divert_once([HELP_ENABLE], [])
-
-AC_PLUGIN([aggregation], [yes],                [Aggregation plugin])
-AC_PLUGIN([amqp],        [$with_librabbitmq],  [AMQP output plugin])
-AC_PLUGIN([apache],      [$with_libcurl],      [Apache httpd statistics])
-AC_PLUGIN([apcups],      [yes],                [Statistics of UPSes by APC])
-AC_PLUGIN([apple_sensors], [$with_libiokit],   [Apple's hardware sensors])
-AC_PLUGIN([aquaero],     [$with_libaquaero5],  [Aquaero's hardware sensors])
-AC_PLUGIN([ascent],      [$plugin_ascent],     [AscentEmu player statistics])
-AC_PLUGIN([battery],     [$plugin_battery],    [Battery statistics])
-AC_PLUGIN([bind],        [$plugin_bind],       [ISC Bind nameserver statistics])
-AC_PLUGIN([conntrack],   [$plugin_conntrack],  [nf_conntrack statistics])
-AC_PLUGIN([contextswitch], [$plugin_contextswitch], [context switch statistics])
-AC_PLUGIN([cpufreq],     [$plugin_cpufreq],    [CPU frequency statistics])
-AC_PLUGIN([cpu],         [$plugin_cpu],        [CPU usage statistics])
-AC_PLUGIN([csv],         [yes],                [CSV output plugin])
-AC_PLUGIN([curl],        [$with_libcurl],      [CURL generic web statistics])
-AC_PLUGIN([curl_json],   [$plugin_curl_json],    [CouchDB statistics])
-AC_PLUGIN([curl_xml],   [$plugin_curl_xml],    [CURL generic xml statistics])
-AC_PLUGIN([cgroups],     [$plugin_cgroups],    [CGroups CPU usage accounting])
-AC_PLUGIN([dbi],         [$with_libdbi],       [General database statistics])
-AC_PLUGIN([df],          [$plugin_df],         [Filesystem usage statistics])
-AC_PLUGIN([disk],        [$plugin_disk],       [Disk usage statistics])
-AC_PLUGIN([dns],         [$with_libpcap],      [DNS traffic analysis])
-AC_PLUGIN([email],       [yes],                [EMail statistics])
-AC_PLUGIN([entropy],     [$plugin_entropy],    [Entropy statistics])
-AC_PLUGIN([ethstat],     [$plugin_ethstat],    [Stats from NIC driver])
-AC_PLUGIN([exec],        [yes],                [Execution of external programs])
-AC_PLUGIN([filecount],   [yes],                [Count files in directories])
-AC_PLUGIN([fscache],     [$plugin_fscache],    [fscache statistics])
-AC_PLUGIN([gmond],       [$with_libganglia],   [Ganglia plugin])
-AC_PLUGIN([hddtemp],     [yes],                [Query hddtempd])
-AC_PLUGIN([interface],   [$plugin_interface],  [Interface traffic statistics])
-AC_PLUGIN([ipmi],        [$plugin_ipmi],       [IPMI sensor statistics])
-AC_PLUGIN([iptables],    [$with_libiptc],      [IPTables rule counters])
-AC_PLUGIN([ipvs],        [$plugin_ipvs],       [IPVS connection statistics])
-AC_PLUGIN([irq],         [$plugin_irq],        [IRQ statistics])
-AC_PLUGIN([java],        [$with_java],         [Embed the Java Virtual Machine])
-AC_PLUGIN([libvirt],     [$plugin_libvirt],    [Virtual machine statistics])
-AC_PLUGIN([load],        [$plugin_load],       [System load])
-AC_PLUGIN([logfile],     [yes],                [File logging plugin])
-AC_PLUGIN([lpar],        [$with_perfstat],     [AIX logical partitions statistics])
-AC_PLUGIN([lvm],         [$with_liblvm2app],   [LVM statistics])
-AC_PLUGIN([madwifi],     [$have_linux_wireless_h], [Madwifi wireless statistics])
-AC_PLUGIN([match_empty_counter], [yes],        [The empty counter match])
-AC_PLUGIN([match_hashed], [yes],               [The hashed match])
-AC_PLUGIN([match_regex], [yes],                [The regex match])
-AC_PLUGIN([match_timediff], [yes],             [The timediff match])
-AC_PLUGIN([match_value], [yes],                [The value match])
-AC_PLUGIN([mbmon],       [yes],                [Query mbmond])
-AC_PLUGIN([md],          [$have_linux_raid_md_u_h], [md (Linux software RAID) devices])
-AC_PLUGIN([memcachec],   [$with_libmemcached], [memcachec statistics])
-AC_PLUGIN([memcached],   [yes],                [memcached statistics])
-AC_PLUGIN([memory],      [$plugin_memory],     [Memory usage])
-AC_PLUGIN([mic],         [$with_mic],          [Intel Many Integrated Core stats])
-AC_PLUGIN([modbus],      [$with_libmodbus],    [Modbus plugin])
-AC_PLUGIN([multimeter],  [$plugin_multimeter], [Read multimeter values])
-AC_PLUGIN([mysql],       [$with_libmysql],     [MySQL statistics])
-AC_PLUGIN([netapp],      [$with_libnetapp],    [NetApp plugin])
-AC_PLUGIN([netlink],     [$with_libmnl],       [Enhanced Linux network statistics])
-AC_PLUGIN([network],     [yes],                [Network communication plugin])
-AC_PLUGIN([nfs],         [$plugin_nfs],        [NFS statistics])
-AC_PLUGIN([nginx],       [$with_libcurl],      [nginx statistics])
-AC_PLUGIN([notify_desktop], [$with_libnotify], [Desktop notifications])
-AC_PLUGIN([notify_email], [$with_libesmtp],    [Email notifier])
-AC_PLUGIN([ntpd],        [yes],                [NTPd statistics])
-AC_PLUGIN([numa],        [$plugin_numa],       [NUMA virtual memory statistics])
-AC_PLUGIN([nut],         [$with_libupsclient], [Network UPS tools statistics])
-AC_PLUGIN([olsrd],       [yes],                [olsrd statistics])
-AC_PLUGIN([onewire],     [$with_libowcapi],    [OneWire sensor statistics])
-AC_PLUGIN([openvpn],     [yes],                [OpenVPN client statistics])
-AC_PLUGIN([oracle],      [$with_oracle],       [Oracle plugin])
-AC_PLUGIN([perl],        [$plugin_perl],       [Embed a Perl interpreter])
-AC_PLUGIN([pf],          [$have_net_pfvar_h],  [BSD packet filter (PF) statistics])
-# FIXME: Check for libevent, too.
-AC_PLUGIN([pinba],       [$have_protoc_c],     [Pinba statistics])
-AC_PLUGIN([ping],        [$with_liboping],     [Network latency statistics])
-AC_PLUGIN([postgresql],  [$with_libpq],        [PostgreSQL database statistics])
-AC_PLUGIN([powerdns],    [yes],                [PowerDNS statistics])
-AC_PLUGIN([processes],   [$plugin_processes],  [Process statistics])
-AC_PLUGIN([protocols],   [$plugin_protocols],  [Protocol (IP, TCP, ...) statistics])
-AC_PLUGIN([python],      [$with_python],       [Embed a Python interpreter])
-AC_PLUGIN([redis],       [$with_libcredis],    [Redis plugin])
-AC_PLUGIN([routeros],    [$with_librouteros],  [RouterOS plugin])
-AC_PLUGIN([rrdcached],   [$librrd_rrdc_update], [RRDTool output plugin])
-AC_PLUGIN([rrdtool],     [$with_librrd],       [RRDTool output plugin])
-AC_PLUGIN([sensors],     [$with_libsensors],   [lm_sensors statistics])
-AC_PLUGIN([serial],      [$plugin_serial],     [serial port traffic])
-AC_PLUGIN([sigrok],      [$with_libsigrok],    [sigrok acquisition sources])
-AC_PLUGIN([snmp],        [$with_libnetsnmp],   [SNMP querying plugin])
-AC_PLUGIN([statsd],      [yes],                [StatsD plugin])
-AC_PLUGIN([swap],        [$plugin_swap],       [Swap usage statistics])
-AC_PLUGIN([syslog],      [$have_syslog],       [Syslog logging plugin])
-AC_PLUGIN([table],       [yes],                [Parsing of tabular data])
-AC_PLUGIN([tail],        [yes],                [Parsing of logfiles])
-AC_PLUGIN([tail_csv],    [yes],                [Parsing of CSV files])
-AC_PLUGIN([tape],        [$plugin_tape],       [Tape drive statistics])
-AC_PLUGIN([target_notification], [yes],        [The notification target])
-AC_PLUGIN([target_replace], [yes],             [The replace target])
-AC_PLUGIN([target_scale],[yes],                [The scale target])
-AC_PLUGIN([target_set],  [yes],                [The set target])
-AC_PLUGIN([target_v5upgrade], [yes],           [The v5upgrade target])
-AC_PLUGIN([tcpconns],    [$plugin_tcpconns],   [TCP connection statistics])
-AC_PLUGIN([teamspeak2],  [yes],                [TeamSpeak2 server statistics])
-AC_PLUGIN([ted],         [$plugin_ted],        [Read The Energy Detective values])
-AC_PLUGIN([thermal],     [$plugin_thermal],    [Linux ACPI thermal zone statistics])
-AC_PLUGIN([threshold],   [yes],                [Threshold checking plugin])
-AC_PLUGIN([tokyotyrant], [$with_libtokyotyrant],  [TokyoTyrant database statistics])
-AC_PLUGIN([unixsock],    [yes],                [Unixsock communication plugin])
-AC_PLUGIN([uptime],      [$plugin_uptime],     [Uptime statistics])
-AC_PLUGIN([users],       [$plugin_users],      [User statistics])
-AC_PLUGIN([uuid],        [yes],                [UUID as hostname plugin])
-AC_PLUGIN([varnish],     [$with_libvarnish],   [Varnish cache statistics])
-AC_PLUGIN([vmem],        [$plugin_vmem],       [Virtual memory statistics])
-AC_PLUGIN([vserver],     [$plugin_vserver],    [Linux VServer statistics])
-AC_PLUGIN([wireless],    [$plugin_wireless],   [Wireless statistics])
-AC_PLUGIN([write_graphite], [yes],             [Graphite / Carbon output plugin])
-AC_PLUGIN([write_http],  [$with_libcurl],      [HTTP output plugin])
-AC_PLUGIN([write_mongodb], [$with_libmongoc],  [MongoDB output plugin])
-AC_PLUGIN([write_redis], [$with_libcredis],    [Redis output plugin])
-AC_PLUGIN([write_riemann], [$have_protoc_c],   [Riemann output plugin])
-AC_PLUGIN([xmms],        [$with_libxmms],      [XMMS statistics])
-AC_PLUGIN([zfs_arc],     [$plugin_zfs_arc],    [ZFS ARC statistics])
-
-dnl Default configuration file
-# Load either syslog or logfile
-LOAD_PLUGIN_SYSLOG=""
-LOAD_PLUGIN_LOGFILE=""
-
-AC_MSG_CHECKING([which default log plugin to load])
-default_log_plugin="none"
-if test "x$enable_syslog" = "xyes"
-then
-       default_log_plugin="syslog"
-else
-       LOAD_PLUGIN_SYSLOG="##"
-fi
-
-if test "x$enable_logfile" = "xyes"
-then
-       if test "x$default_log_plugin" = "xnone"
-       then
-               default_log_plugin="logfile"
-       else
-               LOAD_PLUGIN_LOGFILE="#"
-       fi
-else
-       LOAD_PLUGIN_LOGFILE="##"
-fi
-AC_MSG_RESULT([$default_log_plugin])
-
-AC_SUBST(LOAD_PLUGIN_SYSLOG)
-AC_SUBST(LOAD_PLUGIN_LOGFILE)
-
-DEFAULT_LOG_LEVEL="info"
-if test "x$enable_debug" = "xyes"
-then
-       DEFAULT_LOG_LEVEL="debug"
-fi
-AC_SUBST(DEFAULT_LOG_LEVEL)
-
-# Load only one of rrdtool, network, csv in the default config.
-LOAD_PLUGIN_RRDTOOL=""
-LOAD_PLUGIN_NETWORK=""
-LOAD_PLUGIN_CSV=""
-
-AC_MSG_CHECKING([which default write plugin to load])
-default_write_plugin="none"
-if test "x$enable_rrdtool" = "xyes"
-then
-       default_write_plugin="rrdtool"
-else
-       LOAD_PLUGIN_RRDTOOL="##"
-fi
-
-if test "x$enable_network" = "xyes"
-then
-       if test "x$default_write_plugin" = "xnone"
-       then
-               default_write_plugin="network"
-       else
-               LOAD_PLUGIN_NETWORK="#"
-       fi
-else
-       LOAD_PLUGIN_NETWORK="##"
-fi
-
-if test "x$enable_csv" = "xyes"
-then
-       if test "x$default_write_plugin" = "xnone"
-       then
-               default_write_plugin="csv"
-       else
-               LOAD_PLUGIN_CSV="#"
-       fi
-else
-       LOAD_PLUGIN_CSV="##"
-fi
-AC_MSG_RESULT([$default_write_plugin])
-
-AC_SUBST(LOAD_PLUGIN_RRDTOOL)
-AC_SUBST(LOAD_PLUGIN_NETWORK)
-AC_SUBST(LOAD_PLUGIN_CSV)
-
-dnl ip_vs.h
-if test "x$ac_system" = "xLinux" \
-       && 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
-PERL_BINDINGS_OPTIONS="PREFIX=${prefix}"
-AC_ARG_WITH(perl-bindings, [AS_HELP_STRING([--with-perl-bindings@<:@=OPTIONS@:>@], [Options passed to "perl Makefile.PL".])],
-[
-       if test "x$withval" != "xno" && test "x$withval" != "xyes"
-       then
-               PERL_BINDINGS_OPTIONS="$withval"
-               with_perl_bindings="yes"
-       else
-               with_perl_bindings="$withval"
-       fi
-],
-[
-       if test -n "$perl_interpreter"
-       then
-               with_perl_bindings="yes"
-       else
-               with_perl_bindings="no (no perl interpreter found)"
-       fi
-])
-if test "x$with_perl_bindings" = "xyes"
-then
-       PERL_BINDINGS="perl"
-else
-       PERL_BINDINGS=""
-fi
-AC_SUBST(PERL_BINDINGS)
-AC_SUBST(PERL_BINDINGS_OPTIONS)
-
-dnl libcollectdclient
-LCC_VERSION_MAJOR=`echo $PACKAGE_VERSION | cut -d'.' -f1`
-LCC_VERSION_MINOR=`echo $PACKAGE_VERSION | cut -d'.' -f2`
-LCC_VERSION_PATCH=`echo $PACKAGE_VERSION | cut -d'.' -f3`
-
-LCC_VERSION_EXTRA=`echo $PACKAGE_VERSION | cut -d'.' -f4-`
-
-LCC_VERSION_STRING="$LCC_VERSION_MAJOR.$LCC_VERSION_MINOR.$LCC_VERSION_PATCH"
-
-AC_SUBST(LCC_VERSION_MAJOR)
-AC_SUBST(LCC_VERSION_MINOR)
-AC_SUBST(LCC_VERSION_PATCH)
-AC_SUBST(LCC_VERSION_EXTRA)
-AC_SUBST(LCC_VERSION_STRING)
-
-AC_CONFIG_FILES(src/libcollectdclient/collectd/lcc_features.h)
-
-AC_OUTPUT(Makefile src/Makefile src/collectd.conf src/libcollectdclient/Makefile src/libcollectdclient/libcollectdclient.pc src/liboconfig/Makefile bindings/Makefile bindings/java/Makefile)
-
-if test "x$with_librrd" = "xyes" \
-       && test "x$librrd_threadsafe" != "xyes"
-then
-       with_librrd="yes (warning: librrd is not thread-safe)"
-fi
-
-if test "x$with_libperl" = "xyes"
-then
-       with_libperl="yes (version `$perl_interpreter -MConfig -e 'print $Config{version};'`)"
-else
-       enable_perl="no (needs libperl)"
-fi
-
-if test "x$enable_perl" = "xno" && test "x$c_cv_have_perl_ithreads" = "xno"
-then
-       enable_perl="no (libperl doesn't support ithreads)"
-fi
-
-if test "x$with_perl_bindings" = "xyes" \
-       && test "x$PERL_BINDINGS_OPTIONS" != "x"
-then
-       with_perl_bindings="yes ($PERL_BINDINGS_OPTIONS)"
-fi
-
-cat <<EOF;
-
-Configuration:
-  Libraries:
-    intel mic . . . . . . $with_mic
-    libaquaero5 . . . . . $with_libaquaero5
-    libcurl . . . . . . . $with_libcurl
-    libdbi  . . . . . . . $with_libdbi
-    libcredis . . . . . . $with_libcredis
-    libesmtp  . . . . . . $with_libesmtp
-    libganglia  . . . . . $with_libganglia
-    libgcrypt . . . . . . $with_libgcrypt
-    libiokit  . . . . . . $with_libiokit
-    libiptc . . . . . . . $with_libiptc
-    libjvm  . . . . . . . $with_java
-    libkstat  . . . . . . $with_kstat
-    libkvm  . . . . . . . $with_libkvm
-    libmemcached  . . . . $with_libmemcached
-    libmnl  . . . . . . . $with_libmnl
-    libmodbus . . . . . . $with_libmodbus
-    libmysql  . . . . . . $with_libmysql
-    libnetapp . . . . . . $with_libnetapp
-    libnetsnmp  . . . . . $with_libnetsnmp
-    libnotify . . . . . . $with_libnotify
-    liboconfig  . . . . . $with_liboconfig
-    libopenipmi . . . . . $with_libopenipmipthread
-    liboping  . . . . . . $with_liboping
-    libpcap . . . . . . . $with_libpcap
-    libperfstat . . . . . $with_perfstat
-    libperl . . . . . . . $with_libperl
-    libpq . . . . . . . . $with_libpq
-    libpthread  . . . . . $with_libpthread
-    librabbitmq . . . . . $with_librabbitmq
-    librouteros . . . . . $with_librouteros
-    librrd  . . . . . . . $with_librrd
-    libsensors  . . . . . $with_libsensors
-    libsigrok   . . . . . $with_libsigrok
-    libstatgrab . . . . . $with_libstatgrab
-    libtokyotyrant  . . . $with_libtokyotyrant
-    libupsclient  . . . . $with_libupsclient
-    libvarnish  . . . . . $with_libvarnish
-    libvirt . . . . . . . $with_libvirt
-    libxml2 . . . . . . . $with_libxml2
-    libxmms . . . . . . . $with_libxmms
-    libyajl . . . . . . . $with_libyajl
-    libevent  . . . . . . $with_libevent
-    protobuf-c  . . . . . $have_protoc_c
-    oracle  . . . . . . . $with_oracle
-    python  . . . . . . . $with_python
-
-  Features:
-    daemon mode . . . . . $enable_daemon
-    debug . . . . . . . . $enable_debug
-
-  Bindings:
-    perl  . . . . . . . . $with_perl_bindings
-
-  Modules:
-    aggregation . . . . . $enable_aggregation
-    amqp    . . . . . . . $enable_amqp
-    apache  . . . . . . . $enable_apache
-    apcups  . . . . . . . $enable_apcups
-    aquaero . . . . . . . $enable_aquaero
-    apple_sensors . . . . $enable_apple_sensors
-    ascent  . . . . . . . $enable_ascent
-    battery . . . . . . . $enable_battery
-    bind  . . . . . . . . $enable_bind
-    conntrack . . . . . . $enable_conntrack
-    contextswitch . . . . $enable_contextswitch
-    cgroups . . . . . . . $enable_cgroups
-    cpu . . . . . . . . . $enable_cpu
-    cpufreq . . . . . . . $enable_cpufreq
-    csv . . . . . . . . . $enable_csv
-    curl  . . . . . . . . $enable_curl
-    curl_json . . . . . . $enable_curl_json
-    curl_xml  . . . . . . $enable_curl_xml
-    dbi . . . . . . . . . $enable_dbi
-    df  . . . . . . . . . $enable_df
-    disk  . . . . . . . . $enable_disk
-    dns . . . . . . . . . $enable_dns
-    email . . . . . . . . $enable_email
-    entropy . . . . . . . $enable_entropy
-    ethstat . . . . . . . $enable_ethstat
-    exec  . . . . . . . . $enable_exec
-    filecount . . . . . . $enable_filecount
-    fscache . . . . . . . $enable_fscache
-    gmond . . . . . . . . $enable_gmond
-    hddtemp . . . . . . . $enable_hddtemp
-    interface . . . . . . $enable_interface
-    ipmi  . . . . . . . . $enable_ipmi
-    iptables  . . . . . . $enable_iptables
-    ipvs  . . . . . . . . $enable_ipvs
-    irq . . . . . . . . . $enable_irq
-    java  . . . . . . . . $enable_java
-    libvirt . . . . . . . $enable_libvirt
-    load  . . . . . . . . $enable_load
-    logfile . . . . . . . $enable_logfile
-    lpar  . . . . . . . . $enable_lpar
-    lvm . . . . . . . . . $enable_lvm
-    madwifi . . . . . . . $enable_madwifi
-    match_empty_counter . $enable_match_empty_counter
-    match_hashed  . . . . $enable_match_hashed
-    match_regex . . . . . $enable_match_regex
-    match_timediff  . . . $enable_match_timediff
-    match_value . . . . . $enable_match_value
-    mbmon . . . . . . . . $enable_mbmon
-    md  . . . . . . . . . $enable_md
-    memcachec . . . . . . $enable_memcachec
-    memcached . . . . . . $enable_memcached
-    memory  . . . . . . . $enable_memory
-    modbus  . . . . . . . $enable_modbus
-    multimeter  . . . . . $enable_multimeter
-    mysql . . . . . . . . $enable_mysql
-    netapp  . . . . . . . $enable_netapp
-    netlink . . . . . . . $enable_netlink
-    network . . . . . . . $enable_network
-    nfs . . . . . . . . . $enable_nfs
-    nginx . . . . . . . . $enable_nginx
-    notify_desktop  . . . $enable_notify_desktop
-    notify_email  . . . . $enable_notify_email
-    ntpd  . . . . . . . . $enable_ntpd
-    numa  . . . . . . . . $enable_numa
-    nut . . . . . . . . . $enable_nut
-    olsrd . . . . . . . . $enable_olsrd
-    onewire . . . . . . . $enable_onewire
-    openvpn . . . . . . . $enable_openvpn
-    oracle  . . . . . . . $enable_oracle
-    perl  . . . . . . . . $enable_perl
-    pf  . . . . . . . . . $enable_pf
-    pinba . . . . . . . . $enable_pinba
-    ping  . . . . . . . . $enable_ping
-    postgresql  . . . . . $enable_postgresql
-    powerdns  . . . . . . $enable_powerdns
-    processes . . . . . . $enable_processes
-    protocols . . . . . . $enable_protocols
-    python  . . . . . . . $enable_python
-    redis . . . . . . . . $enable_redis
-    routeros  . . . . . . $enable_routeros
-    rrdcached . . . . . . $enable_rrdcached
-    rrdtool . . . . . . . $enable_rrdtool
-    sensors . . . . . . . $enable_sensors
-    serial  . . . . . . . $enable_serial
-    sigrok  . . . . . . . $enable_sigrok
-    snmp  . . . . . . . . $enable_snmp
-    statsd  . . . . . . . $enable_statsd
-    swap  . . . . . . . . $enable_swap
-    syslog  . . . . . . . $enable_syslog
-    table . . . . . . . . $enable_table
-    tail  . . . . . . . . $enable_tail
-    tail_csv  . . . . . . $enable_tail_csv
-    tape  . . . . . . . . $enable_tape
-    target_notification . $enable_target_notification
-    target_replace  . . . $enable_target_replace
-    target_scale  . . . . $enable_target_scale
-    target_set  . . . . . $enable_target_set
-    target_v5upgrade  . . $enable_target_v5upgrade
-    tcpconns  . . . . . . $enable_tcpconns
-    teamspeak2  . . . . . $enable_teamspeak2
-    ted . . . . . . . . . $enable_ted
-    thermal . . . . . . . $enable_thermal
-    threshold . . . . . . $enable_threshold
-    tokyotyrant . . . . . $enable_tokyotyrant
-    unixsock  . . . . . . $enable_unixsock
-    uptime  . . . . . . . $enable_uptime
-    users . . . . . . . . $enable_users
-    uuid  . . . . . . . . $enable_uuid
-    varnish . . . . . . . $enable_varnish
-    vmem  . . . . . . . . $enable_vmem
-    vserver . . . . . . . $enable_vserver
-    wireless  . . . . . . $enable_wireless
-    write_graphite  . . . $enable_write_graphite
-    write_http  . . . . . $enable_write_http
-    write_mongodb . . . . $enable_write_mongodb
-    write_redis . . . . . $enable_write_redis
-    write_riemann . . . . $enable_write_riemann
-    xmms  . . . . . . . . $enable_xmms
-    zfs_arc . . . . . . . $enable_zfs_arc
-
-EOF
-
-if test "x$dependency_error" = "xyes"; then
-       AC_MSG_ERROR("Some plugins are missing dependencies - see the summary above for details")
-fi
-
-if test "x$dependency_warning" = "xyes"; then
-       AC_MSG_WARN("Some plugins seem to have missing dependencies but have been enabled forcibly - see the summary above for details")
-fi
-
-# vim: set fdm=marker :
index af64fb1..d364633 100755 (executable)
@@ -1,4 +1,25 @@
 #!/usr/bin/perl
+# Copyright (c) 2006-2010 Florian Forster <octo at collectd.org>
+# Copyright (c) 2006-2008 Sebastian Harl <sh at tokkee.org>
+# Copyright (c) 2008      Mirko Buffoni <briareos at eswat.org>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
 
 use strict;
 use warnings;
index 5d1024f..5fe4313 100644 (file)
@@ -3,7 +3,7 @@ GraphWidth 400
 #UnixSockAddr "/var/run/collectd-unixsock"
 <Type apache_bytes>
   DataSources value
-  DSName "count Bytes/s"
+  DSName "value Bytes/s"
   RRDTitle "Apache Traffic"
   RRDVerticalLabel "Bytes/s"
   RRDFormat "%5.1lf%s"
@@ -11,7 +11,7 @@ GraphWidth 400
 </Type>
 <Type apache_requests>
   DataSources value
-  DSName "count Requests/s"
+  DSName "value Requests/s"
   RRDTitle "Apache Traffic"
   RRDVerticalLabel "Requests/s"
   RRDFormat "%5.2lf"
@@ -246,14 +246,14 @@ GraphWidth 400
 </Type>
 <Type conntrack>
   DataSources value
-  DSName conntrack Conntrack count
+  DSName value Conntrack count
   RRDTitle "nf_conntrack connections on {hostname}"
   RRDVerticalLabel "Count"
   RRDFormat "%4.0lf"
 </Type>
 <Type entropy>
   DataSources value
-  DSName entropy Entropy bits
+  DSName value Entropy bits
   RRDTitle "Available entropy on {hostname}"
   RRDVerticalLabel "Bits"
   RRDFormat "%4.0lf"
@@ -268,7 +268,7 @@ GraphWidth 400
 </Type>
 <Type frequency>
   DataSources value
-  DSName frequency Frequency
+  DSName value Frequency
   RRDTitle "Frequency ({type_instance})"
   RRDVerticalLabel "Hertz"
   RRDFormat "%4.1lfHz"
@@ -543,7 +543,7 @@ GraphWidth 400
 </Type>
 <Type percent>
   DataSources value
-  DSName percent Percent
+  DSName value Percent
   RRDTitle "Percent ({type_instance})"
   RRDVerticalLabel "Percent"
   RRDFormat "%4.1lf%%"
@@ -551,7 +551,7 @@ GraphWidth 400
 </Type>
 <Type ping>
   DataSources value
-  DSName "ping Latency"
+  DSName "value Latency"
   RRDTitle "Network latency ({type_instance})"
   RRDVerticalLabel "Milliseconds"
   RRDFormat "%5.2lfms"
@@ -701,7 +701,7 @@ GraphWidth 400
 </Type>
 <Type users>
   DataSources value
-  DSName users Users
+  DSName value Users
   RRDTitle "Users ({type_instance}) on {hostname}"
   RRDVerticalLabel "Users"
   RRDFormat "%.1lf"
index 4f70fd6..2379c8d 100644 (file)
@@ -43,6 +43,7 @@
 %{?el6:%global _has_recent_libganglia 1}
 %{?el6:%global _has_working_libiptc 1}
 %{?el6:%global _has_ip_vs_h 1}
+%{?el6:%global _has_lvm2app_h 1}
 %{?el6:%global _has_perl_extutils_embed 1}
 
 # plugins enabled by default
@@ -53,6 +54,7 @@
 %define with_ascent 0%{!?_without_ascent:1}
 %define with_battery 0%{!?_without_battery:1}
 %define with_bind 0%{!?_without_bind:1}
+%define with_cgroups 0%{!?_without_cgroups:1}
 %define with_conntrack 0%{!?_without_conntrack:1}
 %define with_contextswitch 0%{!?_without_contextswitch:1}
 %define with_cpu 0%{!?_without_cpu:1}
@@ -82,6 +84,7 @@
 %define with_libvirt 0%{!?_without_libvirt:1}
 %define with_load 0%{!?_without_load:1}
 %define with_logfile 0%{!?_without_logfile:1}
+%define with_lvm 0%{!?_without_lvm:0%{?_has_lvm2app_h}}
 %define with_madwifi 0%{!?_without_madwifi:1}
 %define with_mbmon 0%{!?_without_mbmon:1}
 %define with_md 0%{!?_without_md:1}
@@ -90,6 +93,7 @@
 %define with_memory 0%{!?_without_memory:1}
 %define with_multimeter 0%{!?_without_multimeter:1}
 %define with_mysql 0%{!?_without_mysql:1}
+%define with_netlink 0%{!?_without_netlink:1}
 %define with_network 0%{!?_without_network:1}
 %define with_nfs 0%{!?_without_nfs:1}
 %define with_nginx 0%{!?_without_nginx:1}
 %define with_sensors 0%{!?_without_sensors:1}
 %define with_serial 0%{!?_without_serial:1}
 %define with_snmp 0%{!?_without_snmp:1}
+%define with_statsd 0%{!?_without_statsd:1}
 %define with_swap 0%{!?_without_swap:1}
 %define with_syslog 0%{!?_without_syslog:1}
 %define with_table 0%{!?_without_table:1}
 
 # plugin apple_sensors disabled, requires a Mac
 %define with_apple_sensors 0%{!?_without_apple_sensors:0}
+# plugin aquaero disabled, requires a libaquaero5
+%define with_aquaero 0%{!?_without_aquaero:0}
 # plugin lpar disabled, requires AIX
 %define with_lpar 0%{!?_without_lpar:0}
+# plugin mic disabled, requires Mic
+%define with_mic 0%{!?_without_mic:0}
 # plugin modbus disabled, requires libmodbus
 %define with_modbus 0%{!?_without_modbus:0}
 # plugin netapp disabled, requires libnetapp
 %define with_netapp 0%{!?_without_netapp:0}
-# plugin netlink disabled, requires libnetlink.h
-%define with_netlink 0%{!?_without_netlink:0}
 # plugin onewire disabled, requires libowfs
 %define with_onewire 0%{!?_without_onewire:0}
 # plugin oracle disabled, requires Oracle
 %define with_routeros 0%{!?_without_routeros:0}
 # plugin rrdcached disabled, requires rrdtool >= 1.4
 %define with_rrdcached 0%{!?_without_rrdcached:0}
+# plugin sigrok disabled, requires libsigrok
+%define with_sigrok 0%{!?_without_sigrok:0}
 # plugin tape disabled, requires libkstat
 %define with_tape 0%{!?_without_tape:0}
 # plugin tokyotyrant disabled, requires tcrdb.h
 
 Summary:       Statistics collection daemon for filling RRD files
 Name:          collectd
-Version:       5.3.1
+Version:       5.4.0
 Release:       1%{?dist}
 URL:           http://collectd.org
 Source:                http://collectd.org/files/%{name}-%{version}.tar.bz2
@@ -217,6 +226,15 @@ BuildRequires:     curl-devel
 This plugin collects data provided by Apache's `mod_status'.
 %endif
 
+%if %{with_aquaero}
+%package aquaero
+Summary:       aquaero plugin for collectd
+Group:         System Environment/Daemons
+Requires:      %{name}%{?_isa} = %{version}-%{release}
+%description aquaero
+Various sensors in the Aquaero 5 watercooling board made by Aquacomputer.
+%endif
+
 %if %{with_ascent}
 %package ascent
 Summary:       Ascent plugin for collectd
@@ -371,6 +389,17 @@ BuildRequires:     libvirt-devel
 This plugin collects information from virtualized guests.
 %endif
 
+%if %{with_lvm}
+%package lvm
+Summary:       LVM plugin for collectd
+Group:         System Environment/Daemons
+Requires:      %{name}%{?_isa} = %{version}-%{release}
+BuildRequires: lvm2-devel
+%description lvm
+This plugin collects size of “Logical Volumes” (LV) and “Volume Groups” (VG)
+of Linux' “Logical Volume Manager” (LVM).
+%endif
+
 %if %{with_memcachec}
 %package memcachec
 Summary:       Memcachec plugin for collectd
@@ -383,6 +412,16 @@ instance. Note that another plugin, named `memcached', exists and does a
 similar job, without requiring the installation of libmemcached.
 %endif
 
+%if %{with_mic}
+%package mic
+Summary:       mic plugin for collectd
+Group:         System Environment/Daemons
+Requires:      %{name}%{?_isa} = %{version}-%{release}
+%description mic
+The mic plugin collects CPU usage, memory usage, temperatures and power
+consumption from Intel Many Integrated Core (MIC) CPUs.
+%endif
+
 %if %{with_mysql}
 %package mysql
 Summary:       MySQL plugin for collectd
@@ -394,6 +433,17 @@ MySQL querying plugin. This plugin provides data of issued commands, called
 handlers and database traffic.
 %endif
 
+%if %{with_netlink}
+%package netlink
+Summary:       netlink plugin for collectd
+Group:         System Environment/Daemons
+Requires:      %{name}%{?_isa} = %{version}-%{release}
+BuildRequires: libmnl-devel
+%description netlink
+This plugin collects very detailed Linux network interface and routing
+statistics.
+%endif
+
 %if %{with_nginx}
 %package nginx
 Summary:       Nginx plugin for collectd
@@ -538,6 +588,17 @@ BuildRequires:     lm_sensors-devel
 This plugin for collectd provides querying of sensors supported by lm_sensors.
 %endif
 
+%if %{with_sigrok}
+%package sigrok
+Summary:       sigrok plugin for collectd
+Group:         System Environment/Daemons
+Requires:      %{name}%{?_isa} = %{version}-%{release}
+%description sigrok
+Uses libsigrok as a backend, allowing any sigrok-supported device to have its
+measurements fed to collectd. This includes multimeters, sound level meters,
+thermometers, and much more.
+%endif
+
 %if %{with_snmp}
 %package snmp
 Summary:       SNMP plugin for collectd
@@ -666,6 +727,12 @@ Development files for libcollectdclient
 %define _with_apple_sensors --disable-apple_sensors
 %endif
 
+%if %{with_aquaero}
+%define _with_aquaero --enable-aquaero
+%else
+%define _with_aquaero --disable-aquaero
+%endif
+
 %if %{with_ascent}
 %define _with_ascent --enable-ascent
 %else
@@ -684,6 +751,12 @@ Development files for libcollectdclient
 %define _with_bind --disable-bind
 %endif
 
+%if %{with_cgroups}
+%define _with_cgroups --enable-cgroups
+%else
+%define _with_cgroups --disable-cgroups
+%endif
+
 %if %{with_conntrack}
 %define _with_conntrack --enable-conntrack
 %else
@@ -864,6 +937,12 @@ Development files for libcollectdclient
 %define _with_lpar --disable-lpar
 %endif
 
+%if %{with_lvm}
+%define _with_lvm --enable-lvm
+%else
+%define _with_lvm --disable-lvm
+%endif
+
 %if %{with_madwifi}
 %define _with_madwifi --enable-madwifi
 %else
@@ -900,6 +979,12 @@ Development files for libcollectdclient
 %define _with_memory --disable-memory
 %endif
 
+%if %{with_mic}
+%define _with_mic --enable-mic
+%else
+%define _with_mic --disable-mic
+%endif
+
 %if %{with_modbus}
 %define _with_modbus --enable-modbus
 %else
@@ -1096,12 +1181,24 @@ Development files for libcollectdclient
 %define _with_serial --disable-serial
 %endif
 
+%if %{with_sigrok}
+%define _with_sigrok --enable-sigrok
+%else
+%define _with_sigrok --disable-sigrok
+%endif
+
 %if %{with_snmp}
 %define _with_snmp --enable-snmp
 %else
 %define _with_snmp --disable-snmp
 %endif
 
+%if %{with_statsd}
+%define _with_statsd --enable-statsd
+%else
+%define _with_statsd --disable-statsd
+%endif
+
 %if %{with_swap}
 %define _with_swap --enable-swap
 %else
@@ -1283,9 +1380,11 @@ Development files for libcollectdclient
        %{?_with_apache} \
        %{?_with_apcups} \
        %{?_with_apple_sensors} \
+       %{?_with_aquaero} \
        %{?_with_ascent} \
        %{?_with_battery} \
        %{?_with_bind} \
+       %{?_with_cgroups} \
        %{?_with_conntrack} \
        %{?_with_contextswitch} \
        %{?_with_cpu} \
@@ -1313,7 +1412,9 @@ Development files for libcollectdclient
        %{?_with_java} \
        %{?_with_libvirt} \
        %{?_with_lpar} \
+       %{?_with_lvm} \
        %{?_with_memcachec} \
+       %{?_with_mic} \
        %{?_with_modbus} \
        %{?_with_multimeter} \
        %{?_with_mysql} \
@@ -1336,6 +1437,7 @@ Development files for libcollectdclient
        %{?_with_rrdcached} \
        %{?_with_rrdtool} \
        %{?_with_sensors} \
+       %{?_with_sigrok} \
        %{?_with_snmp} \
        %{?_with_tape} \
        %{?_with_tokyotyrant} \
@@ -1363,6 +1465,7 @@ Development files for libcollectdclient
        %{?_with_processes} \
        %{?_with_protocols} \
        %{?_with_serial} \
+       %{?_with_statsd} \
        %{?_with_swap} \
        %{?_with_syslog} \
        %{?_with_table} \
@@ -1504,6 +1607,9 @@ fi
 %if %{with_battery}
 %{_libdir}/%{name}/battery.so
 %endif
+%if %{with_cgroups}
+%{_libdir}/%{name}/cgroups.so
+%endif
 %if %{with_conntrack}
 %{_libdir}/%{name}/conntrack.so
 %endif
@@ -1603,6 +1709,9 @@ fi
 %if %{with_serial}
 %{_libdir}/%{name}/serial.so
 %endif
+%if %{with_statsd}
+%{_libdir}/%{name}/statsd.so
+%endif
 %if %{with_swap}
 %{_libdir}/%{name}/swap.so
 %endif
@@ -1680,6 +1789,11 @@ fi
 %{_libdir}/%{name}/apache.so
 %endif
 
+%if %{with_aquaero}
+%files aquaero
+%{_libdir}/%{name}/aquaero.so
+%endif
+
 %if %{with_ascent}
 %files ascent
 %{_libdir}/%{name}/ascent.so
@@ -1753,16 +1867,31 @@ fi
 %{_libdir}/%{name}/libvirt.so
 %endif
 
+%if %{with_lvm}
+%files lvm
+%{_libdir}/%{name}/lvm.so
+%endif
+
 %if %{with_memcachec}
 %files memcachec
 %{_libdir}/%{name}/memcachec.so
 %endif
 
+%if %{with_mic}
+%files mic
+%{_libdir}/%{name}/mic.so
+%endif
+
 %if %{with_mysql}
 %files mysql
 %{_libdir}/%{name}/mysql.so
 %endif
 
+%if %{with_netlink}
+%files netlink
+%{_libdir}/%{name}/netlink.so
+%endif
+
 %if %{with_nginx}
 %files nginx
 %{_libdir}/%{name}/nginx.so
@@ -1835,6 +1964,11 @@ fi
 %{_libdir}/%{name}/sensors.so
 %endif
 
+%if %{with_sigrok}
+%files sigrok
+%{_libdir}/%{name}/sigrok.so
+%endif
+
 %if %{with_snmp}
 %files snmp
 %{_mandir}/man5/collectd-snmp.5*
@@ -1873,6 +2007,12 @@ fi
 %doc contrib/
 
 %changelog
+* Mon Aug 19 2013 Marc Fournier <marc.fournier@camptocamp.com> 5.4.0-1
+- New upstream version
+- Build netlink plugin by default
+- Enable cgroups, lvm and statsd plugins
+- Enable (but don't build by default) mic, aquaero and sigrok plugins
+
 * Tue Aug 06 2013 Marc Fournier <marc.fournier@camptocamp.com> 5.3.1-1
 - New upstream version
 - Added RHEL5 support:
index 59454dc..a9d8582 100644 (file)
@@ -191,7 +191,7 @@ if BUILD_PLUGIN_APPLE_SENSORS
 pkglib_LTLIBRARIES += apple_sensors.la
 apple_sensors_la_SOURCES = apple_sensors.c
 apple_sensors_la_LDFLAGS = -module -avoid-version
-apple_sensors_la_LIBADD = -lIOKit
+apple_sensors_la_LDFLAGS += -framework IOKit
 collectd_LDADD += "-dlopen" apple_sensors.la
 collectd_DEPENDENCIES += apple_sensors.la
 endif
@@ -223,7 +223,7 @@ battery_la_SOURCES = battery.c
 battery_la_LDFLAGS = -module -avoid-version
 battery_la_LIBADD =
 if BUILD_WITH_LIBIOKIT
-battery_la_LIBADD += -lIOKit
+battery_la_LDFLAGS += -framework IOKit
 endif
 collectd_LDADD += "-dlopen" battery.la
 collectd_DEPENDENCIES += battery.la
@@ -379,7 +379,7 @@ if BUILD_WITH_LIBDEVINFO
 disk_la_LIBADD += -ldevinfo
 endif
 if BUILD_WITH_LIBIOKIT
-disk_la_LIBADD += -lIOKit
+disk_la_LDFLAGS += -framework IOKit
 endif
 if BUILD_WITH_LIBSTATGRAB
 disk_la_CFLAGS += $(BUILD_WITH_LIBSTATGRAB_CFLAGS)  
index 84c797b..5db988e 100644 (file)
@@ -158,7 +158,7 @@ static int aquaero_read (void)
 
                aquaero_submit ("fanspeed", type_instance,
                                aq_data.fan_rpm[i]);
-               aquaero_submit ("percentage", type_instance,
+               aquaero_submit ("percent", type_instance,
                                aq_data.fan_duty[i]);
                aquaero_submit ("voltage", type_instance,
                                aq_data.fan_voltage[i]);
@@ -177,7 +177,7 @@ static int aquaero_read (void)
        aquaero_submit_array("flow", "sensor", aq_data.flow, AQ5_NUM_FLOW);
 
        /* Liquid level */
-       aquaero_submit_array("percentage", "waterlevel",
+       aquaero_submit_array("percent", "waterlevel",
                        aq_data.level, AQ5_NUM_LEVEL);
 
        return (0);
index ffb1740..17b12d0 100644 (file)
@@ -93,7 +93,7 @@ static int read_cpuacct_procs (const char *dirname, char const *cgroup_name,
        if (fh == NULL)
        {
                char errbuf[1024];
-               ERROR ("cgroups pluign: fopen (\"%s\") failed: %s",
+               ERROR ("cgroups plugin: fopen (\"%s\") failed: %s",
                                abs_path,
                                sstrerror (errno, errbuf, sizeof (errbuf)));
                return (-1);
@@ -111,6 +111,11 @@ static int read_cpuacct_procs (const char *dirname, char const *cgroup_name,
                 *
                 *   user: 12345
                 *   system: 23456
+                *
+                * Or:
+                *
+                *   user 12345
+                *   system 23456
                 */
                strstripnewline (buf);
                numfields = strsplit (buf, fields, STATIC_ARRAY_SIZE (fields));
@@ -122,10 +127,9 @@ static int read_cpuacct_procs (const char *dirname, char const *cgroup_name,
                if (key_len < 2)
                        continue;
 
-               /* Strip colon off the first column */
-               if (key[key_len - 1] != ':')
-                       continue;
-               key[key_len - 1] = 0;
+               /* Strip colon off the first column, if found */
+               if (key[key_len - 1] == ':')
+                       key[key_len - 1] = 0;
 
                status = parse_value (fields[1], &value, DS_TYPE_DERIVE);
                if (status != 0)
@@ -217,8 +221,9 @@ static int cgroups_read (void)
        {
                /* Find the cgroup mountpoint which contains the cpuacct
                 * controller. */
-               if (strcmp(mnt_ptr->type, "cgroup") != 0 ||
-                       !cu_mount_getoptionvalue(mnt_ptr->options, "cpuacct"))
+               if ((strcmp(mnt_ptr->type, "cgroup") != 0)
+                               || !cu_mount_checkoption(mnt_ptr->options,
+                                       "cpuacct", /* full = */ 1))
                        continue;
 
                walk_directory (mnt_ptr->dir, read_cpuacct_root,
index fd7a508..db955d6 100644 (file)
@@ -43,6 +43,17 @@ collectd-snmp - Documentation of collectd's C<snmp plugin>
       Community "another_string"
       Collect "std_traffic" "hr_users"
     </Host>
+    <Host "secure.router.mydomain.org">
+      Address "192.168.0.7"
+      Version 3
+      SecurityLevel "authPriv"
+      Username "cosmo"
+      AuthProtocol "SHA"
+      AuthPassphrase "setec_astronomy"
+      PrivacyProtocol "AES"
+      PrivacyPassphrase "too_many_secrets"
+      Collect "std_traffic"
+    </Host>
     <Host "some.ups.mydomain.org">
       Address "192.168.0.3"
       Version 1
@@ -191,6 +202,18 @@ degrees Celsius. The default value is, of course, B<0.0>.
 
 This value is not applied to counter-values.
 
+=item B<Ignore> I<Value> [, I<Value> ...]
+
+The ignore values allows to ignore Instances based on their name and the patterns
+specified by the various values you've entered. The match is a glob-type shell
+matching.
+
+=item B<InvertMatch> I<true|false(default)>
+
+The invertmatch value should be use in combination of the Ignore option.
+It changes the behaviour of the Ignore option, from a blacklist behaviour
+when InvertMatch is set to false, to a whitelist when specified to true.
+
 =back
 
 =head2 The Host block
@@ -207,14 +230,41 @@ stored by collectd.
 
 Set the address to connect to.
 
-=item B<Version> B<1>|B<2>
+=item B<Version> B<1>|B<2>|B<3>
 
 Set the SNMP version to use. When giving B<2> version C<2c> is actually used.
-Version 3 is not supported by this plugin.
 
 =item B<Community> I<Community>
 
-Pass I<Community> to the host.
+Pass I<Community> to the host. (Ignored for SNMPv3).
+
+=item B<Username> I<Username>
+
+Sets the I<Username> to use for SNMPv3 security.
+
+=item B<SecurityLevel> I<authPriv>|I<authNoPriv>|I<noAuthNoPriv>
+
+Selects the security level for SNMPv3 security.
+
+=item B<Context> I<Context>
+
+Sets the I<Context> for SNMPv3 security.
+
+=item B<AuthProtocol> I<MD5>|I<SHA>
+
+Selects the authentication protocol for SNMPv3 security.
+
+=item B<AuthPassphrase> I<Passphrase>
+
+Sets the authentication passphrase for SNMPv3 security. 
+
+=item B<PrivacyProtocol> I<AES>|I<DES>
+
+Selects the privacy (encryption) protocol for SNMPv3 security.
+
+=item B<PrivacyPassphrase> I<Passphrase>
+
+Sets the privacy (encryption) passphrase for SNMPv3 security. 
 
 =item B<Collect> I<Data> [I<Data> ...]
 
@@ -241,8 +291,9 @@ L<snmpgetnext(1)>,
 L<variables(5)>,
 L<unix(7)>
 
-=head1 AUTHOR
+=head1 AUTHORS
 
 Florian Forster E<lt>octo@verplant.orgE<gt>
+Michael Pilat E<lt>mike@mikepilat.comE<gt>
 
 =cut
index d96d676..d259753 100644 (file)
@@ -118,7 +118,7 @@ static int init_hostname (void)
                ERROR ("Looking up \"%s\" failed. You have set the "
                                "\"FQDNLookup\" option, but I cannot resolve "
                                "my hostname to a fully qualified domain "
-                               "name. Please fix you network "
+                               "name. Please fix the network "
                                "configuration.", hostname_g);
                return (-1);
        }
index 9e4c269..7d9dab3 100644 (file)
 #  </View>
 #</Plugin>
 
+#<Plugin cgroup>
+#  CGroup "libvirt"
+#  IgnoreSelected false
+#</Plugin>
+
 #<Plugin csv>
 #      DataDir "@localstatedir@/lib/@PACKAGE_NAME@/csv"
 #      StoreRates false
 #      ReportByDevice false
 #      ReportReserved false
 #      ReportInodes false
+#      ValuesAbsolute true
+#      ValuesPercentage false
 #</Plugin>
 
 #<Plugin disk>
 #      InterfaceFormat name
 #</Plugin>
 
+#<Plugin load>
+#        ReportRelative true
+#</Plugin>
+
 #<Plugin lpar>
 #      CpuPoolStats   false
 #      ReportBySerial false
 #      </Instance>
 #</Plugin>
 
+#<Plugin memory>
+#      ValuesAbsolute true
+#      ValuesPercentage false
+#</Plugin>
+
 #<Plugin modbus>
 #      <Data "data_name">
 #              RegisterBase 1234
 #<Plugin "swap">
 #      ReportByDevice false
 #      ReportBytes true
+#      ValuesAbsolute true
+#      ValuesPercentage false
 #</Plugin>
 
 #<Plugin "table">
 #  <Node "example">
 #    Host "localhost"
 #    Port "2003"
-#    Protocol "udp"
+#    Protocol "tcp"
 #    LogSendErrors true
 #    Prefix "collectd"
 #    Postfix "collectd"
 #              Protocol UDP
 #              StoreRates true
 #              AlwaysAppendDS false
+#              TTLFactor 2.0
 #      </Node>
 #      Tag "foobar"
 #       Attribute "foo" "bar"
index 7a6eefe..a14a8f6 100644 (file)
@@ -9,14 +9,14 @@ collectd.conf - Configuration for the system statistics collection daemon B<coll
   BaseDir "/path/to/data/"
   PIDFile "/path/to/pidfile/collectd.pid"
   Server  "123.123.123.123" 12345
-  
+
   LoadPlugin cpu
   LoadPlugin load
-  
+
   <LoadPlugin df>
     Interval 3600
   </LoadPlugin>
-  
+
   LoadPlugin ping
   <Plugin ping>
     Host "example.org"
@@ -341,10 +341,10 @@ The full example configuration looks like this:
    <Aggregation>
      Plugin "cpu"
      Type "cpu"
-     
+
      GroupBy "Host"
      GroupBy "TypeInstance"
-     
+
      CalculateSum true
      CalculateAverage true
    </Aggregation>
@@ -420,13 +420,13 @@ The following example calculates the average usage of all "even" CPUs:
      Plugin "cpu"
      PluginInstance "/[0,2,4,6,8]$/"
      Type "cpu"
-     
+
      SetPlugin "cpu"
      SetPluginInstance "even-%{aggregation}"
-     
+
      GroupBy "Host"
      GroupBy "TypeInstance"
-     
+
      CalculateAverage true
    </Aggregation>
  </Plugin>
@@ -495,7 +495,7 @@ possibly filtering or messages.
  #   GraphitePrefix "collectd."
  #   GraphiteEscapeChar "_"
    </Publish>
-   
+
    # Receive values from an AMQP broker
    <Subscribe "some_name">
      Host "localhost"
@@ -822,17 +822,17 @@ Synopsis:
    ParseTime       false
    OpCodes         true
    QTypes          true
+
    ServerStats     true
    ZoneMaintStats  true
    ResolverStats   false
    MemoryStats     true
+
    <View "_default">
      QTypes        true
      ResolverStats true
      CacheRRSets   true
+
      Zone "127.in-addr.arpa/IN"
    </View>
  </Plugin>
@@ -973,6 +973,31 @@ at all, B<all> cgroups are selected.
 
 =back
 
+=head2 Plugin C<cpu>
+
+The I<CPU plugin> collects CPU usage metrics.
+
+The following configuration options are available:
+
+=over 4
+
+=item B<ReportActive> B<false>|B<true>
+
+Reports non-idle CPU usage as the "active" value. Defaults to false.
+
+=item B<ReportByCpu> B<false>|B<true>
+
+When true reports usage for all cores. When false, reports cpu usage
+aggregated over all cores. Implies ValuesPercentage when false.
+Defaults to true.
+
+=item B<ValuesPercentage> B<false>|B<true>
+
+When true report percentage usage instead of tick values. Defaults to false.
+
+=back
+
+
 =head2 Plugin C<cpufreq>
 
 This plugin doesn't have any options. It reads
@@ -1046,6 +1071,10 @@ Username to use if authorization is required to read the page.
 
 Password to use if authorization is required to read the page.
 
+=item B<Digest> B<true>|B<false>
+
+Enable HTTP digest authentication.
+
 =item B<VerifyPeer> B<true>|B<false>
 
 Enable or disable peer SSL certificate verification. See
@@ -1157,11 +1186,19 @@ The following options are valid within B<URL> blocks:
 Sets the plugin instance to I<Instance>.
 
 =item B<User> I<Name>
+
 =item B<Password> I<Password>
+
+=item B<Digest> B<true>|B<false>
+
 =item B<VerifyPeer> B<true>|B<false>
+
 =item B<VerifyHost> B<true>|B<false>
+
 =item B<CACert> I<file>
+
 =item B<Header> I<Header>
+
 =item B<Post> I<Body>
 
 These options behave exactly equivalent to the appropriate options of the
@@ -1250,6 +1287,8 @@ Examples:
 
 =item B<Password> I<Password>
 
+=item B<Digest> B<true>|B<false>
+
 =item B<VerifyPeer> B<true>|B<false>
 
 =item B<VerifyHost> B<true>|B<false>
@@ -1603,17 +1642,17 @@ transfer agents and web caches.
 
 =item B<ValuesAbsolute> B<true>|B<false>
 
-Enables or disables reporting of free, used and used disk space in 1K-blocks. 
-Defaults to true.
+Enables or disables reporting of free and used disk space in 1K-blocks.
+Defaults to B<true>.
 
-=item B<ValuesPercentage> B<true>|B<false>
+=item B<ValuesPercentage> B<false>|B<true>
 
-Enables or disables reporting of free, used and used disk space in percentage.
-Defaults to false.
+Enables or disables reporting of free and used disk space in percentage.
+Defaults to B<false>.
 
-This is useful for deploying collectd on the cloud, where machines with
-different disk size may exist. Then it is more practical to configure thresholds
-based on relative disk size.
+This is useful for deploying I<collectd> on the cloud, where machines with
+different disk size may exist. Then it is more practical to configure
+thresholds based on relative disk size.
 
 =back
 
@@ -2199,6 +2238,25 @@ interface path might change between reboots of a guest or across migrations.
 
 =back
 
++=head2 Plugin C<load>
+
+The I<Load plugin> collects the system load. These numbers give a rough overview
+over the utilization of a machine. The system load is defined as the number of
+runnable tasks in the run-queue and is provided by many operating systems as a
+one, five or fifteen minute average.
+
+The following configuration options are available:
+
+=over 4
+
+=item B<ReportRelative> B<false>|B<true>
+
+When enabled, system load divided by number of available CPU cores is reported
+for intervals 1 min, 5 min and 15 min. Defaults to false.
+
+=back
+
+
 =head2 Plugin C<logfile>
 
 =over 4
@@ -2406,7 +2464,7 @@ B<Synopsis:>
    ShowCPU true
    ShowCPUCores true
    ShowMemory true
-   
+
    ShowTemperatures true
    Temperature vddg
    Temperature vddq
@@ -2415,7 +2473,7 @@ B<Synopsis:>
    ShowPower true
    Power total0
    Power total1
-   IgnoreSelectedPower true   
+   IgnoreSelectedPower true
  </Plugin>
 
 The following options are valid inside the B<PluginE<nbsp>mic> block:
@@ -2472,7 +2530,7 @@ Fan In
 
 =item fout
 
-Fan Out 
+Fan Out
 
 =item vccp
 
@@ -2513,11 +2571,11 @@ Known power names are:
 
 =item total0
 
-Total power utilization averaged over Time Window 0 (uWatts). 
+Total power utilization averaged over Time Window 0 (uWatts).
 
 =item total1
 
-Total power utilization averaged over Time Window 0 (uWatts). 
+Total power utilization averaged over Time Window 0 (uWatts).
 
 =item inst
 
@@ -2525,36 +2583,57 @@ Instantaneous power (uWatts).
 
 =item imax
 
-Max instantaneous power (uWatts). 
+Max instantaneous power (uWatts).
 
 =item pcie
 
-PCI-E connector power (uWatts). 
+PCI-E connector power (uWatts).
 
 =item c2x3
 
-2x3 connector power (uWatts). 
+2x3 connector power (uWatts).
 
 =item c2x4
 
-2x4 connector power (uWatts). 
+2x4 connector power (uWatts).
 
 =item vccp
 
-Core rail (uVolts). 
+Core rail (uVolts).
 
 =item vddg
 
-Uncore rail (uVolts). 
+Uncore rail (uVolts).
 
 =item vddq
 
-Memory subsystem rail (uVolts). 
+Memory subsystem rail (uVolts).
 
 =back
 
 =back
 
+=head2 Plugin C<memory>
+
+The I<memory plugin> provides the following configuration options:
+
+=over 4
+
+=item B<ValuesAbsolute> B<true>|B<false>
+
+Enables or disables reporting of physical memory usage in absolute numbers,
+i.e. bytes. Defaults to B<true>.
+
+=item B<ValuesPercentage> B<false>|B<true>
+
+Enables or disables reporting of physical memory usage in percentages, e.g.
+percent of physical memory used. Defaults to B<false>.
+
+This is useful for deploying I<collectd> in a heterogeneous environment in
+which the sizes of physical memory vary.
+
+=back
+
 =head2 Plugin C<modbus>
 
 The B<modbus plugin> connects to a Modbus "slave" via Modbus/TCP and reads
@@ -2570,19 +2649,19 @@ B<Synopsis:>
    Type voltage
    Instance "input-1"
  </Data>
+
  <Data "voltage-input-2">
    RegisterBase 2
    RegisterType float
    Type voltage
    Instance "input-2"
  </Data>
+
  <Host "modbus.example.com">
    Address "192.168.0.42"
    Port    "502"
    Interval 60
-   
+
    <Slave 1>
      Instance "power-supply"
      Collect  "voltage-input-1"
@@ -2815,7 +2894,7 @@ Required capabilities are documented below.
     User          "username"
     Password      "aef4Aebe"
     Interval      30
-    
+
     <WAFL>
       Interval 30
       GetNameCache   true
@@ -2823,12 +2902,12 @@ Required capabilities are documented below.
       GetBufferCache true
       GetInodeCache  true
     </WAFL>
-    
+
     <Disks>
       Interval 30
       GetBusy true
     </Disks>
-    
+
     <VolumePerf>
       Interval 30
       GetIO      "volume0"
@@ -2838,7 +2917,7 @@ Required capabilities are documented below.
       GetLatency "volume0"
       IgnoreSelectedLatency false
     </VolumePerf>
-    
+
     <VolumeUsage>
       Interval 30
       GetCapacity "vol0"
@@ -2848,15 +2927,15 @@ Required capabilities are documented below.
       GetSnapshot "vol3"
       IgnoreSelectedSnapshot false
     </VolumeUsage>
-    
+
     <Quota>
       Interval 60
     </Quota>
-    
+
     <Snapvault>
       Interval 30
     </Snapvault>
-    
+
     <System>
       Interval 30
       GetCPULoad     true
@@ -3417,7 +3496,7 @@ signature):
    # Export to an internal server
    # (demonstrates usage without additional options)
    Server "collectd.internal.tld"
-   
+
    # Export to an external server
    # (demonstrates usage with signature options)
    <Server "collectd.external.tld">
@@ -5337,6 +5416,19 @@ This option is only available if the I<Swap plugin> can read C</proc/swaps>
 When enabled, the I<swap I/O> is reported in bytes. When disabled, the default,
 I<swap I/O> is reported in pages. This option is available under Linux only.
 
+=item B<ValuesAbsolute> B<true>|B<false>
+
+Enables or disables reporting of absolute swap metrics, i.e. number of I<bytes>
+available and used. Defaults to B<true>.
+
+=item B<ValuesPercentage> B<false>|B<true>
+
+Enables or disables reporting of relative swap metrics, i.e. I<percent>
+available and free. Defaults to B<false>.
+
+This is useful for deploying I<collectd> in a heterogeneous environment, where
+swap sizes differ and you want to specify generic thresholds or similar.
+
 =back
 
 =head2 Plugin C<syslog>
@@ -6089,7 +6181,7 @@ Synopsis:
    <Node "example">
      Host "localhost"
      Port "2003"
-     Protocol "udp"
+     Protocol "tcp"
      LogSendErrors true
      Prefix "collectd"
    </Node>
@@ -6392,7 +6484,7 @@ When a value comes within range again or is received after it was missing, an
 Here is a configuration example to get you started. Read below for more
 information.
 
- <Threshold>
+ <Plugin threshold>
    <Type "foo">
      WarningMin    0.00
      WarningMax 1000.00
@@ -6423,7 +6515,7 @@ information.
        </Type>
      </Plugin>
    </Host>
- </Threshold>
+ </Plugin>
 
 There are basically two types of configuration statements: The C<Host>,
 C<Plugin>, and C<Type> blocks select the value for which a threshold should be
@@ -7012,7 +7104,7 @@ Example:
    Max 100
    Satisfy "All"
  </Match>
+
  # Match if the value of any data source is outside the range of 0 - 100.
  <Match "value">
    Min   0
@@ -7194,7 +7286,7 @@ Example:
  <Target "replace">
    # Replace "example.net" with "example.com"
    Host "\\<example.net\\>" "example.com"
+
    # Strip "www." from hostnames
    Host "\\<www\\." ""
  </Target>
index 161b4d6..18b5c43 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * collectd - src/common.c
- * Copyright (C) 2005-2010  Florian octo Forster
+ * Copyright (C) 2005-2014  Florian octo Forster
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -418,34 +418,36 @@ size_t strstripnewline (char *buffer)
        return (buffer_len);
 } /* size_t strstripnewline */
 
-int escape_slashes (char *buf, int buf_len)
+int escape_slashes (char *buffer, size_t buffer_size)
 {
        int i;
+       size_t buffer_len;
 
-       if (strcmp (buf, "/") == 0)
-       {
-               if (buf_len < 5)
-                       return (-1);
+       buffer_len = strlen (buffer);
 
-               strncpy (buf, "root", buf_len);
+       if (buffer_len <= 1)
+       {
+               if (strcmp ("/", buffer) == 0)
+               {
+                       if (buffer_size < 5)
+                               return (-1);
+                       sstrncpy (buffer, "root", buffer_size);
+               }
                return (0);
        }
 
-       if (buf_len <= 1)
-               return (0);
-
        /* Move one to the left */
-       if (buf[0] == '/')
-               memmove (buf, buf + 1, buf_len - 1);
+       if (buffer[0] == '/')
+       {
+               memmove (buffer, buffer + 1, buffer_len);
+               buffer_len--;
+       }
 
-       for (i = 0; i < buf_len - 1; i++)
+       for (i = 0; i < buffer_len - 1; i++)
        {
-               if (buf[i] == '\0')
-                       break;
-               else if (buf[i] == '/')
-                       buf[i] = '_';
+               if (buffer[i] == '/')
+                       buffer[i] = '_';
        }
-       buf[i] = '\0';
 
        return (0);
 } /* int escape_slashes */
@@ -648,7 +650,7 @@ int get_kstat (kstat_t **ksp_ptr, char *module, int instance, char *name)
        char ident[128];
 
        *ksp_ptr = NULL;
-       
+
        if (kc == NULL)
                return (-1);
 
@@ -1234,7 +1236,7 @@ int walk_directory (const char *dir, dirwalk_callback_f callback,
        while ((ent = readdir (dh)) != NULL)
        {
                int status;
-               
+
                if (include_hidden)
                {
                        if ((strcmp (".", ent->d_name) == 0)
@@ -1397,6 +1399,69 @@ int rate_to_value (value_t *ret_value, gauge_t rate, /* {{{ */
        return (0);
 } /* }}} value_t rate_to_value */
 
+int value_to_rate (value_t *ret_rate, derive_t value, /* {{{ */
+               value_to_rate_state_t *state,
+               int ds_type, cdtime_t t)
+{
+       double interval;
+
+       /* Another invalid state: The time is not increasing. */
+       if (t <= state->last_time)
+       {
+               memset (state, 0, sizeof (*state));
+               return (EINVAL);
+       }
+
+       interval = CDTIME_T_TO_DOUBLE(t - state->last_time);
+
+       /* Previous value is invalid. */
+       if (state->last_time == 0) /* {{{ */
+       {
+               if (ds_type == DS_TYPE_DERIVE)
+               {
+                       state->last_value.derive = value;
+               }
+               else if (ds_type == DS_TYPE_COUNTER)
+               {
+                       state->last_value.counter = (counter_t) value;
+               }
+               else if (ds_type == DS_TYPE_ABSOLUTE)
+               {
+                       state->last_value.absolute = (absolute_t) value;
+               }
+               else
+               {
+                       assert (23 == 42);
+               }
+
+               state->last_time = t;
+               return (EAGAIN);
+       } /* }}} */
+
+       if (ds_type == DS_TYPE_DERIVE)
+       {
+               ret_rate->gauge = (value - state->last_value.derive) / interval;
+               state->last_value.derive = value;
+       }
+       else if (ds_type == DS_TYPE_COUNTER)
+       {
+               ret_rate->gauge = (((counter_t)value) - state->last_value.counter) / interval;
+               state->last_value.counter = (counter_t) value;
+       }
+       else if (ds_type == DS_TYPE_ABSOLUTE)
+       {
+               ret_rate->gauge = (((absolute_t)value) - state->last_value.absolute) / interval;
+               state->last_value.absolute = (absolute_t) value;
+       }
+       else
+       {
+               assert (23 == 42);
+       }
+
+        state->last_time = t;
+       return (0);
+} /* }}} value_t rate_to_value */
+
 int service_name_to_port_number (const char *service_name)
 {
        struct addrinfo *ai_list;
index 317be8d..29590ff 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * collectd - src/common.h
- * Copyright (C) 2005-2010  Florian octo Forster
+ * Copyright (C) 2005-2014  Florian octo Forster
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -55,6 +55,13 @@ struct rate_to_value_state_s
 };
 typedef struct rate_to_value_state_s rate_to_value_state_t;
 
+struct value_to_rate_state_s
+{
+  value_t last_value;
+  cdtime_t last_time;
+};
+typedef struct value_to_rate_state_s value_to_rate_state_t;
+
 char *sstrncpy (char *dest, const char *src, size_t n);
 
 __attribute__ ((format(printf,3,4)))
@@ -158,19 +165,21 @@ int strjoin (char *dst, size_t dst_len, char **fields, size_t fields_num, const
  *   escape_slashes
  *
  * DESCRIPTION
- *   Removes slashes from the string `buf' and substitutes them with something
- *   appropriate. This function should be used whenever a path is to be used as
- *   (part of) an instance.
+ *   Removes slashes ("/") from "buffer". If buffer contains a single slash,
+ *   the result will be "root". Leading slashes are removed. All other slashes
+ *   are replaced with underscores ("_").
+ *   This function is used by plugin_dispatch_values() to escape all parts of
+ *   the identifier.
  *
  * PARAMETERS
- *   `buf'         String to be escaped.
- *   `buf_len'     Length of the buffer. No more then this many bytes will be
- *   written to `buf', including the trailing null-byte.
+ *   `buffer'         String to be escaped.
+ *   `buffer_size'    Size of the buffer. No more then this many bytes will be
+ *                    written to `buffer', including the trailing null-byte.
  *
  * RETURN VALUE
  *   Returns zero upon success and a value smaller than zero upon failure.
  */
-int escape_slashes (char *buf, int buf_len);
+int escape_slashes (char *buffer, size_t buffer_size);
 
 /*
  * NAME
@@ -322,6 +331,9 @@ counter_t counter_diff (counter_t old_value, counter_t new_value);
 int rate_to_value (value_t *ret_value, gauge_t rate,
                rate_to_value_state_t *state, int ds_type, cdtime_t t);
 
+int value_to_rate (value_t *ret_rate, derive_t value,
+               value_to_rate_state_t *state, int ds_type, cdtime_t t);
+
 /* Converts a service name (a string) to a port number
  * (in the range [1-65535]). Returns less than zero on error. */
 int service_name_to_port_number (const char *service_name);
index 33236c4..e7bccad 100644 (file)
@@ -8,7 +8,7 @@
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the GNU
  * General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License along
 #endif
 
 #define CONNTRACK_FILE "/proc/sys/net/netfilter/nf_conntrack_count"
+#define CONNTRACK_MAX_FILE "/proc/sys/net/netfilter/nf_conntrack_max"
 
-static void conntrack_submit (value_t conntrack)
+static void conntrack_submit (const char *type, const char *type_instance,
+                             value_t conntrack)
 {
        value_list_t vl = VALUE_LIST_INIT;
 
@@ -39,14 +41,17 @@ static void conntrack_submit (value_t conntrack)
        vl.values_len = 1;
        sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "conntrack", sizeof (vl.plugin));
-       sstrncpy (vl.type, "conntrack", sizeof (vl.type));
+       sstrncpy (vl.type, type, sizeof (vl.type));
+       if (type_instance != NULL)
+               sstrncpy (vl.type_instance, type_instance,
+                         sizeof (vl.type_instance));
 
        plugin_dispatch_values (&vl);
 } /* static void conntrack_submit */
 
 static int conntrack_read (void)
 {
-       value_t conntrack;
+       value_t conntrack, conntrack_max, conntrack_pct;
        FILE *fh;
        char buffer[64];
        size_t buffer_len;
@@ -74,7 +79,35 @@ static int conntrack_read (void)
        if (parse_value (buffer, &conntrack, DS_TYPE_GAUGE) != 0)
                return (-1);
 
-       conntrack_submit (conntrack);
+       conntrack_submit ("conntrack", NULL, conntrack);
+
+       fh = fopen (CONNTRACK_MAX_FILE, "r");
+       if (fh == NULL)
+               return (-1);
+
+       memset (buffer, 0, sizeof (buffer));
+       if (fgets (buffer, sizeof (buffer), fh) == NULL)
+       {
+               fclose (fh);
+               return (-1);
+       }
+       fclose (fh);
+
+       /* strip trailing newline. */
+       buffer_len = strlen (buffer);
+       while ((buffer_len > 0) && isspace ((int) buffer[buffer_len - 1]))
+       {
+               buffer[buffer_len - 1] = 0;
+               buffer_len--;
+       }
+
+       if (parse_value (buffer, &conntrack_max, DS_TYPE_GAUGE) != 0)
+               return (-1);
+
+       conntrack_submit ("conntrack", "max", conntrack_max);
+       conntrack_pct.gauge = (conntrack.gauge / conntrack_max.gauge) * 100;
+       conntrack_submit ("percent", "used", conntrack_pct);
+
 
        return (0);
 } /* static int conntrack_read */
index 2247d5f..2e225fd 100644 (file)
--- a/src/cpu.c
+++ b/src/cpu.c
@@ -1,9 +1,9 @@
 /**
  * collectd - src/cpu.c
  * Copyright (C) 2005-2010  Florian octo Forster
- * Copyright (C) 2008       Oleg King
- * Copyright (C) 2009       Simon Kuhnle
- * Copyright (C) 2009       Manuel Sanmartin
+ * Copyright (C) 2008      Oleg King
+ * Copyright (C) 2009      Simon Kuhnle
+ * Copyright (C) 2009      Manuel Sanmartin
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -11,7 +11,7 @@
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the GNU
  * General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License along
 # define CAN_USE_SYSCTL 0
 #endif
 
+#define CPU_SUBMIT_USER 0
+#define CPU_SUBMIT_SYSTEM 1
+#define CPU_SUBMIT_WAIT 2
+#define CPU_SUBMIT_NICE 3
+#define CPU_SUBMIT_SWAP 4
+#define CPU_SUBMIT_INTERRUPT 5
+#define CPU_SUBMIT_SOFTIRQ 6
+#define CPU_SUBMIT_STEAL 7
+#define CPU_SUBMIT_IDLE 8
+#define CPU_SUBMIT_ACTIVE 9
+#define CPU_SUBMIT_MAX 10
+
 #if HAVE_STATGRAB_H
 # include <statgrab.h>
 #endif
 # error "No applicable input method."
 #endif
 
+static const char *cpu_state_names[] = {
+       "user",
+       "system",
+       "wait",
+       "nice",
+       "swap",
+       "interrupt",
+       "softirq",
+       "steal",
+       "idle",
+       "active"
+};
+
 #ifdef PROCESSOR_CPU_LOAD_INFO
 static mach_port_t port_host;
 static processor_port_array_t cpu_list;
@@ -107,8 +132,8 @@ static mach_msg_type_number_t cpu_list_len;
 
 #if PROCESSOR_TEMPERATURE
 static int cpu_temp_retry_counter = 0;
-static int cpu_temp_retry_step    = 1;
-static int cpu_temp_retry_max     = 1;
+static int cpu_temp_retry_step   = 1;
+static int cpu_temp_retry_max    = 1;
 #endif /* PROCESSOR_TEMPERATURE */
 /* #endif PROCESSOR_CPU_LOAD_INFO */
 
@@ -145,6 +170,86 @@ static int numcpu;
 static int pnumcpu;
 #endif /* HAVE_PERFSTAT */
 
+static value_to_rate_state_t *percents = NULL;
+static gauge_t agg_percents[CPU_SUBMIT_MAX] = {
+       -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
+
+};
+static int percents_cells = 0;
+static int cpu_count = 0;
+
+
+static _Bool report_by_cpu = 1;
+static _Bool report_percent = 0;
+static _Bool report_active = 0;
+
+static const char *config_keys[] =
+{
+       "ReportByCpu",
+       "ReportActive",
+       "ValuesPercentage"
+};
+static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
+
+
+static int cpu_config (const char *key, const char *value)
+{
+       if (strcasecmp (key, "ReportByCpu") == 0) {
+               report_by_cpu = IS_TRUE (value) ? 1 : 0;
+               if (!report_by_cpu)
+                       report_percent = 1;
+       }
+       if (strcasecmp (key, "ValuesPercentage") == 0) {
+               report_percent = IS_TRUE (value) ? 1 : 0;
+               if (!report_percent)
+                       report_by_cpu = 1;
+       }
+       if (strcasecmp (key, "ReportActive") == 0)
+               report_active = IS_TRUE (value) ? 1 : 0;
+       return (-1);
+}
+
+static int cpu_states_grow (void)
+{
+  void *tmp;
+  int size;
+  int i;
+
+  size = cpu_count * CPU_SUBMIT_MAX; /* always alloc for all states */
+
+  if (size <= 0)
+         return 0;
+
+  if (percents_cells >= size)
+         return 0;
+
+  if (percents == NULL) {
+         percents = malloc(size * sizeof(*percents));
+         if (percents == NULL)
+                 return -1;
+         for (i = 0; i < size; i++)
+                 memset(&percents[i], 0, sizeof(*percents));
+         percents_cells = size;
+         return 0;
+  }
+
+  tmp = realloc(percents, size * sizeof(*percents));
+
+  if (tmp == NULL) {
+         ERROR ("cpu plugin: could not reserve enough space to hold states");
+         percents = NULL;
+         return -1;
+  }
+
+  for (i = percents_cells; i < size; i++)
+         memset(&percents[i], 0, sizeof(*percents));
+
+  percents = tmp;
+  percents_cells = size;
+  return 0;
+} /* cpu_states_grow */
+
+
 static int init (void)
 {
 #if PROCESSOR_CPU_LOAD_INFO || PROCESSOR_TEMPERATURE
@@ -241,39 +346,156 @@ static int init (void)
        return (0);
 } /* int init */
 
-static void submit (int cpu_num, const char *type_instance, derive_t value)
+static void submit_value (int cpu_num, int cpu_state, const char *type, value_t value)
 {
        value_t values[1];
        value_list_t vl = VALUE_LIST_INIT;
 
-       values[0].derive = value;
+       memcpy(&values[0], &value, sizeof(value));
 
        vl.values = values;
        vl.values_len = 1;
+
        sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "cpu", sizeof (vl.plugin));
-       ssnprintf (vl.plugin_instance, sizeof (vl.plugin_instance),
-                       "%i", cpu_num);
-       sstrncpy (vl.type, "cpu", sizeof (vl.type));
-       sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
+       sstrncpy (vl.type, type, sizeof (vl.type));
+       sstrncpy (vl.type_instance, cpu_state_names[cpu_state],
+                 sizeof (vl.type_instance));
 
+       if (cpu_num >= 0) {
+               ssnprintf (vl.plugin_instance, sizeof (vl.plugin_instance),
+                          "%i", cpu_num);
+       }
        plugin_dispatch_values (&vl);
 }
 
+static void submit_percent(int cpu_num, int cpu_state, gauge_t percent)
+{
+       value_t value;
+
+       value.gauge = percent;
+       submit_value (cpu_num, cpu_state, "percent", value);
+}
+
+static void submit_derive(int cpu_num, int cpu_state, derive_t derive)
+{
+       value_t value;
+
+       value.derive = derive;
+       submit_value (cpu_num, cpu_state, "cpu", value);
+}
+
+static void submit_flush (void)
+{
+       int i = 0;
+
+       if (report_by_cpu) {
+               cpu_count = 0;
+               return;
+       }
+
+       for (i = 0; i < CPU_SUBMIT_MAX; i++) {
+               if (agg_percents[i] == -1)
+                       continue;
+
+               submit_percent(-1, i, agg_percents[i] / cpu_count);
+               agg_percents[i] = -1;
+       }
+       cpu_count = 0;
+}
+
+static void submit (int cpu_num, derive_t *derives)
+{
+
+       int i = 0;
+
+       if (!report_percent && report_by_cpu) {
+               derive_t cpu_active = 0;
+               for (i = 0; i < CPU_SUBMIT_ACTIVE; i++)
+               {
+                       if (derives[i] == -1)
+                               continue;
+
+                       if (i != CPU_SUBMIT_IDLE)
+                               cpu_active += derives[i];
+
+                       submit_derive(cpu_num, i, derives[i]);
+               }
+               if (report_active)
+                       submit_derive(cpu_num, CPU_SUBMIT_ACTIVE, cpu_active);
+       }
+       else /* we are reporting percents */
+       {
+               cdtime_t cdt;
+               gauge_t percent;
+               gauge_t cpu_total = 0;
+               gauge_t cpu_active = 0;
+               gauge_t local_rates[CPU_SUBMIT_MAX];
+
+               cpu_count++;
+               if (cpu_states_grow())
+                       return;
+
+               memset(local_rates, 0, sizeof(local_rates));
+
+               cdt = cdtime();
+               for (i = 0; i < CPU_SUBMIT_ACTIVE; i++) {
+                       value_t rate;
+                       int index;
+
+                       if (derives[i] == -1)
+                               continue;
+
+                       index = (cpu_num * CPU_SUBMIT_MAX) + i;
+                       if (value_to_rate(&rate, derives[i], &percents[index],
+                                         DS_TYPE_DERIVE, cdt) != 0) {
+                               local_rates[i] = -1;
+                               continue;
+                       }
+
+                       local_rates[i] = rate.gauge;
+                       cpu_total += rate.gauge;
+                       if (i != CPU_SUBMIT_IDLE)
+                               cpu_active += rate.gauge;
+               }
+               if (cpu_total == 0.0)
+                       return;
+
+               if (report_active)
+                       local_rates[CPU_SUBMIT_ACTIVE] = cpu_active;
+
+               for (i = 0; i < CPU_SUBMIT_MAX; i++) {
+                       if (local_rates[i] == -1)
+                               continue;
+
+                       percent = (local_rates[i] / cpu_total) * 100;
+                       if (report_by_cpu)
+                               submit_percent (cpu_num, i, percent);
+                       else {
+                               if (agg_percents[i] == -1)
+                                       agg_percents[i] = percent;
+                               else
+                                       agg_percents[i] += percent;
+                       }
+
+               }
+       }
+}
+
 static int cpu_read (void)
 {
 #if PROCESSOR_CPU_LOAD_INFO || PROCESSOR_TEMPERATURE
        int cpu;
 
        kern_return_t status;
-       
+
 #if PROCESSOR_CPU_LOAD_INFO
        processor_cpu_load_info_data_t cpu_info;
-       mach_msg_type_number_t         cpu_info_len;
+       mach_msg_type_number_t         cpu_info_len;
 #endif
 #if PROCESSOR_TEMPERATURE
-       processor_info_data_t          cpu_temp;
-       mach_msg_type_number_t         cpu_temp_len;
+       processor_info_data_t          cpu_temp;
+       mach_msg_type_number_t         cpu_temp_len;
 #endif
 
        host_t cpu_host;
@@ -281,6 +503,10 @@ static int cpu_read (void)
        for (cpu = 0; cpu < cpu_list_len; cpu++)
        {
 #if PROCESSOR_CPU_LOAD_INFO
+               derive_t derives[CPU_SUBMIT_MAX] = {
+                       -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
+               };
+               memset(derives, -1, sizeof(derives));
                cpu_host = 0;
                cpu_info_len = PROCESSOR_BASIC_INFO_COUNT;
 
@@ -298,10 +524,12 @@ static int cpu_read (void)
                        continue;
                }
 
-               submit (cpu, "user", (derive_t) cpu_info.cpu_ticks[CPU_STATE_USER]);
-               submit (cpu, "nice", (derive_t) cpu_info.cpu_ticks[CPU_STATE_NICE]);
-               submit (cpu, "system", (derive_t) cpu_info.cpu_ticks[CPU_STATE_SYSTEM]);
-               submit (cpu, "idle", (derive_t) cpu_info.cpu_ticks[CPU_STATE_IDLE]);
+               derives[CPU_SUBMIT_USER] = (derive_t) cpu_info.cpu_ticks[CPU_STATE_USER];
+               derives[CPU_SUBMIT_NICE] = (derive_t) cpu_info.cpu_ticks[CPU_STATE_NICE];
+               derives[CPU_SUBMIT_SYSTEM] = (derive_t) cpu_info.cpu_ticks[CPU_STATE_SYSTEM];
+               derives[CPU_SUBMIT_IDLE] = (derive_t) cpu_info.cpu_ticks[CPU_STATE_IDLE];
+               submit (cpu, derives);
+
 #endif /* PROCESSOR_CPU_LOAD_INFO */
 #if PROCESSOR_TEMPERATURE
                /*
@@ -338,7 +566,7 @@ static int cpu_read (void)
                if (cpu_temp_len != 1)
                {
                        DEBUG ("processor_info (PROCESSOR_TEMPERATURE) returned %i elements..?",
-                                       (int) cpu_temp_len);
+                                       (int) cpu_temp_len);
                        continue;
                }
 
@@ -346,12 +574,11 @@ static int cpu_read (void)
                cpu_temp_retry_step    = 1;
 #endif /* PROCESSOR_TEMPERATURE */
        }
+       submit_flush ();
 /* #endif PROCESSOR_CPU_LOAD_INFO */
 
 #elif defined(KERNEL_LINUX)
        int cpu;
-       derive_t user, nice, syst, idle;
-       derive_t wait, intr, sitr; /* sitr == soft interrupt */
        FILE *fh;
        char buf[1024];
 
@@ -368,6 +595,10 @@ static int cpu_read (void)
 
        while (fgets (buf, 1024, fh) != NULL)
        {
+               derive_t derives[CPU_SUBMIT_MAX] = {
+                       -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
+               };
+
                if (strncmp (buf, "cpu", 3))
                        continue;
                if ((buf[3] < '0') || (buf[3] > '9'))
@@ -378,37 +609,29 @@ static int cpu_read (void)
                        continue;
 
                cpu = atoi (fields[0] + 3);
-               user = atoll (fields[1]);
-               nice = atoll (fields[2]);
-               syst = atoll (fields[3]);
-               idle = atoll (fields[4]);
-
-               submit (cpu, "user", user);
-               submit (cpu, "nice", nice);
-               submit (cpu, "system", syst);
-               submit (cpu, "idle", idle);
+               derives[CPU_SUBMIT_USER] = atoll(fields[1]);
+               derives[CPU_SUBMIT_NICE] = atoll(fields[2]);
+               derives[CPU_SUBMIT_SYSTEM] = atoll(fields[3]);
+               derives[CPU_SUBMIT_IDLE] = atoll(fields[4]);
 
                if (numfields >= 8)
                {
-                       wait = atoll (fields[5]);
-                       intr = atoll (fields[6]);
-                       sitr = atoll (fields[7]);
-
-                       submit (cpu, "wait", wait);
-                       submit (cpu, "interrupt", intr);
-                       submit (cpu, "softirq", sitr);
+                       derives[CPU_SUBMIT_WAIT] = atoll(fields[5]);
+                       derives[CPU_SUBMIT_INTERRUPT] = atoll(fields[6]);
+                       derives[CPU_SUBMIT_SOFTIRQ] = atoll(fields[6]);
 
                        if (numfields >= 9)
-                               submit (cpu, "steal", atoll (fields[8]));
+                               derives[CPU_SUBMIT_STEAL] = atoll(fields[8]);
                }
+               submit(cpu, derives);
        }
+       submit_flush();
 
        fclose (fh);
 /* #endif defined(KERNEL_LINUX) */
 
 #elif defined(HAVE_LIBKSTAT)
        int cpu;
-       derive_t user, syst, idle, wait;
        static cpu_stat_t cs;
 
        if (kc == NULL)
@@ -416,19 +639,21 @@ static int cpu_read (void)
 
        for (cpu = 0; cpu < numcpu; cpu++)
        {
+               derive_t derives[CPU_SUBMIT_MAX] = {
+                       -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
+               };
+
                if (kstat_read (kc, ksp[cpu], &cs) == -1)
                        continue; /* error message? */
 
-               idle = (derive_t) cs.cpu_sysinfo.cpu[CPU_IDLE];
-               user = (derive_t) cs.cpu_sysinfo.cpu[CPU_USER];
-               syst = (derive_t) cs.cpu_sysinfo.cpu[CPU_KERNEL];
-               wait = (derive_t) cs.cpu_sysinfo.cpu[CPU_WAIT];
-
-               submit (ksp[cpu]->ks_instance, "user", user);
-               submit (ksp[cpu]->ks_instance, "system", syst);
-               submit (ksp[cpu]->ks_instance, "idle", idle);
-               submit (ksp[cpu]->ks_instance, "wait", wait);
+               memset(derives, -1, sizeof(derives));
+               derives[CPU_SUBMIT_IDLE] = cs.cpu_sysinfo.cpu[CPU_IDLE];
+               derives[CPU_SUBMIT_USER] = cs.cpu_sysinfo.cpu[CPU_USER];
+               derives[CPU_SUBMIT_SYSTEM] = cs.cpu_sysinfo.cpu[CPU_KERNEL];
+               derives[CPU_SUBMIT_WAIT] = cs.cpu_sysinfo.cpu[CPU_WAIT];
+               submit (ksp[cpu]->ks_instance, derives);
        }
+       submit_flush ();
 /* #endif defined(HAVE_LIBKSTAT) */
 
 #elif CAN_USE_SYSCTL
@@ -487,12 +712,18 @@ static int cpu_read (void)
        }
 
        for (i = 0; i < numcpu; i++) {
-               submit (i, "user",      cpuinfo[i][CP_USER]);
-               submit (i, "nice",      cpuinfo[i][CP_NICE]);
-               submit (i, "system",    cpuinfo[i][CP_SYS]);
-               submit (i, "idle",      cpuinfo[i][CP_IDLE]);
-               submit (i, "interrupt", cpuinfo[i][CP_INTR]);
+               derive_t derives[CPU_SUBMIT_MAX] = {
+                       -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
+               };
+
+               derives[CPU_SUBMIT_USER] = cpuinfo[i][CP_USER];
+               derives[CPU_SUBMIT_NICE] = cpuinfo[i][CP_NICE];
+               derives[CPU_SUBMIT_SYSTEM] = cpuinfo[i][CP_SYS];
+               derives[CPU_SUBMIT_IDLE] = cpuinfo[i][CP_IDLE];
+               derives[CPU_SUBMIT_INTERRUPT] = cpuinfo[i][CP_INTR];
+               submit(i, derives);
        }
+       submit_flush();
 /* #endif CAN_USE_SYSCTL */
 #elif defined(HAVE_SYSCTLBYNAME) && defined(HAVE_SYSCTL_KERN_CP_TIMES)
        long cpuinfo[maxcpu][CPUSTATES];
@@ -511,16 +742,26 @@ static int cpu_read (void)
        }
 
        for (i = 0; i < numcpu; i++) {
-               submit (i, "user", cpuinfo[i][CP_USER]);
-               submit (i, "nice", cpuinfo[i][CP_NICE]);
-               submit (i, "system", cpuinfo[i][CP_SYS]);
-               submit (i, "idle", cpuinfo[i][CP_IDLE]);
-               submit (i, "interrupt", cpuinfo[i][CP_INTR]);
+               derive_t derives[CPU_SUBMIT_MAX] = {
+                       -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
+               };
+
+               derives[CPU_SUBMIT_USER] = cpuinfo[i][CP_USER];
+               derives[CPU_SUBMIT_NICE] = cpuinfo[i][CP_NICE];
+               derives[CPU_SUBMIT_SYSTEM] = cpuinfo[i][CP_SYS];
+               derives[CPU_SUBMIT_IDLE] = cpuinfo[i][CP_IDLE];
+               derives[CPU_SUBMIT_INTERRUPT] = cpuinfo[i][CP_INTR];
+               submit(i, derives);
        }
+       submit_flush();
+
 /* #endif HAVE_SYSCTL_KERN_CP_TIMES */
 #elif defined(HAVE_SYSCTLBYNAME)
        long cpuinfo[CPUSTATES];
        size_t cpuinfo_size;
+       derive_t derives[CPU_SUBMIT_MAX] = {
+               -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
+       };
 
        cpuinfo_size = sizeof (cpuinfo);
 
@@ -532,15 +773,21 @@ static int cpu_read (void)
                return (-1);
        }
 
-       submit (0, "user", cpuinfo[CP_USER]);
-       submit (0, "nice", cpuinfo[CP_NICE]);
-       submit (0, "system", cpuinfo[CP_SYS]);
-       submit (0, "idle", cpuinfo[CP_IDLE]);
-       submit (0, "interrupt", cpuinfo[CP_INTR]);
+       derives[CPU_SUBMIT_USER] = cpuinfo[CP_USER];
+       derives[CPU_SUBMIT_SYSTEM] = cpuinfo[CP_SYS];
+       derives[CPU_SUBMIT_NICE] = cpuinfo[CP_NICE];
+       derives[CPU_SUBMIT_IDLE] = cpuinfo[CP_IDLE];
+       derives[CPU_SUBMIT_INTERRUPT] = cpuinfo[CP_INTR];
+       submit(0, derives);
+       submit_flush();
+
 /* #endif HAVE_SYSCTLBYNAME */
 
 #elif defined(HAVE_LIBSTATGRAB)
        sg_cpu_stats *cs;
+       derive_t derives[CPU_SUBMIT_MAX] = {
+               -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
+       };
        cs = sg_get_cpu_stats ();
 
        if (cs == NULL)
@@ -549,12 +796,14 @@ static int cpu_read (void)
                return (-1);
        }
 
-       submit (0, "idle",   (derive_t) cs->idle);
-       submit (0, "nice",   (derive_t) cs->nice);
-       submit (0, "swap",   (derive_t) cs->swap);
-       submit (0, "system", (derive_t) cs->kernel);
-       submit (0, "user",   (derive_t) cs->user);
-       submit (0, "wait",   (derive_t) cs->iowait);
+       derives[CPU_SUBMIT_IDLE] = (derive_t) cs->idle;
+       derives[CPU_SUBMIT_NICE] = (derive_t) cs->nice;
+       derives[CPU_SUBMIT_SWAP] = (derive_t) cs->swap;
+       derives[CPU_SUBMIT_SYSTEM] = (derive_t) cs->kernel;
+       derives[CPU_SUBMIT_USER] = (derive_t) cs->user;
+       derives[CPU_SUBMIT_WAIT] = (derive_t) cs->iowait;
+       submit(0, derives);
+       submit_flush();
 /* #endif HAVE_LIBSTATGRAB */
 
 #elif defined(HAVE_PERFSTAT)
@@ -569,10 +818,10 @@ static int cpu_read (void)
                        sstrerror (errno, errbuf, sizeof (errbuf)));
                return (-1);
        }
-       
-       if (pnumcpu != numcpu || perfcpu == NULL) 
+
+       if (pnumcpu != numcpu || perfcpu == NULL)
        {
-               if (perfcpu != NULL) 
+               if (perfcpu != NULL)
                        free(perfcpu);
                perfcpu = malloc(numcpu * sizeof(perfstat_cpu_t));
        }
@@ -587,13 +836,18 @@ static int cpu_read (void)
                return (-1);
        }
 
-       for (i = 0; i < cpus; i++) 
+       for (i = 0; i < cpus; i++)
        {
-               submit (i, "idle",   (derive_t) perfcpu[i].idle);
-               submit (i, "system", (derive_t) perfcpu[i].sys);
-               submit (i, "user",   (derive_t) perfcpu[i].user);
-               submit (i, "wait",   (derive_t) perfcpu[i].wait);
+               derive_t derives[CPU_SUBMIT_MAX] = {
+                       -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
+               };
+               derives[CPU_SUBMIT_IDLE] = perfcpu[i].idle;
+               derives[CPU_SUBMIT_SYSTEM] = perfcpu[i].sys;
+               derives[CPU_SUBMIT_USER] = perfcpu[i].user;
+               derives[CPU_SUBMIT_WAIT] = perfcpu[i].wait;
+               submit(i, derives);
        }
+       submit_flush();
 #endif /* HAVE_PERFSTAT */
 
        return (0);
@@ -602,5 +856,6 @@ static int cpu_read (void)
 void module_register (void)
 {
        plugin_register_init ("cpu", init);
+       plugin_register_config ("cpu", cpu_config, config_keys, config_keys_num);
        plugin_register_read ("cpu", cpu_read);
 } /* void module_register */
index 5990368..e189df6 100644 (file)
@@ -58,6 +58,7 @@ struct web_page_s /* {{{ */
   char *user;
   char *pass;
   char *credentials;
+  _Bool digest;
   _Bool verify_peer;
   _Bool verify_host;
   char *cacert;
@@ -388,6 +389,13 @@ static int cc_page_init_curl (web_page_t *wp) /* {{{ */
     ssnprintf (wp->credentials, credentials_size, "%s:%s",
         wp->user, (wp->pass == NULL) ? "" : wp->pass);
     curl_easy_setopt (wp->curl, CURLOPT_USERPWD, wp->credentials);
+    
+    if (wp->digest)
+    {
+      curl_easy_setopt (wp->curl, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
+      curl_easy_setopt (wp->curl, CURLOPT_USERNAME, wp->user);
+      curl_easy_setopt (wp->curl, CURLOPT_PASSWORD, wp->pass);
+    }
   }
 
   curl_easy_setopt (wp->curl, CURLOPT_SSL_VERIFYPEER, (long) wp->verify_peer);
@@ -425,6 +433,7 @@ static int cc_config_add_page (oconfig_item_t *ci) /* {{{ */
   page->url = NULL;
   page->user = NULL;
   page->pass = NULL;
+  page->digest = 0;
   page->verify_peer = 1;
   page->verify_host = 1;
   page->response_time = 0;
@@ -450,6 +459,8 @@ static int cc_config_add_page (oconfig_item_t *ci) /* {{{ */
       status = cf_util_get_string (child, &page->user);
     else if (strcasecmp ("Password", child->key) == 0)
       status = cf_util_get_string (child, &page->pass);
+    else if (strcasecmp ("Digest", child->key) == 0)
+      status = cf_util_get_boolean (child, &page->digest);
     else if (strcasecmp ("VerifyPeer", child->key) == 0)
       status = cf_util_get_boolean (child, &page->verify_peer);
     else if (strcasecmp ("VerifyHost", child->key) == 0)
@@ -585,7 +596,8 @@ static void cc_submit (const web_page_t *wp, const web_match_t *wm, /* {{{ */
   sstrncpy (vl.plugin, "curl", sizeof (vl.plugin));
   sstrncpy (vl.plugin_instance, wp->instance, sizeof (vl.plugin_instance));
   sstrncpy (vl.type, wm->type, sizeof (vl.type));
-  sstrncpy (vl.type_instance, wm->instance, sizeof (vl.type_instance));
+  if (wm->instance != NULL)
+    sstrncpy (vl.type_instance, wm->instance, sizeof (vl.type_instance));
 
   plugin_dispatch_values (&vl);
 } /* }}} void cc_submit */
index 251fee8..a9db925 100644 (file)
@@ -53,10 +53,10 @@ struct cj_key_s;
 typedef struct cj_key_s cj_key_t;
 struct cj_key_s /* {{{ */
 {
+  unsigned long magic;
   char *path;
   char *type;
   char *instance;
-  unsigned long magic;
 };
 /* }}} */
 
@@ -71,6 +71,7 @@ struct cj_s /* {{{ */
   char *user;
   char *pass;
   char *credentials;
+  _Bool digest;
   _Bool verify_peer;
   _Bool verify_host;
   char *cacert;
@@ -549,6 +550,7 @@ static int cj_config_add_key (cj_t *db, /* {{{ */
         len = ptr-name;
         if (len == 0)
           break;
+        len = COUCH_MIN(len, sizeof (ent)-1);
         sstrncpy (ent, name, len+1);
 
         if (c_avl_get (tree, ent, (void *) &value) != 0)
@@ -608,6 +610,13 @@ static int cj_init_curl (cj_t *db) /* {{{ */
     ssnprintf (db->credentials, credentials_size, "%s:%s",
                db->user, (db->pass == NULL) ? "" : db->pass);
     curl_easy_setopt (db->curl, CURLOPT_USERPWD, db->credentials);
+    
+    if (db->digest)
+    {
+      curl_easy_setopt (db->curl, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
+      curl_easy_setopt (db->curl, CURLOPT_USERNAME, db->user);
+      curl_easy_setopt (db->curl, CURLOPT_PASSWORD, db->pass);
+    }
   }
 
   curl_easy_setopt (db->curl, CURLOPT_SSL_VERIFYPEER, (long) db->verify_peer);
@@ -674,6 +683,8 @@ static int cj_config_add_url (oconfig_item_t *ci) /* {{{ */
       status = cf_util_get_string (child, &db->user);
     else if (db->url && strcasecmp ("Password", child->key) == 0)
       status = cf_util_get_string (child, &db->pass);
+    else if (strcasecmp ("Digest", child->key) == 0)
+      status = cf_util_get_boolean (child, &db->digest);
     else if (db->url && strcasecmp ("VerifyPeer", child->key) == 0)
       status = cf_util_get_boolean (child, &db->verify_peer);
     else if (db->url && strcasecmp ("VerifyHost", child->key) == 0)
@@ -858,17 +869,17 @@ static int cj_curl_perform(cj_t *db) /* {{{ */
   int status;
   long rc;
   char *url;
-  url = NULL;
-  curl_easy_getinfo(db->curl, CURLINFO_EFFECTIVE_URL, &url);
+  url = db->url;
 
   status = curl_easy_perform (db->curl);
   if (status != CURLE_OK)
   {
     ERROR ("curl_json plugin: curl_easy_perform failed with status %i: %s (%s)",
-           status, db->curl_errbuf, (url != NULL) ? url : "<null>");
+           status, db->curl_errbuf, url);
     return (-1);
   }
 
+  curl_easy_getinfo(db->curl, CURLINFO_EFFECTIVE_URL, &url);
   curl_easy_getinfo(db->curl, CURLINFO_RESPONSE_CODE, &rc);
 
   /* The response code is zero if a non-HTTP transport was used. */
index 3554d7e..6d36d29 100644 (file)
@@ -76,6 +76,7 @@ struct cx_s /* {{{ */
   char *user;
   char *pass;
   char *credentials;
+  _Bool digest;
   _Bool verify_peer;
   _Bool verify_host;
   char *cacert;
@@ -608,6 +609,7 @@ static int cx_curl_perform (cx_t *db, CURL *curl) /* {{{ */
   long rc;
   char *ptr;
   char *url;
+  url = db->url;
 
   db->buffer_fill = 0; 
   status = curl_easy_perform (curl);
@@ -859,6 +861,13 @@ static int cx_init_curl (cx_t *db) /* {{{ */
     ssnprintf (db->credentials, credentials_size, "%s:%s",
                db->user, (db->pass == NULL) ? "" : db->pass);
     curl_easy_setopt (db->curl, CURLOPT_USERPWD, db->credentials);
+    
+    if (db->digest)
+    {
+      curl_easy_setopt (db->curl, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
+      curl_easy_setopt (db->curl, CURLOPT_USERNAME, db->user);
+      curl_easy_setopt (db->curl, CURLOPT_PASSWORD, db->pass);
+    }
   }
 
   curl_easy_setopt (db->curl, CURLOPT_SSL_VERIFYPEER, db->verify_peer ? 1L : 0L);
@@ -925,6 +934,8 @@ static int cx_config_add_url (oconfig_item_t *ci) /* {{{ */
       status = cf_util_get_string (child, &db->user);
     else if (strcasecmp ("Password", child->key) == 0)
       status = cf_util_get_string (child, &db->pass);
+    else if (strcasecmp ("Digest", child->key) == 0)
+      status = cf_util_get_boolean (child, &db->digest);
     else if (strcasecmp ("VerifyPeer", child->key) == 0)
       status = cf_util_get_boolean (child, &db->verify_peer);
     else if (strcasecmp ("VerifyHost", child->key) == 0)
index ea82039..c618af9 100644 (file)
@@ -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);
index 0188da7..9b5dd3d 100644 (file)
@@ -2,6 +2,7 @@
  * collectd - src/load.c
  * Copyright (C) 2005-2008  Florian octo Forster
  * Copyright (C) 2009       Manuel Sanmartin
+ * Copyright (C) 2013       Vedran Bartonicek
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -19,6 +20,7 @@
  * Authors:
  *   Florian octo Forster <octo at verplant.org>
  *   Manuel Sanmartin
+ *   Vedran Bartonicek <vbartoni at gmail.com>
  **/
 
 #define _BSD_SOURCE
@@ -27,6 +29,8 @@
 #include "common.h"
 #include "plugin.h"
 
+#include <unistd.h>
+
 #ifdef HAVE_SYS_LOADAVG_H
 #include <sys/loadavg.h>
 #endif
 # include <libperfstat.h>
 #endif /* HAVE_PERFSTAT */
 
+static _Bool report_relative_load = 0;
+
+static const char *config_keys[] =
+{
+       "ReportRelative"
+};
+static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
+
+static int load_config (const char *key, const char *value)
+{
+       if (strcasecmp (key, "ReportRelative") == 0)
+#ifdef _SC_NPROCESSORS_ONLN
+               report_relative_load = IS_TRUE (value) ? 1 : 0;
+#else
+                WARNING ("load plugin: The \"ReportRelative\" configuration "
+                         "is not available, because I can't determine the "
+                         "number of CPUS on this system. Sorry.");
+#endif
+       return (-1);
+
+}
 static void load_submit (gauge_t snum, gauge_t mnum, gauge_t lnum)
 {
        value_t values[3];
        value_list_t vl = VALUE_LIST_INIT;
+        int cores = 0;
+        char errbuf[1024];
+
+#ifdef  _SC_NPROCESSORS_ONLN
+        if (report_relative_load) {
+                if ((cores = sysconf(_SC_NPROCESSORS_ONLN)) < 1) {
+                       WARNING ("load: sysconf failed : %s",
+                                sstrerror (errno, errbuf, sizeof (errbuf)));
+               }
+       }
+#endif
+       if (cores > 0) {
+               snum /= cores;
+               mnum /= cores;
+               lnum /= cores;
+       }
 
        values[0].gauge = snum;
        values[1].gauge = mnum;
@@ -60,10 +101,16 @@ static void load_submit (gauge_t snum, gauge_t mnum, gauge_t lnum)
 
        vl.values = values;
        vl.values_len = STATIC_ARRAY_SIZE (values);
+
        sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "load", sizeof (vl.plugin));
        sstrncpy (vl.type, "load", sizeof (vl.type));
 
+       if (cores > 0) {
+               sstrncpy(vl.type_instance, "relative",
+                        sizeof (vl.type_instance));
+       }
+
        plugin_dispatch_values (&vl);
 }
 
@@ -73,17 +120,17 @@ static int load_read (void)
        double load[3];
 
        if (getloadavg (load, 3) == 3)
-               load_submit (load[LOADAVG_1MIN], load[LOADAVG_5MIN], load[LOADAVG_15MIN]);
-       else
-       {
-               char errbuf[1024];
-               WARNING ("load: getloadavg failed: %s",
-                               sstrerror (errno, errbuf, sizeof (errbuf)));
+                load_submit (load[LOADAVG_1MIN], load[LOADAVG_5MIN], load[LOADAVG_15MIN]);
+        else
+        {
+                char errbuf[1024];
+                WARNING ("load: getloadavg failed: %s",
+                         sstrerror (errno, errbuf, sizeof (errbuf)));
        }
 /* #endif HAVE_GETLOADAVG */
 
 #elif defined(KERNEL_LINUX)
-       gauge_t snum, mnum, lnum;
+        gauge_t snum, mnum, lnum;
        FILE *loadavg;
        char buffer[16];
 
@@ -123,11 +170,11 @@ static int load_read (void)
        mnum = atof (fields[1]);
        lnum = atof (fields[2]);
 
-       load_submit (snum, mnum, lnum);
+        load_submit(snum, mnum, lnum);
 /* #endif KERNEL_LINUX */
 
 #elif HAVE_LIBSTATGRAB
-       gauge_t snum, mnum, lnum;
+        gauge_t snum, mnum, lnum;
        sg_load_stats *ls;
 
        if ((ls = sg_get_load_stats ()) == NULL)
@@ -136,12 +183,11 @@ static int load_read (void)
        snum = ls->min1;
        mnum = ls->min5;
        lnum = ls->min15;
-
-       load_submit (snum, mnum, lnum);
+        load_submit(snum, mnum, lnum);
 /* #endif HAVE_LIBSTATGRAB */
 
 #elif HAVE_PERFSTAT
-       gauge_t snum, mnum, lnum;
+        gauge_t snum, mnum, lnum;
        perfstat_cpu_total_t cputotal;
 
        if (perfstat_cpu_total(NULL,  &cputotal, sizeof(perfstat_cpu_total_t), 1) < 0)
@@ -155,8 +201,7 @@ static int load_read (void)
        snum = (float)cputotal.loadavg[0]/(float)(1<<SBITS);
        mnum = (float)cputotal.loadavg[1]/(float)(1<<SBITS);
        lnum = (float)cputotal.loadavg[2]/(float)(1<<SBITS);
-
-       load_submit (snum, mnum, lnum);
+        load_submit(snum, mnum, lnum);
 /* #endif HAVE_PERFSTAT */
 
 #else
@@ -168,5 +213,6 @@ static int load_read (void)
 
 void module_register (void)
 {
+       plugin_register_config ("load", load_config, config_keys, config_keys_num);
        plugin_register_read ("load", load_read);
 } /* void module_register */
index 6a50161..b33c1f8 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * collectd - src/memory.c
- * Copyright (C) 2005-2008  Florian octo Forster
+ * Copyright (C) 2005-2014  Florian octo Forster
  * Copyright (C) 2009       Simon Kuhnle
  * Copyright (C) 2009       Manuel Sanmartin
  *
@@ -84,12 +84,33 @@ static int pagesize;
 /* endif HAVE_LIBSTATGRAB */
 #elif HAVE_PERFSTAT
 static int pagesize;
-static perfstat_memory_total_t pmemory;
 /* endif HAVE_PERFSTAT */
 #else
 # error "No applicable input method."
 #endif
 
+static _Bool values_absolute = 1;
+static _Bool values_percentage = 0;
+
+static int memory_config (oconfig_item_t *ci) /* {{{ */
+{
+       int i;
+
+       for (i = 0; i < ci->children_num; i++)
+       {
+               oconfig_item_t *child = ci->children + i;
+               if (strcasecmp ("ValuesAbsolute", child->key) == 0)
+                       cf_util_get_boolean (child, &values_absolute);
+               else if (strcasecmp ("ValuesPercentage", child->key) == 0)
+                       cf_util_get_boolean (child, &values_percentage);
+               else
+                       ERROR ("memory plugin: Invalid configuration option: "
+                                       "\"%s\".", child->key);
+       }
+
+       return (0);
+} /* }}} int memory_config */
+
 static int memory_init (void)
 {
 #if HAVE_HOST_STATISTICS
@@ -134,24 +155,14 @@ static int memory_init (void)
        return (0);
 } /* int memory_init */
 
-static void memory_submit (const char *type_instance, gauge_t value)
-{
-       value_t values[1];
-       value_list_t vl = VALUE_LIST_INIT;
-
-       values[0].gauge = value;
-
-       vl.values = values;
-       vl.values_len = 1;
-       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
-       sstrncpy (vl.plugin, "memory", sizeof (vl.plugin));
-       sstrncpy (vl.type, "memory", sizeof (vl.type));
-       sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
-
-       plugin_dispatch_values (&vl);
-}
+#define MEMORY_SUBMIT(...) do { \
+       if (values_absolute) \
+               plugin_dispatch_multivalue (vl, 0, __VA_ARGS__, NULL); \
+       if (values_percentage) \
+               plugin_dispatch_multivalue (vl, 1, __VA_ARGS__, NULL); \
+} while (0)
 
-static int memory_read (void)
+static int memory_read_internal (value_list_t *vl)
 {
 #if HAVE_HOST_STATISTICS
        kern_return_t status;
@@ -200,10 +211,10 @@ static int memory_read (void)
        inactive = (gauge_t) (((uint64_t) vm_data.inactive_count) * ((uint64_t) pagesize));
        free     = (gauge_t) (((uint64_t) vm_data.free_count)     * ((uint64_t) pagesize));
 
-       memory_submit ("wired",    wired);
-       memory_submit ("active",   active);
-       memory_submit ("inactive", inactive);
-       memory_submit ("free",     free);
+       MEMORY_SUBMIT ("wired",    wired,
+                      "active",   active,
+                      "inactive", inactive,
+                      "free",     free);
 /* #endif HAVE_HOST_STATISTICS */
 
 #elif HAVE_SYSCTLBYNAME
@@ -253,11 +264,11 @@ static int memory_read (void)
                if (!isnan (sysctl_vals[i]))
                        sysctl_vals[i] *= sysctl_vals[0];
 
-       memory_submit ("free",     sysctl_vals[2]);
-       memory_submit ("wired",    sysctl_vals[3]);
-       memory_submit ("active",   sysctl_vals[4]);
-       memory_submit ("inactive", sysctl_vals[5]);
-       memory_submit ("cache",    sysctl_vals[6]);
+       MEMORY_SUBMIT ("free",     (gauge_t) sysctl_vals[2],
+                      "wired",    (gauge_t) sysctl_vals[3],
+                      "active",   (gauge_t) sysctl_vals[4],
+                      "inactive", (gauge_t) sysctl_vals[5],
+                      "cache",    (gauge_t) sysctl_vals[6]);
 /* #endif HAVE_SYSCTLBYNAME */
 
 #elif KERNEL_LINUX
@@ -267,10 +278,11 @@ static int memory_read (void)
        char *fields[8];
        int numfields;
 
-       long long mem_used = 0;
-       long long mem_buffered = 0;
-       long long mem_cached = 0;
-       long long mem_free = 0;
+       gauge_t mem_total = 0;
+       gauge_t mem_used = 0;
+       gauge_t mem_buffered = 0;
+       gauge_t mem_cached = 0;
+       gauge_t mem_free = 0;
 
        if ((fh = fopen ("/proc/meminfo", "r")) == NULL)
        {
@@ -280,12 +292,12 @@ static int memory_read (void)
                return (-1);
        }
 
-       while (fgets (buffer, 1024, fh) != NULL)
+       while (fgets (buffer, sizeof (buffer), fh) != NULL)
        {
-               long long *val = NULL;
+               gauge_t *val = NULL;
 
                if (strncasecmp (buffer, "MemTotal:", 9) == 0)
-                       val = &mem_used;
+                       val = &mem_total;
                else if (strncasecmp (buffer, "MemFree:", 8) == 0)
                        val = &mem_free;
                else if (strncasecmp (buffer, "Buffers:", 8) == 0)
@@ -295,12 +307,11 @@ static int memory_read (void)
                else
                        continue;
 
-               numfields = strsplit (buffer, fields, 8);
-
+               numfields = strsplit (buffer, fields, STATIC_ARRAY_SIZE (fields));
                if (numfields < 2)
                        continue;
 
-               *val = atoll (fields[1]) * 1024LL;
+               *val = 1024.0 * atof (fields[1]);
        }
 
        if (fclose (fh))
@@ -310,19 +321,19 @@ static int memory_read (void)
                                sstrerror (errno, errbuf, sizeof (errbuf)));
        }
 
-       if (mem_used >= (mem_free + mem_buffered + mem_cached))
-       {
-               mem_used -= mem_free + mem_buffered + mem_cached;
-               memory_submit ("used",     mem_used);
-               memory_submit ("buffered", mem_buffered);
-               memory_submit ("cached",   mem_cached);
-               memory_submit ("free",     mem_free);
-       }
+       if (mem_total < (mem_free + mem_buffered + mem_cached))
+               return (-1);
+
+       mem_used = mem_total - (mem_free + mem_buffered + mem_cached);
+       MEMORY_SUBMIT ("used",     mem_used,
+                      "buffered", mem_buffered,
+                      "cached",   mem_cached,
+                      "free",     mem_free);
 /* #endif KERNEL_LINUX */
 
 #elif HAVE_LIBKSTAT
-        /* Most of the additions here were taken as-is from the k9toolkit from
-         * Brendan Gregg and are subject to change I guess */
+       /* Most of the additions here were taken as-is from the k9toolkit from
+        * Brendan Gregg and are subject to change I guess */
        long long mem_used;
        long long mem_free;
        long long mem_lock;
@@ -372,7 +383,7 @@ static int memory_read (void)
        }
 
        /* mem_kern is accounted for in mem_lock */
-       if ( pp_kernel < mem_lock )
+       if (pp_kernel < mem_lock)
        {
                mem_kern = pp_kernel;
                mem_lock -= pp_kernel;
@@ -389,16 +400,19 @@ static int memory_read (void)
        mem_kern *= pagesize; /* it's 2011 RAM is cheap */
        mem_unus *= pagesize;
 
-       memory_submit ("used",   mem_used);
-       memory_submit ("free",   mem_free);
-       memory_submit ("locked", mem_lock);
-       memory_submit ("kernel", mem_kern);
-       memory_submit ("unusable", mem_unus);
+       MEMORY_SUBMIT ("used",     (gauge_t) mem_used,
+                      "free",     (gauge_t) mem_free,
+                      "locked",   (gauge_t) mem_lock,
+                      "kernel",   (gauge_t) mem_kern,
+                      "unusable", (gauge_t) mem_unus);
 /* #endif HAVE_LIBKSTAT */
 
 #elif HAVE_SYSCTL
        int mib[] = {CTL_VM, VM_METER};
        struct vmtotal vmtotal;
+       gauge_t mem_active;
+       gauge_t mem_inactive;
+       gauge_t mem_free;
        size_t size;
 
        memset (&vmtotal, 0, sizeof (vmtotal));
@@ -412,42 +426,76 @@ static int memory_read (void)
        }
 
        assert (pagesize > 0);
-       memory_submit ("active",   vmtotal.t_arm * pagesize);
-       memory_submit ("inactive", (vmtotal.t_rm - vmtotal.t_arm) * pagesize);
-       memory_submit ("free",     vmtotal.t_free * pagesize);
+       mem_active   = (gauge_t) (vmtotal.t_arm * pagesize);
+       mem_inactive = (gauge_t) ((vmtotal.t_rm - vmtotal.t_arm) * pagesize);
+       mem_free     = (gauge_t) (vmtotal.t_free * pagesize);
+
+       MEMORY_SUBMIT ("active",   mem_active,
+                      "inactive", mem_inactive,
+                      "free",     mem_free);
 /* #endif HAVE_SYSCTL */
 
 #elif HAVE_LIBSTATGRAB
        sg_mem_stats *ios;
 
-       if ((ios = sg_get_mem_stats ()) != NULL)
-       {
-               memory_submit ("used",   ios->used);
-               memory_submit ("cached", ios->cache);
-               memory_submit ("free",   ios->free);
-       }
+       ios = sg_get_mem_stats ();
+       if (ios == NULL)
+               return (-1);
+
+       MEMORY_SUBMIT ("used",   (gauge_t) ios->used,
+                      "cached", (gauge_t) ios->cache,
+                      "free",   (gauge_t) ios->free);
 /* #endif HAVE_LIBSTATGRAB */
 
 #elif HAVE_PERFSTAT
-       if (perfstat_memory_total(NULL, &pmemory, sizeof(perfstat_memory_total_t), 1) < 0)
+       perfstat_memory_total_t pmemory;
+
+       memset (&pmemory, 0, sizeof (pmemory));
+       if (perfstat_memory_total(NULL, &pmemory, sizeof(pmemory), 1) < 0)
        {
                char errbuf[1024];
                WARNING ("memory plugin: perfstat_memory_total failed: %s",
                        sstrerror (errno, errbuf, sizeof (errbuf)));
                return (-1);
        }
-       memory_submit ("used",   pmemory.real_inuse * pagesize);
-       memory_submit ("free",   pmemory.real_free * pagesize);
-       memory_submit ("cached", pmemory.numperm * pagesize);
-       memory_submit ("system", pmemory.real_system * pagesize);
-       memory_submit ("user",   pmemory.real_process * pagesize);
+
+       /* Unfortunately, the AIX documentation is not very clear on how these
+        * numbers relate to one another. The only thing is states explcitly
+        * is:
+        *   real_total = real_process + real_free + numperm + real_system
+        *
+        * Another segmentation, which would be closer to the numbers reported
+        * by the "svmon" utility, would be:
+        *   real_total = real_free + real_inuse
+        *   real_inuse = "active" + real_pinned + numperm
+        */
+       MEMORY_SUBMIT ("free",   (gauge_t) (pmemory.real_free    * pagesize),
+                      "cached", (gauge_t) (pmemory.numperm      * pagesize),
+                      "system", (gauge_t) (pmemory.real_system  * pagesize),
+                      "user",   (gauge_t) (pmemory.real_process * pagesize));
 #endif /* HAVE_PERFSTAT */
 
        return (0);
-}
+} /* }}} int memory_read_internal */
+
+static int memory_read (void) /* {{{ */
+{
+       value_t v[1];
+       value_list_t vl = VALUE_LIST_INIT;
+
+       vl.values = v;
+       vl.values_len = STATIC_ARRAY_SIZE (v);
+       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+       sstrncpy (vl.plugin, "memory", sizeof (vl.plugin));
+       sstrncpy (vl.type, "memory", sizeof (vl.type));
+       vl.time = cdtime ();
+
+       return (memory_read_internal (&vl));
+} /* }}} int memory_read */
 
 void module_register (void)
 {
+       plugin_register_complex_config ("memory", memory_config);
        plugin_register_init ("memory", memory_init);
        plugin_register_read ("memory", memory_read);
 } /* void module_register */
index 5e670d4..de2de9b 100644 (file)
@@ -310,10 +310,10 @@ static void check_ignorelist_and_submit (const char *dev,
 
 } /* void check_ignorelist_and_submit */
 
-#define COPY_RTNL_LINK_VALUE (dst_stats, src_stats, value_name) \
+#define COPY_RTNL_LINK_VALUE(dst_stats, src_stats, value_name) \
   (dst_stats)->value_name = (src_stats)->value_name
 
-#define COPY_RTNL_LINK_STATS (dst_stats, src_stats) \
+#define COPY_RTNL_LINK_STATS(dst_stats, src_stats) \
   COPY_RTNL_LINK_VALUE (dst_stats, src_stats, rx_packets); \
   COPY_RTNL_LINK_VALUE (dst_stats, src_stats, tx_packets); \
   COPY_RTNL_LINK_VALUE (dst_stats, src_stats, rx_bytes); \
index 6c7aa05..5f1ca55 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * collectd - src/plugin.c
- * Copyright (C) 2005-2013  Florian octo Forster
+ * Copyright (C) 2005-2014  Florian octo Forster
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -2089,6 +2089,65 @@ int plugin_dispatch_values (value_list_t const *vl)
        return (0);
 }
 
+__attribute__((sentinel))
+int plugin_dispatch_multivalue (value_list_t const *template, /* {{{ */
+               _Bool store_percentage, ...)
+{
+       value_list_t *vl;
+       int failed = 0;
+       gauge_t sum = 0.0;
+       va_list ap;
+
+       assert (template->values_len == 1);
+
+       va_start (ap, store_percentage);
+       while (42)
+       {
+               char const *name;
+               gauge_t value;
+
+               name = va_arg (ap, char const *);
+               if (name == NULL)
+                       break;
+
+               value = va_arg (ap, gauge_t);
+               if (!isnan (value))
+                       sum += value;
+       }
+       va_end (ap);
+
+       vl = plugin_value_list_clone (template);
+       /* plugin_value_list_clone makes sure vl->time is set to non-zero. */
+       if (store_percentage)
+               sstrncpy (vl->type, "percent", sizeof (vl->type));
+
+       va_start (ap, store_percentage);
+       while (42)
+       {
+               char const *name;
+               int status;
+
+               /* Set the type instance. */
+               name = va_arg (ap, char const *);
+               if (name == NULL)
+                       break;
+               sstrncpy (vl->type_instance, name, sizeof (vl->type_instance));
+
+               /* Set the value. */
+               vl->values[0].gauge = va_arg (ap, gauge_t);
+               if (store_percentage)
+                       vl->values[0].gauge *= 100.0 / sum;
+
+               status = plugin_write_enqueue (vl);
+               if (status != 0)
+                       failed++;
+       }
+       va_end (ap);
+
+       plugin_value_list_free (vl);
+       return (failed);
+} /* }}} int plugin_dispatch_multivalue */
+
 int plugin_dispatch_notification (const notification_t *notif)
 {
        llentry_t *le;
index 8f0c6d8..924c842 100644 (file)
@@ -2,7 +2,7 @@
 #define PLUGIN_H
 /**
  * collectd - src/plugin.h
- * Copyright (C) 2005-2011  Florian octo Forster
+ * Copyright (C) 2005-2014  Florian octo Forster
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -328,6 +328,35 @@ int plugin_unregister_notification (const char *name);
  *              function.
  */
 int plugin_dispatch_values (value_list_t const *vl);
+
+/*
+ * NAME
+ *  plugin_dispatch_multivalue
+ *
+ * SYNOPSIS
+ *  plugin_dispatch_multivalue (vl, 1,
+ *                              "free", 42.0,
+ *                              "used", 58.0,
+ *                              NULL);
+ *
+ * DESCRIPTION
+ *  Takes a list of type instances and values and dispatches that in a batch,
+ *  making sure that all values have the same time stamp. If "store_percentage"
+ *  is set to true, the "type" is set to "percent" and a percentage is
+ *  calculated and dispatched, rather than the absolute values. Values that are
+ *  NaN are dispatched as NaN and will not influence the total.
+ *
+ *  The variadic arguments is a list of type_instance / gauge pairs, that are
+ *  interpreted as type "char const *" and "gauge_t". The last argument must be
+ *  a NULL pointer to signal end-of-list.
+ *
+ * RETURNS
+ *  The number of values it failed to dispatch (zero on success).
+ */
+__attribute__((sentinel))
+int plugin_dispatch_multivalue (value_list_t const *vl,
+               _Bool store_percentage, ...);
+
 int plugin_dispatch_missing (const value_list_t *vl);
 
 int plugin_dispatch_notification (const notification_t *notif);
index 85a8354..92be18f 100644 (file)
@@ -37,6 +37,7 @@
 #define REDIS_DEF_PORT    6379
 #define REDIS_DEF_TIMEOUT 2000
 #define MAX_REDIS_NODE_NAME 64
+#define MAX_REDIS_PASSWD_LENGTH 512
 
 /* Redis plugin configuration example:
  *
@@ -55,7 +56,7 @@ struct redis_node_s
 {
   char name[MAX_REDIS_NODE_NAME];
   char host[HOST_NAME_MAX];
-  char passwd[HOST_NAME_MAX];
+  char passwd[MAX_REDIS_PASSWD_LENGTH];
   int port;
   int timeout;
 
index ad81c89..2bb7c2a 100644 (file)
@@ -29,6 +29,8 @@
 #include <net-snmp/net-snmp-config.h>
 #include <net-snmp/net-snmp-includes.h>
 
+#include <fnmatch.h>
+
 /*
  * Private data structes
  */
@@ -50,7 +52,7 @@ struct data_definition_s
 {
   char *name; /* used to reference this from the `Collect' option */
   char *type; /* used to find the data_set */
-  int is_table;
+  _Bool is_table;
   instance_t instance;
   char *instance_prefix;
   oid_t *values;
@@ -58,6 +60,9 @@ struct data_definition_s
   double scale;
   double shift;
   struct data_definition_s *next;
+  char **ignores;
+  size_t ignores_len;
+  int invert_match;
 };
 typedef struct data_definition_s data_definition_t;
 
@@ -65,8 +70,22 @@ struct host_definition_s
 {
   char *name;
   char *address;
-  char *community;
   int version;
+
+  /* snmpv1/2 options */
+  char *community;
+
+  /* snmpv3 security options */
+  char *username;
+  oid *auth_protocol;
+  size_t auth_protocol_len;
+  char *auth_passphrase;
+  oid *priv_protocol;
+  size_t priv_protocol_len;
+  char *priv_passphrase;
+  int security_level;
+  char *context;
+
   void *sess_handle;
   c_complain_t complaint;
   cdtime_t interval;
@@ -183,6 +202,10 @@ static void csnmp_host_definition_destroy (void *arg) /* {{{ */
   sfree (hd->name);
   sfree (hd->address);
   sfree (hd->community);
+  sfree (hd->username);
+  sfree (hd->auth_passphrase);
+  sfree (hd->priv_passphrase);
+  sfree (hd->context);
   sfree (hd->data_list);
 
   sfree (hd);
@@ -197,16 +220,15 @@ static void csnmp_host_definition_destroy (void *arg) /* {{{ */
  *  csnmp_config
  *  +-> call_snmp_init_once
  *  +-> csnmp_config_add_data
- *  !   +-> csnmp_config_add_data_type
- *  !   +-> csnmp_config_add_data_table
  *  !   +-> csnmp_config_add_data_instance
  *  !   +-> csnmp_config_add_data_instance_prefix
  *  !   +-> csnmp_config_add_data_values
  *  +-> csnmp_config_add_host
- *      +-> csnmp_config_add_host_address
- *      +-> csnmp_config_add_host_community
  *      +-> csnmp_config_add_host_version
  *      +-> csnmp_config_add_host_collect
+ *      +-> csnmp_config_add_host_auth_protocol
+ *      +-> csnmp_config_add_host_priv_protocol
+ *      +-> csnmp_config_add_host_security_level
  */
 static void call_snmp_init_once (void)
 {
@@ -217,60 +239,31 @@ static void call_snmp_init_once (void)
   have_init = 1;
 } /* void call_snmp_init_once */
 
-static int csnmp_config_add_data_type (data_definition_t *dd, oconfig_item_t *ci)
-{
-  if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING))
-  {
-    WARNING ("snmp plugin: `Type' needs exactly one string argument.");
-    return (-1);
-  }
-
-  sfree (dd->type);
-  dd->type = strdup (ci->values[0].value.string);
-  if (dd->type == NULL)
-    return (-1);
-
-  return (0);
-} /* int csnmp_config_add_data_type */
-
-static int csnmp_config_add_data_table (data_definition_t *dd, oconfig_item_t *ci)
-{
-  if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN))
-  {
-    WARNING ("snmp plugin: `Table' needs exactly one boolean argument.");
-    return (-1);
-  }
-
-  dd->is_table = ci->values[0].value.boolean ? 1 : 0;
-
-  return (0);
-} /* int csnmp_config_add_data_table */
-
 static int csnmp_config_add_data_instance (data_definition_t *dd, oconfig_item_t *ci)
 {
-  if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING))
-  {
-    WARNING ("snmp plugin: `Instance' needs exactly one string argument.");
-    return (-1);
-  }
+  char buffer[DATA_MAX_NAME_LEN];
+  int status;
+
+  status = cf_util_get_string_buffer(ci, buffer, sizeof(buffer));
+  if (status != 0)
+    return status;
 
   if (dd->is_table)
   {
     /* Instance is an OID */
     dd->instance.oid.oid_len = MAX_OID_LEN;
 
-    if (!read_objid (ci->values[0].value.string,
+    if (!read_objid (buffer,
           dd->instance.oid.oid, &dd->instance.oid.oid_len))
     {
-      ERROR ("snmp plugin: read_objid (%s) failed.",
-          ci->values[0].value.string);
+      ERROR ("snmp plugin: read_objid (%s) failed.", buffer);
       return (-1);
     }
   }
   else
   {
     /* Instance is a simple string */
-    sstrncpy (dd->instance.string, ci->values[0].value.string,
+    sstrncpy (dd->instance.string, buffer,
         sizeof (dd->instance.string));
   }
 
@@ -280,11 +273,7 @@ static int csnmp_config_add_data_instance (data_definition_t *dd, oconfig_item_t
 static int csnmp_config_add_data_instance_prefix (data_definition_t *dd,
     oconfig_item_t *ci)
 {
-  if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING))
-  {
-    WARNING ("snmp plugin: `InstancePrefix' needs exactly one string argument.");
-    return (-1);
-  }
+  int status;
 
   if (!dd->is_table)
   {
@@ -293,12 +282,8 @@ static int csnmp_config_add_data_instance_prefix (data_definition_t *dd,
     return (-1);
   }
 
-  sfree (dd->instance_prefix);
-  dd->instance_prefix = strdup (ci->values[0].value.string);
-  if (dd->instance_prefix == NULL)
-    return (-1);
-
-  return (0);
+  status = cf_util_get_string(ci, &dd->instance_prefix);
+  return status;
 } /* int csnmp_config_add_data_instance_prefix */
 
 static int csnmp_config_add_data_values (data_definition_t *dd, oconfig_item_t *ci)
@@ -344,33 +329,49 @@ static int csnmp_config_add_data_values (data_definition_t *dd, oconfig_item_t *
   return (0);
 } /* int csnmp_config_add_data_instance */
 
-static int csnmp_config_add_data_shift (data_definition_t *dd, oconfig_item_t *ci)
+static int csnmp_config_add_data_blacklist(data_definition_t *dd, oconfig_item_t *ci)
 {
-  if ((ci->values_num != 1)
-      || (ci->values[0].type != OCONFIG_TYPE_NUMBER))
+  int i;
+
+  if (ci->values_num < 1)
+    return (0);
+
+  for (i = 0; i < ci->values_num; i++)
   {
-    WARNING ("snmp plugin: The `Shift' config option needs exactly one number argument.");
-    return (-1);
+    if (ci->values[i].type != OCONFIG_TYPE_STRING)
+    {
+      WARNING ("snmp plugin: `Ignore' needs only string argument.");
+      return (-1);
+    }
   }
 
-  dd->shift = ci->values[0].value.number;
+  dd->ignores_len = 0;
+  dd->ignores = NULL;
 
-  return (0);
-} /* int csnmp_config_add_data_shift */
+  for (i = 0; i < ci->values_num; ++i)
+  {
+    if (strarray_add(&(dd->ignores), &(dd->ignores_len), ci->values[i].value.string) != 0)
+    {
+      ERROR("snmp plugin: Can't allocate memory");
+      strarray_free(dd->ignores, dd->ignores_len);
+      return (ENOMEM); 
+    }
+  }
+  return 0;
+} /* int csnmp_config_add_data_blacklist */
 
-static int csnmp_config_add_data_scale (data_definition_t *dd, oconfig_item_t *ci)
+static int csnmp_config_add_data_blacklist_match_inverted(data_definition_t *dd, oconfig_item_t *ci)
 {
-  if ((ci->values_num != 1)
-      || (ci->values[0].type != OCONFIG_TYPE_NUMBER))
+  if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN))
   {
-    WARNING ("snmp plugin: The `Scale' config option needs exactly one number argument.");
+    WARNING ("snmp plugin: `InvertMatch' needs exactly one boolean argument.");
     return (-1);
   }
 
-  dd->scale = ci->values[0].value.number;
+  dd->invert_match = ci->values[0].value.boolean ? 1 : 0;
 
   return (0);
-} /* int csnmp_config_add_data_scale */
+} /* int csnmp_config_add_data_blacklist_match_inverted */
 
 static int csnmp_config_add_data (oconfig_item_t *ci)
 {
@@ -378,24 +379,18 @@ static int csnmp_config_add_data (oconfig_item_t *ci)
   int status = 0;
   int i;
 
-  if ((ci->values_num != 1)
-      || (ci->values[0].type != OCONFIG_TYPE_STRING))
-  {
-    WARNING ("snmp plugin: The `Data' config option needs exactly one string argument.");
-    return (-1);
-  }
-
   dd = (data_definition_t *) malloc (sizeof (data_definition_t));
   if (dd == NULL)
     return (-1);
   memset (dd, '\0', sizeof (data_definition_t));
 
-  dd->name = strdup (ci->values[0].value.string);
-  if (dd->name == NULL)
+  status = cf_util_get_string(ci, &dd->name);
+  if (status != 0)
   {
     free (dd);
     return (-1);
   }
+
   dd->scale = 1.0;
   dd->shift = 0.0;
 
@@ -405,9 +400,9 @@ static int csnmp_config_add_data (oconfig_item_t *ci)
     status = 0;
 
     if (strcasecmp ("Type", option->key) == 0)
-      status = csnmp_config_add_data_type (dd, option);
+      status = cf_util_get_string(option, &dd->type);
     else if (strcasecmp ("Table", option->key) == 0)
-      status = csnmp_config_add_data_table (dd, option);
+      status = cf_util_get_boolean(option, &dd->is_table);
     else if (strcasecmp ("Instance", option->key) == 0)
       status = csnmp_config_add_data_instance (dd, option);
     else if (strcasecmp ("InstancePrefix", option->key) == 0)
@@ -415,9 +410,13 @@ static int csnmp_config_add_data (oconfig_item_t *ci)
     else if (strcasecmp ("Values", option->key) == 0)
       status = csnmp_config_add_data_values (dd, option);
     else if (strcasecmp ("Shift", option->key) == 0)
-      status = csnmp_config_add_data_shift (dd, option);
+      status = cf_util_get_double(option, &dd->shift);
     else if (strcasecmp ("Scale", option->key) == 0)
-      status = csnmp_config_add_data_scale (dd, option);
+      status = cf_util_get_double(option, &dd->scale);
+    else if (strcasecmp ("Ignore", option->key) == 0)
+      status = csnmp_config_add_data_blacklist(dd, option);
+    else if (strcasecmp ("InvertMatch", option->key) == 0)
+      status = csnmp_config_add_data_blacklist_match_inverted(dd, option);
     else
     {
       WARNING ("snmp plugin: Option `%s' not allowed here.", option->key);
@@ -451,6 +450,7 @@ static int csnmp_config_add_data (oconfig_item_t *ci)
     sfree (dd->name);
     sfree (dd->instance_prefix);
     sfree (dd->values);
+    sfree (dd->ignores);
     sfree (dd);
     return (-1);
   }
@@ -472,50 +472,6 @@ static int csnmp_config_add_data (oconfig_item_t *ci)
   return (0);
 } /* int csnmp_config_add_data */
 
-static int csnmp_config_add_host_address (host_definition_t *hd, oconfig_item_t *ci)
-{
-  if ((ci->values_num != 1)
-      || (ci->values[0].type != OCONFIG_TYPE_STRING))
-  {
-    WARNING ("snmp plugin: The `Address' config option needs exactly one string argument.");
-    return (-1);
-  }
-
-  if (hd->address == NULL)
-    free (hd->address);
-
-  hd->address = strdup (ci->values[0].value.string);
-  if (hd->address == NULL)
-    return (-1);
-
-  DEBUG ("snmp plugin: host = %s; host->address = %s;",
-      hd->name, hd->address);
-
-  return (0);
-} /* int csnmp_config_add_host_address */
-
-static int csnmp_config_add_host_community (host_definition_t *hd, oconfig_item_t *ci)
-{
-  if ((ci->values_num != 1)
-      || (ci->values[0].type != OCONFIG_TYPE_STRING))
-  {
-    WARNING ("snmp plugin: The `Community' config option needs exactly one string argument.");
-    return (-1);
-  }
-
-  if (hd->community == NULL)
-    free (hd->community);
-
-  hd->community = strdup (ci->values[0].value.string);
-  if (hd->community == NULL)
-    return (-1);
-
-  DEBUG ("snmp plugin: host = %s; host->community = %s;",
-      hd->name, hd->community);
-
-  return (0);
-} /* int csnmp_config_add_host_community */
-
 static int csnmp_config_add_host_version (host_definition_t *hd, oconfig_item_t *ci)
 {
   int version;
@@ -528,9 +484,9 @@ static int csnmp_config_add_host_version (host_definition_t *hd, oconfig_item_t
   }
 
   version = (int) ci->values[0].value.number;
-  if ((version != 1) && (version != 2))
+  if ((version < 1) || (version > 3))
   {
-    WARNING ("snmp plugin: `Version' must either be `1' or `2'.");
+    WARNING ("snmp plugin: `Version' must either be `1', `2', or `3'.");
     return (-1);
   }
 
@@ -590,6 +546,92 @@ static int csnmp_config_add_host_collect (host_definition_t *host,
   return (0);
 } /* int csnmp_config_add_host_collect */
 
+static int csnmp_config_add_host_auth_protocol (host_definition_t *hd, oconfig_item_t *ci)
+{
+  char buffer[4];
+  int status;
+
+  status = cf_util_get_string_buffer(ci, buffer, sizeof(buffer));
+  if (status != 0)
+    return status;
+
+  if (strcasecmp("MD5", buffer) == 0) {
+    hd->auth_protocol = usmHMACMD5AuthProtocol;
+    hd->auth_protocol_len = sizeof(usmHMACMD5AuthProtocol)/sizeof(oid);
+  }
+  else if (strcasecmp("SHA", buffer) == 0) {
+    hd->auth_protocol = usmHMACSHA1AuthProtocol;
+    hd->auth_protocol_len = sizeof(usmHMACSHA1AuthProtocol)/sizeof(oid);
+  }
+  else
+  {
+    WARNING ("snmp plugin: The `AuthProtocol' config option must be `MD5' or `SHA'.");
+    return (-1);
+  }
+
+  DEBUG ("snmp plugin: host = %s; host->auth_protocol = %s;",
+      hd->name, hd->auth_protocol == usmHMACMD5AuthProtocol ? "MD5" : "SHA");
+
+  return (0);
+} /* int csnmp_config_add_host_auth_protocol */
+
+static int csnmp_config_add_host_priv_protocol (host_definition_t *hd, oconfig_item_t *ci)
+{
+  char buffer[4];
+  int status;
+
+  status = cf_util_get_string_buffer(ci, buffer, sizeof(buffer));
+  if (status != 0)
+    return status;
+
+  if (strcasecmp("AES", buffer) == 0)
+  {
+    hd->priv_protocol = usmAESPrivProtocol;
+    hd->priv_protocol_len = sizeof(usmAESPrivProtocol)/sizeof(oid);
+  }
+  else if (strcasecmp("DES", buffer) == 0) {
+    hd->priv_protocol = usmDESPrivProtocol;
+    hd->priv_protocol_len = sizeof(usmDESPrivProtocol)/sizeof(oid);
+  }
+  else
+  {
+    WARNING ("snmp plugin: The `PrivProtocol' config option must be `AES' or `DES'.");
+    return (-1);
+  }
+
+  DEBUG ("snmp plugin: host = %s; host->priv_protocol = %s;",
+      hd->name, hd->priv_protocol == usmAESPrivProtocol ? "AES" : "DES");
+
+  return (0);
+} /* int csnmp_config_add_host_priv_protocol */
+
+static int csnmp_config_add_host_security_level (host_definition_t *hd, oconfig_item_t *ci)
+{
+  char buffer[16];
+  int status;
+
+  status = cf_util_get_string_buffer(ci, buffer, sizeof(buffer));
+  if (status != 0)
+    return status;
+
+  if (strcasecmp("noAuthNoPriv", buffer) == 0)
+    hd->security_level = SNMP_SEC_LEVEL_NOAUTH;
+  else if (strcasecmp("authNoPriv", buffer) == 0)
+    hd->security_level = SNMP_SEC_LEVEL_AUTHNOPRIV;
+  else if (strcasecmp("authPriv", buffer) == 0)
+    hd->security_level = SNMP_SEC_LEVEL_AUTHPRIV;
+  else
+  {
+    WARNING ("snmp plugin: The `SecurityLevel' config option must be `noAuthNoPriv', `authNoPriv', or `authPriv'.");
+    return (-1);
+  }
+
+  DEBUG ("snmp plugin: host = %s; host->security_level = %d;",
+      hd->name, hd->security_level);
+
+  return (0);
+} /* int csnmp_config_add_host_security_level */
+
 static int csnmp_config_add_host (oconfig_item_t *ci)
 {
   host_definition_t *hd;
@@ -601,12 +643,6 @@ static int csnmp_config_add_host (oconfig_item_t *ci)
   user_data_t cb_data;
   struct timespec cb_interval;
 
-  if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING))
-  {
-    WARNING ("snmp plugin: `Host' needs exactly one string argument.");
-    return (-1);
-  }
-
   hd = (host_definition_t *) malloc (sizeof (host_definition_t));
   if (hd == NULL)
     return (-1);
@@ -614,12 +650,9 @@ static int csnmp_config_add_host (oconfig_item_t *ci)
   hd->version = 2;
   C_COMPLAIN_INIT (&hd->complaint);
 
-  hd->name = strdup (ci->values[0].value.string);
-  if (hd->name == NULL)
-  {
-    free (hd);
-    return (-1);
-  }
+  status = cf_util_get_string(ci, &hd->name);
+  if (status != 0)
+    return status;
 
   hd->sess_handle = NULL;
   hd->interval = 0;
@@ -630,15 +663,29 @@ static int csnmp_config_add_host (oconfig_item_t *ci)
     status = 0;
 
     if (strcasecmp ("Address", option->key) == 0)
-      status = csnmp_config_add_host_address (hd, option);
+      status = cf_util_get_string(option, &hd->address);
     else if (strcasecmp ("Community", option->key) == 0)
-      status = csnmp_config_add_host_community (hd, option);
+      status = cf_util_get_string(option, &hd->community);
     else if (strcasecmp ("Version", option->key) == 0)
       status = csnmp_config_add_host_version (hd, option);
     else if (strcasecmp ("Collect", option->key) == 0)
       csnmp_config_add_host_collect (hd, option);
     else if (strcasecmp ("Interval", option->key) == 0)
       cf_util_get_cdtime (option, &hd->interval);
+    else if (strcasecmp ("Username", option->key) == 0)
+      status = cf_util_get_string(option, &hd->username);
+    else if (strcasecmp ("AuthProtocol", option->key) == 0)
+      status = csnmp_config_add_host_auth_protocol (hd, option);
+    else if (strcasecmp ("PrivacyProtocol", option->key) == 0)
+      status = csnmp_config_add_host_priv_protocol (hd, option);
+    else if (strcasecmp ("AuthPassphrase", option->key) == 0)
+      status = cf_util_get_string(option, &hd->auth_passphrase);
+    else if (strcasecmp ("PrivacyPassphrase", option->key) == 0)
+      status = cf_util_get_string(option, &hd->priv_passphrase);
+    else if (strcasecmp ("SecurityLevel", option->key) == 0)
+      status = csnmp_config_add_host_security_level (hd, option);
+    else if (strcasecmp ("Context", option->key) == 0)
+      status = cf_util_get_string(option, &hd->context);
     else
     {
       WARNING ("snmp plugin: csnmp_config_add_host: Option `%s' not allowed here.", option->key);
@@ -657,12 +704,57 @@ static int csnmp_config_add_host (oconfig_item_t *ci)
       status = -1;
       break;
     }
-    if (hd->community == NULL)
+    if (hd->community == NULL && hd->version < 3)
     {
       WARNING ("snmp plugin: `Community' not given for host `%s'", hd->name);
       status = -1;
       break;
     }
+    if (hd->version == 3)
+    {
+      if (hd->username == NULL)
+      {
+        WARNING ("snmp plugin: `Username' not given for host `%s'", hd->name);
+        status = -1;
+        break;
+      }
+      if (hd->security_level == 0)
+      {
+        WARNING ("snmp plugin: `SecurityLevel' not given for host `%s'", hd->name);
+        status = -1;
+        break;
+      }
+      if (hd->security_level == SNMP_SEC_LEVEL_AUTHNOPRIV || hd->security_level == SNMP_SEC_LEVEL_AUTHPRIV)
+      {
+       if (hd->auth_protocol == NULL)
+       {
+         WARNING ("snmp plugin: `AuthProtocol' not given for host `%s'", hd->name);
+         status = -1;
+         break;
+       }
+       if (hd->auth_passphrase == NULL)
+       {
+         WARNING ("snmp plugin: `AuthPassphrase' not given for host `%s'", hd->name);
+         status = -1;
+         break;
+       }
+      }
+      if (hd->security_level == SNMP_SEC_LEVEL_AUTHPRIV)
+      {
+       if (hd->priv_protocol == NULL)
+       {
+         WARNING ("snmp plugin: `PrivacyProtocol' not given for host `%s'", hd->name);
+         status = -1;
+         break;
+       }
+       if (hd->priv_passphrase == NULL)
+       {
+         WARNING ("snmp plugin: `PrivacyPassphrase' not given for host `%s'", hd->name);
+         status = -1;
+         break;
+       }
+      }
+    }
 
     break;
   } /* while (status == 0) */
@@ -724,15 +816,75 @@ static int csnmp_config (oconfig_item_t *ci)
 static void csnmp_host_open_session (host_definition_t *host)
 {
   struct snmp_session sess;
+  int error;
 
   if (host->sess_handle != NULL)
     csnmp_host_close_session (host);
 
   snmp_sess_init (&sess);
   sess.peername = host->address;
-  sess.community = (u_char *) host->community;
-  sess.community_len = strlen (host->community);
-  sess.version = (host->version == 1) ? SNMP_VERSION_1 : SNMP_VERSION_2c;
+  switch (host->version)
+  {
+    case 1:
+      sess.version = SNMP_VERSION_1;
+      break;
+    case 3:
+      sess.version = SNMP_VERSION_3;
+      break;
+    default:
+      sess.version = SNMP_VERSION_2c;
+      break;
+  }
+
+  if (host->version == 3)
+  {
+    sess.securityName = host->username;
+    sess.securityNameLen = strlen (host->username);
+    sess.securityLevel = host->security_level;
+
+    if (sess.securityLevel == SNMP_SEC_LEVEL_AUTHNOPRIV || sess.securityLevel == SNMP_SEC_LEVEL_AUTHPRIV)
+    {
+      sess.securityAuthProto = host->auth_protocol;
+      sess.securityAuthProtoLen = host->auth_protocol_len;
+      sess.securityAuthKeyLen = USM_AUTH_KU_LEN;
+      error = generate_Ku (sess.securityAuthProto,
+           sess.securityAuthProtoLen,
+           (u_char *) host->auth_passphrase,
+           strlen(host->auth_passphrase),
+           sess.securityAuthKey,
+           &sess.securityAuthKeyLen);
+      if (error != SNMPERR_SUCCESS) {
+       ERROR ("snmp plugin: host %s: Error generating Ku from auth_passphrase. (Error %d)", host->name, error);
+      }
+    }
+
+    if (sess.securityLevel == SNMP_SEC_LEVEL_AUTHPRIV)
+    {
+      sess.securityPrivProto = host->priv_protocol;
+      sess.securityPrivProtoLen = host->priv_protocol_len;
+      sess.securityPrivKeyLen = USM_PRIV_KU_LEN;
+      error = generate_Ku (sess.securityAuthProto,
+           sess.securityAuthProtoLen,
+           (u_char *) host->priv_passphrase,
+           strlen(host->priv_passphrase),
+           sess.securityPrivKey,
+           &sess.securityPrivKeyLen);
+      if (error != SNMPERR_SUCCESS) {
+       ERROR ("snmp plugin: host %s: Error generating Ku from priv_passphrase. (Error %d)", host->name, error);
+      }
+    }
+
+    if (host->context != NULL)
+    {
+      sess.contextName = host->context;
+      sess.contextNameLen = strlen (host->context);
+    }
+  }
+  else /* SNMPv1/2 "authenticates" with community string */
+  {
+    sess.community = (u_char *) host->community;
+    sess.community_len = strlen (host->community);
+  }
 
   /* snmp_sess_open will copy the `struct snmp_session *'. */
   host->sess_handle = snmp_sess_open (&sess);
@@ -971,6 +1123,8 @@ static int csnmp_instance_list_add (csnmp_list_instances_t **head,
   struct variable_list *vb;
   oid_t vb_name;
   int status;
+  uint32_t i;
+  uint32_t is_matched;
 
   /* Set vb on the last variable */
   for (vb = res->variables;
@@ -1004,7 +1158,29 @@ static int csnmp_instance_list_add (csnmp_list_instances_t **head,
     char *ptr;
 
     csnmp_strvbcopy (il->instance, vb, sizeof (il->instance));
-
+    is_matched = 0;
+    for (i = 0; i < dd->ignores_len; i++)
+    {
+      status = fnmatch(dd->ignores[i], il->instance, 0);
+      if (status == 0)
+      {
+        if (dd->invert_match == 0)
+        {
+          sfree(il);
+          return 0;
+        }
+       else
+       {
+          is_matched = 1;
+         break;
+       }
+      }
+    }
+    if (dd->invert_match != 0 && is_matched == 0)
+    {
+      sfree(il);
+      return 0;
+    }
     for (ptr = il->instance; *ptr != '\0'; ptr++)
     {
       if ((*ptr > 0) && (*ptr < 32))
@@ -1655,6 +1831,7 @@ static int csnmp_shutdown (void)
     sfree (data_this->name);
     sfree (data_this->type);
     sfree (data_this->values);
+    sfree (data_this->ignores);
     sfree (data_this);
 
     data_this = data_next;
index 46d3534..508f9d5 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * collectd - src/swap.c
- * Copyright (C) 2005-2012  Florian octo Forster
+ * Copyright (C) 2005-2014  Florian octo Forster
  * Copyright (C) 2009       Stefan Völkel
  * Copyright (C) 2009       Manuel Sanmartin
  * Copyright (C) 2010       Aurélien Reynaud
@@ -97,48 +97,45 @@ int kvm_pagesize;
 
 #elif HAVE_PERFSTAT
 static int pagesize;
-static perfstat_memory_total_t pmemory;
 /*# endif HAVE_PERFSTAT */
 
 #else
 # error "No applicable input method."
 #endif /* HAVE_LIBSTATGRAB */
 
-static const char *config_keys[] =
-{
-       "ReportBytes",
-       "ReportByDevice"
-};
-static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
+static _Bool values_absolute = 1;
+static _Bool values_percentage = 0;
 
-static int swap_config (const char *key, const char *value) /* {{{ */
+static int swap_config (oconfig_item_t *ci) /* {{{ */
 {
-       if (strcasecmp ("ReportBytes", key) == 0)
+       int i;
+
+       for (i = 0; i < ci->children_num; i++)
        {
+               oconfig_item_t *child = ci->children + i;
+               if (strcasecmp ("ReportBytes", child->key) == 0)
 #if KERNEL_LINUX
-               report_bytes = IS_TRUE (value) ? 1 : 0;
+                       cf_util_get_boolean (child, &report_bytes);
 #else
-               WARNING ("swap plugin: The \"ReportBytes\" option is only "
-                               "valid under Linux. "
-                               "The option is going to be ignored.");
+                       WARNING ("swap plugin: The \"ReportBytes\" option "
+                                       "is only valid under Linux. "
+                                       "The option is going to be ignored.");
 #endif
-       }
-       else if (strcasecmp ("ReportByDevice", key) == 0)
-       {
+               else if (strcasecmp ("ReportByDevice", child->key) == 0)
 #if SWAP_HAVE_REPORT_BY_DEVICE
-               if (IS_TRUE (value))
-                       report_by_device = 1;
-               else
-                       report_by_device = 0;
+                       cf_util_get_boolean (child, &report_by_device);
 #else
-               WARNING ("swap plugin: The \"ReportByDevice\" option is not "
-                               "supported on this platform. "
-                               "The option is going to be ignored.");
+                       WARNING ("swap plugin: The \"ReportByDevice\" option "
+                                       "is not supported on this platform. "
+                                       "The option is going to be ignored.");
 #endif /* SWAP_HAVE_REPORT_BY_DEVICE */
-       }
-       else
-       {
-               return (-1);
+               else if (strcasecmp ("ValuesAbsolute", child->key) == 0)
+                       cf_util_get_boolean (child, &values_absolute);
+               else if (strcasecmp ("ValuesPercentage", child->key) == 0)
+                       cf_util_get_boolean (child, &values_percentage);
+               else
+                       WARNING ("swap plugin: Unknown config option: \"%s\"",
+                                       child->key);
        }
 
        return (0);
@@ -191,44 +188,50 @@ static int swap_init (void) /* {{{ */
        return (0);
 } /* }}} int swap_init */
 
-static void swap_submit (const char *plugin_instance, /* {{{ */
-               const char *type, const char *type_instance,
-               value_t value)
+static void swap_submit_usage (char const *plugin_instance, /* {{{ */
+               gauge_t used, gauge_t free,
+               char const *other_name, gauge_t other_value)
 {
+       value_t v[1];
        value_list_t vl = VALUE_LIST_INIT;
 
-       assert (type != NULL);
-
-       vl.values = &value;
-       vl.values_len = 1;
+       vl.values = v;
+       vl.values_len = STATIC_ARRAY_SIZE (v);
        sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "swap", sizeof (vl.plugin));
        if (plugin_instance != NULL)
-               sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
-       sstrncpy (vl.type, type, sizeof (vl.type));
-       if (type_instance != NULL)
-               sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
-
-       plugin_dispatch_values (&vl);
-} /* }}} void swap_submit_inst */
+               sstrncpy (vl.plugin_instance, plugin_instance,
+                               sizeof (vl.plugin_instance));
+       sstrncpy (vl.type, "swap", sizeof (vl.type));
+
+       if (values_absolute)
+               plugin_dispatch_multivalue (&vl, 0,
+                               "used", used, "free", free,
+                               other_name, other_value, NULL);
+       if (values_percentage)
+               plugin_dispatch_multivalue (&vl, 1,
+                               "used", used, "free", free,
+                               other_name, other_value, NULL);
+} /* }}} void swap_submit_usage */
 
-static void swap_submit_gauge (const char *plugin_instance, /* {{{ */
-               const char *type_instance, gauge_t value)
+#if KERNEL_LINUX || HAVE_PERFSTAT
+__attribute__((nonnull(1)))
+static void swap_submit_derive (char const *type_instance, /* {{{ */
+               derive_t value)
 {
-       value_t v;
+       value_list_t vl = VALUE_LIST_INIT;
+       value_t v[1];
 
-       v.gauge = value;
-       swap_submit (plugin_instance, "swap", type_instance, v);
-} /* }}} void swap_submit_gauge */
+       v[0].derive = value;
 
-#if KERNEL_LINUX || HAVE_PERFSTAT
-static void swap_submit_derive (const char *plugin_instance, /* {{{ */
-               const char *type_instance, derive_t value)
-{
-       value_t v;
+       vl.values = v;
+       vl.values_len = STATIC_ARRAY_SIZE (v);
+       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+       sstrncpy (vl.plugin, "swap", sizeof (vl.plugin));
+       sstrncpy (vl.type, "swap_io", sizeof (vl.type));
+       sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
 
-       v.derive = value;
-       swap_submit (plugin_instance, "swap_io", type_instance, v);
+       plugin_dispatch_values (&vl);
 } /* }}} void swap_submit_derive */
 #endif
 
@@ -254,9 +257,8 @@ static int swap_read_separate (void) /* {{{ */
                char *endptr;
 
                char path[PATH_MAX];
-               gauge_t size;
+               gauge_t total;
                gauge_t used;
-               gauge_t free;
 
                numfields = strsplit (buffer, fields, STATIC_ARRAY_SIZE (fields));
                if (numfields != 5)
@@ -267,7 +269,7 @@ static int swap_read_separate (void) /* {{{ */
 
                errno = 0;
                endptr = NULL;
-               size = strtod (fields[2], &endptr);
+               total = strtod (fields[2], &endptr);
                if ((endptr == fields[2]) || (errno != 0))
                        continue;
 
@@ -277,13 +279,10 @@ static int swap_read_separate (void) /* {{{ */
                if ((endptr == fields[3]) || (errno != 0))
                        continue;
 
-               if (size < used)
+               if (total < used)
                        continue;
 
-               free = size - used;
-
-               swap_submit_gauge (path, "used", used);
-               swap_submit_gauge (path, "free", free);
+               swap_submit_usage (path, used, total - used, NULL, NAN);
        }
 
        fclose (fh);
@@ -349,10 +348,7 @@ static int swap_read_combined (void) /* {{{ */
 
        swap_used = swap_total - (swap_free + swap_cached);
 
-       swap_submit_gauge (NULL, "used",   1024.0 * swap_used);
-       swap_submit_gauge (NULL, "free",   1024.0 * swap_free);
-       swap_submit_gauge (NULL, "cached", 1024.0 * swap_cached);
-
+       swap_submit_usage (NULL, swap_used, swap_free, "cached", swap_cached);
        return (0);
 } /* }}} int swap_read_combined */
 
@@ -430,8 +426,8 @@ static int swap_read_io (void) /* {{{ */
                swap_out = swap_out * pagesize;
        }
 
-       swap_submit_derive (NULL, "in",  swap_in);
-       swap_submit_derive (NULL, "out", swap_out);
+       swap_submit_derive ("in",  swap_in);
+       swap_submit_derive ("out", swap_out);
 
        return (0);
 } /* }}} int swap_read_io */
@@ -462,9 +458,9 @@ static int swap_read (void) /* {{{ */
 /* kstat-based read function */
 static int swap_read_kstat (void) /* {{{ */
 {
-       derive_t swap_alloc;
-       derive_t swap_resv;
-       derive_t swap_avail;
+       gauge_t swap_alloc;
+       gauge_t swap_resv;
+       gauge_t swap_avail;
 
        struct anoninfo ai;
 
@@ -497,15 +493,11 @@ static int swap_read_kstat (void) /* {{{ */
         * swap_alloc = pagesize * ( ai.ani_max - ai.ani_free );
         * can suffer from a 32bit overflow.
         */
-       swap_alloc  = (derive_t) ((ai.ani_max - ai.ani_free) * pagesize);
-       swap_resv   = (derive_t) ((ai.ani_resv + ai.ani_free - ai.ani_max)
-                       * pagesize);
-       swap_avail  = (derive_t) ((ai.ani_max - ai.ani_resv) * pagesize);
-
-       swap_submit_gauge (NULL, "used", swap_alloc);
-       swap_submit_gauge (NULL, "free", swap_avail);
-       swap_submit_gauge (NULL, "reserved", swap_resv);
+       swap_alloc = (gauge_t) ((ai.ani_max - ai.ani_free) * pagesize);
+       swap_resv  = (gauge_t) ((ai.ani_resv + ai.ani_free - ai.ani_max) * pagesize);
+       swap_avail = (gauge_t) ((ai.ani_max - ai.ani_resv) * pagesize);
 
+       swap_submit_usage (NULL, swap_alloc, swap_avail, "reserved", swap_resv);
        return (0);
 } /* }}} int swap_read_kstat */
 /* #endif 0 && HAVE_LIBKSTAT */
@@ -520,8 +512,8 @@ static int swap_read (void) /* {{{ */
         int status;
         int i;
 
-        derive_t avail = 0;
-        derive_t total = 0;
+        gauge_t avail = 0;
+        gauge_t total = 0;
 
         swap_num = swapctl (SC_GETNSWP, NULL);
         if (swap_num < 0)
@@ -584,14 +576,14 @@ static int swap_read (void) /* {{{ */
         for (i = 0; i < swap_num; i++)
         {
                char path[PATH_MAX];
-               derive_t this_total;
-               derive_t this_avail;
+               gauge_t this_total;
+               gauge_t this_avail;
 
                 if ((s->swt_ent[i].ste_flags & ST_INDEL) != 0)
                         continue;
 
-               this_total = ((derive_t) s->swt_ent[i].ste_pages) * pagesize;
-               this_avail = ((derive_t) s->swt_ent[i].ste_free)  * pagesize;
+               this_total = (gauge_t) (s->swt_ent[i].ste_pages * pagesize);
+               this_avail = (gauge_t) (s->swt_ent[i].ste_free  * pagesize);
 
                /* Shortcut for the "combined" setting (default) */
                if (!report_by_device)
@@ -604,27 +596,23 @@ static int swap_read (void) /* {{{ */
                sstrncpy (path, s->swt_ent[i].ste_path, sizeof (path));
                escape_slashes (path, sizeof (path));
 
-               swap_submit_gauge (path, "used", (gauge_t) (this_total - this_avail));
-               swap_submit_gauge (path, "free", (gauge_t) this_avail);
+               swap_submit_usage (path, this_total - this_avail, this_avail,
+                               NULL, NAN);
         } /* for (swap_num) */
 
         if (total < avail)
         {
-                ERROR ("swap plugin: Total swap space (%"PRIi64") "
-                                "is less than free swap space (%"PRIi64").",
+                ERROR ("swap plugin: Total swap space (%g) is less than free swap space (%g).",
                                 total, avail);
                sfree (s_paths);
                 sfree (s);
                 return (-1);
         }
 
-       /* If the "separate" option was specified (report_by_device == 2), all
+       /* If the "separate" option was specified (report_by_device == 1), all
         * values have already been dispatched from within the loop. */
        if (!report_by_device)
-       {
-               swap_submit_gauge (NULL, "used", (gauge_t) (total - avail));
-               swap_submit_gauge (NULL, "free", (gauge_t) avail);
-       }
+               swap_submit_usage (NULL, total - avail, avail, NULL, NAN);
 
        sfree (s_paths);
         sfree (s);
@@ -640,8 +628,8 @@ static int swap_read (void) /* {{{ */
        int status;
        int i;
 
-       derive_t used  = 0;
-       derive_t total = 0;
+       gauge_t used  = 0;
+       gauge_t total = 0;
 
        swap_num = swapctl (SWAP_NSWAP, NULL, 0);
        if (swap_num < 0)
@@ -670,35 +658,32 @@ static int swap_read (void) /* {{{ */
        }
 
 #if defined(DEV_BSIZE) && (DEV_BSIZE > 0)
-# define C_SWAP_BLOCK_SIZE ((derive_t) DEV_BSIZE)
+# define C_SWAP_BLOCK_SIZE ((gauge_t) DEV_BSIZE)
 #else
-# define C_SWAP_BLOCK_SIZE ((derive_t) 512)
+# define C_SWAP_BLOCK_SIZE 512.0
 #endif
 
+       /* TODO: Report per-device stats. The path name is available from
+        * swap_entries[i].se_path */
        for (i = 0; i < swap_num; i++)
        {
                if ((swap_entries[i].se_flags & SWF_ENABLE) == 0)
                        continue;
 
-               used  += ((derive_t) swap_entries[i].se_inuse)
-                       * C_SWAP_BLOCK_SIZE;
-               total += ((derive_t) swap_entries[i].se_nblks)
-                       * C_SWAP_BLOCK_SIZE;
+               used  += ((gauge_t) swap_entries[i].se_inuse) * C_SWAP_BLOCK_SIZE;
+               total += ((gauge_t) swap_entries[i].se_nblks) * C_SWAP_BLOCK_SIZE;
        }
 
        if (total < used)
        {
-               ERROR ("swap plugin: Total swap space (%"PRIu64") "
-                               "is less than used swap space (%"PRIu64").",
+               ERROR ("swap plugin: Total swap space (%g) is less than used swap space (%g).",
                                total, used);
                return (-1);
        }
 
-       swap_submit_gauge (NULL, "used", (gauge_t) used);
-       swap_submit_gauge (NULL, "free", (gauge_t) (total - used));
+       swap_submit_usage (NULL, used, total - used, NULL, NAN);
 
        sfree (swap_entries);
-
        return (0);
 } /* }}} int swap_read */
 /* #endif HAVE_SWAPCTL && HAVE_SWAPCTL_THREE_ARGS */
@@ -721,8 +706,9 @@ static int swap_read (void) /* {{{ */
                return (-1);
 
        /* The returned values are bytes. */
-       swap_submit_gauge (NULL, "used", (gauge_t) sw_usage.xsu_used);
-       swap_submit_gauge (NULL, "free", (gauge_t) sw_usage.xsu_avail);
+       swap_submit_usage (NULL,
+                       (gauge_t) sw_usage.xsu_used, (gauge_t) sw_usage.xsu_avail,
+                       NULL, NAN);
 
        return (0);
 } /* }}} int swap_read */
@@ -734,9 +720,8 @@ static int swap_read (void) /* {{{ */
        struct kvm_swap data_s;
        int             status;
 
-       derive_t used;
-       derive_t free;
-       derive_t total;
+       gauge_t used;
+       gauge_t total;
 
        if (kvm_obj == NULL)
                return (-1);
@@ -746,16 +731,13 @@ static int swap_read (void) /* {{{ */
        if (status == -1)
                return (-1);
 
-       total = (derive_t) data_s.ksw_total;
-       used  = (derive_t) data_s.ksw_used;
+       total = (gauge_t) data_s.ksw_total;
+       used  = (gauge_t) data_s.ksw_used;
 
-       total *= (derive_t) kvm_pagesize;
-       used  *= (derive_t) kvm_pagesize;
+       total *= (gauge_t) kvm_pagesize;
+       used  *= (gauge_t) kvm_pagesize;
 
-       free = total - used;
-
-       swap_submit_gauge (NULL, "used", (gauge_t) used);
-       swap_submit_gauge (NULL, "free", (gauge_t) free);
+       swap_submit_usage (NULL, used, total - used, NULL, NAN);
 
        return (0);
 } /* }}} int swap_read */
@@ -767,12 +749,11 @@ static int swap_read (void) /* {{{ */
        sg_swap_stats *swap;
 
        swap = sg_get_swap_stats ();
-
        if (swap == NULL)
                return (-1);
 
-       swap_submit_gauge (NULL, "used", (gauge_t) swap->used);
-       swap_submit_gauge (NULL, "free", (gauge_t) swap->free);
+       swap_submit_usage (NULL, (gauge_t) swap->used, (gauge_t) swap->free,
+                       NULL, NAN);
 
        return (0);
 } /* }}} int swap_read */
@@ -781,19 +762,30 @@ static int swap_read (void) /* {{{ */
 #elif HAVE_PERFSTAT
 static int swap_read (void) /* {{{ */
 {
-        if(perfstat_memory_total(NULL, &pmemory, sizeof(perfstat_memory_total_t), 1) < 0)
+       perfstat_memory_total_t pmemory;
+       int status;
+
+       gauge_t total;
+       gauge_t free;
+       gauge_t reserved;
+
+       memset (&pmemory, 0, sizeof (pmemory));
+        status = perfstat_memory_total (NULL, &pmemory, sizeof(perfstat_memory_total_t), 1);
+       if (status < 0)
        {
                 char errbuf[1024];
-                WARNING ("memory plugin: perfstat_memory_total failed: %s",
+                WARNING ("swap plugin: perfstat_memory_total failed: %s",
                         sstrerror (errno, errbuf, sizeof (errbuf)));
                 return (-1);
         }
 
-       swap_submit_gauge (NULL, "used", (gauge_t) (pmemory.pgsp_total - pmemory.pgsp_free) * pagesize);
-       swap_submit_gauge (NULL, "free", (gauge_t) pmemory.pgsp_free * pagesize );
-       swap_submit_gauge (NULL, "reserved", (gauge_t) pmemory.pgsp_rsvd * pagesize);
-       swap_submit_derive (NULL, "in",  (derive_t) pmemory.pgspins * pagesize);
-       swap_submit_derive (NULL, "out", (derive_t) pmemory.pgspouts * pagesize);
+       total    = (gauge_t) (pmemory.pgsp_total * pagesize);
+       free     = (gauge_t) (pmemory.pgsp_free * pagesize);
+       reserved = (gauge_t) (pmemory.pgsp_rsvd * pagesize);
+
+       swap_submit_usage (NULL, total - free, free, "reserved", reserved);
+       swap_submit_derive ("in",  (derive_t) pmemory.pgspins * pagesize);
+       swap_submit_derive ("out", (derive_t) pmemory.pgspouts * pagesize);
 
        return (0);
 } /* }}} int swap_read */
@@ -801,8 +793,7 @@ static int swap_read (void) /* {{{ */
 
 void module_register (void)
 {
-       plugin_register_config ("swap", swap_config,
-                       config_keys, config_keys_num);
+       plugin_register_complex_config ("swap", swap_config);
        plugin_register_init ("swap", swap_init);
        plugin_register_read ("swap", swap_read);
 } /* void module_register */
index 9a9affb..1d7af5c 100644 (file)
@@ -296,8 +296,8 @@ static int tr_create (const oconfig_item_t *ci, void **user_data) /* {{{ */
         /* && (data->type == NULL) */
         && (data->type_instance == NULL))
     {
-      ERROR ("Target `replace': You need to set at lease one of `Host', "
-          "`Plugin', `PluginInstance', `Type', or `TypeInstance'.");
+      ERROR ("Target `replace': You need to set at least one of `Host', "
+          "`Plugin', `PluginInstance' or `TypeInstance'.");
       status = -1;
     }
 
index 8a014c3..2fb9cee 100644 (file)
@@ -171,8 +171,8 @@ static int ts_create (const oconfig_item_t *ci, void **user_data) /* {{{ */
         /* && (data->type == NULL) */
         && (data->type_instance == NULL))
     {
-      ERROR ("Target `set': You need to set at lease one of `Host', "
-          "`Plugin', `PluginInstance', `Type', or `TypeInstance'.");
+      ERROR ("Target `set': You need to set at least one of `Host', "
+          "`Plugin', `PluginInstance' or `TypeInstance'.");
       status = -1;
     }
 
index 3a5e207..97cc4cc 100644 (file)
@@ -13,7 +13,7 @@ cache_eviction                value:DERIVE:0:U
 cache_operation                value:DERIVE:0:U
 cache_ratio            value:GAUGE:0:100
 cache_result           value:DERIVE:0:U
-cache_size             value:GAUGE:0:4294967295
+cache_size             value:GAUGE:0:U
 charge                 value:GAUGE:0:U
 compression_ratio      value:GAUGE:0:2
 compression            uncompressed:DERIVE:0:U, compressed:DERIVE:0:U
@@ -61,6 +61,7 @@ entropy                       value:GAUGE:0:4294967295
 fanspeed               value:GAUGE:0:U
 file_size              value:GAUGE:0:U
 files                  value:GAUGE:0:U
+flow                   value:GAUGE:0:U
 fork_rate              value:DERIVE:0:U
 frequency_offset       value:GAUGE:-1000000:1000000
 frequency              value:GAUGE:0:U
index fa6e660..05386db 100644 (file)
@@ -68,7 +68,9 @@ static pthread_mutex_t cache_lock = PTHREAD_MUTEX_INITIALIZER;
 
 static int cache_compare (const cache_entry_t *a, const cache_entry_t *b)
 {
+#if COLLECT_DEBUG
   assert ((a != NULL) && (b != NULL));
+#endif
   return (strcmp (a->name, b->name));
 } /* int cache_compare */
 
index 8351201..c9516b4 100644 (file)
@@ -29,6 +29,8 @@
 #include "utils_cache.h"
 #include "utils_parse_option.h"
 
+#define GRAPHITE_FORBIDDEN " \t\"\\:!/\n\r"
+
 /* Utils functions to format data sets in graphite format.
  * Largely taken from write_graphite.c as it remains the same formatting */
 
@@ -169,6 +171,18 @@ static int gr_format_name (char *ret, int ret_len,
     return (0);
 }
 
+static void escape_graphite_string (char *buffer, char escape_char)
+{
+       char *head;
+
+       assert (strchr(GRAPHITE_FORBIDDEN, escape_char) == NULL);
+
+       for (head = buffer + strcspn(buffer, GRAPHITE_FORBIDDEN);
+            *head != '\0';
+            head += strcspn(head, GRAPHITE_FORBIDDEN))
+               *head = escape_char;
+}
+
 int format_graphite (char *buffer, size_t buffer_size,
     data_set_t const *ds, value_list_t const *vl,
     char const *prefix, char const *postfix, char const escape_char,
@@ -204,7 +218,7 @@ int format_graphite (char *buffer, size_t buffer_size,
             return (status);
         }
 
-        escape_string (key, sizeof (key));
+        escape_graphite_string (key, escape_char);
         /* Convert the values to an ASCII representation and put that into
          * `values'. */
         status = gr_format_values (values, sizeof (values), i, ds, vl, rates);
index cae3706..3cede01 100644 (file)
@@ -752,9 +752,6 @@ cu_mount_getoptionvalue(char *line, char *keyword)
                r += strlen(keyword);
                p = strchr(r, ',');
                if(p == NULL) {
-                       if(strlen(r) == 0) {
-                               return NULL;
-                       }
                        return sstrdup(r);
                } else {
                        char *m;
index 6124d33..c17b7f3 100644 (file)
@@ -67,7 +67,7 @@
 #endif
 
 #ifndef WG_DEFAULT_PROTOCOL
-# define WG_DEFAULT_PROTOCOL "udp"
+# define WG_DEFAULT_PROTOCOL "tcp"
 #endif
 
 #ifndef WG_DEFAULT_LOG_SEND_ERRORS
@@ -128,13 +128,17 @@ static int wg_send_buffer (struct wg_callback *cb)
     ssize_t status = 0;
 
     status = swrite (cb->sock_fd, cb->send_buf, strlen (cb->send_buf));
-    if (cb->log_send_errors && status < 0)
+    if (status < 0)
     {
-        char errbuf[1024];
-        ERROR ("write_graphite plugin: send to %s:%s (%s) failed with status %zi (%s)",
-                cb->node, cb->service, cb->protocol,
-                status, sstrerror (errno, errbuf, sizeof (errbuf)));
+        const char *protocol = cb->protocol ? cb->protocol : WG_DEFAULT_PROTOCOL;
 
+        if (cb->log_send_errors)
+        {
+            char errbuf[1024];
+            ERROR ("write_graphite plugin: send to %s:%s (%s) failed with status %zi (%s)",
+                    cb->node, cb->service, protocol,
+                    status, sstrerror (errno, errbuf, sizeof (errbuf)));
+        }
 
         close (cb->sock_fd);
         cb->sock_fd = -1;
index 3a7738f..e85e943 100644 (file)
@@ -108,8 +108,7 @@ static void riemann_msg_protobuf_free (Msg *msg) /* {{{ */
 } /* }}} void riemann_msg_protobuf_free */
 
 /* host->lock must be held when calling this function. */
-static int
-riemann_connect(struct riemann_host *host)
+static int riemann_connect(struct riemann_host *host) /* {{{ */
 {
        int                      e;
        struct addrinfo         *ai, *res, hints;
@@ -164,11 +163,10 @@ riemann_connect(struct riemann_host *host)
                return -1;
        }
        return 0;
-}
+} /* }}} int riemann_connect */
 
 /* host->lock must be held when calling this function. */
-static int
-riemann_disconnect (struct riemann_host *host)
+static int riemann_disconnect (struct riemann_host *host) /* {{{ */
 {
        if ((host->flags & F_CONNECT) == 0)
                return (0);
@@ -178,17 +176,15 @@ riemann_disconnect (struct riemann_host *host)
        host->flags &= ~F_CONNECT;
 
        return (0);
-}
+} /* }}} int riemann_disconnect */
 
-static inline int
-riemann_send_msg(struct riemann_host *host, const Msg *msg)
+static int riemann_send_msg (struct riemann_host *host, const Msg *msg) /* {{{ */
 {
        int status = 0;
        u_char *buffer = NULL;
        size_t  buffer_len;
 
        status = riemann_connect (host);
-
        if (status != 0)
                return status;
 
@@ -198,12 +194,10 @@ riemann_send_msg(struct riemann_host *host, const Msg *msg)
                buffer_len += 4;
 
        buffer = malloc (buffer_len);
-
        if (buffer == NULL) {
                ERROR ("write_riemann plugin: malloc failed.");
                return ENOMEM;
        }
-
        memset (buffer, 0, buffer_len);
 
        if (host->use_tcp)
@@ -218,26 +212,22 @@ riemann_send_msg(struct riemann_host *host, const Msg *msg)
        }
 
        status = (int) swrite (host->s, buffer, buffer_len);
-
        if (status != 0)
        {
                char errbuf[1024];
-
                ERROR ("write_riemann plugin: Sending to Riemann at %s:%s failed: %s",
                                (host->node != NULL) ? host->node : RIEMANN_HOST,
                                (host->service != NULL) ? host->service : RIEMANN_PORT,
                                sstrerror (errno, errbuf, sizeof (errbuf)));
-
                sfree (buffer);
                return -1;
        }
 
        sfree (buffer);
        return 0;
-}
+} /* }}} int riemann_send_msg */
 
-static inline int
-riemann_recv_ack(struct riemann_host *host)
+static int riemann_recv_ack(struct riemann_host *host) /* {{{ */
 {
        int status = 0;
        Msg *msg = NULL;
@@ -277,21 +267,19 @@ riemann_recv_ack(struct riemann_host *host)
 
        msg__free_unpacked (msg, NULL);
        return 0;
-}
+} /* }}} int riemann_recv_ack */
 
 /**
  * Function to send messages (Msg) to riemann.
  *
  * Acquires the host lock, disconnects on errors.
  */
-static int
-riemann_send(struct riemann_host *host, Msg const *msg)
+static int riemann_send(struct riemann_host *host, Msg const *msg) /* {{{ */
 {
        int status = 0;
        pthread_mutex_lock (&host->lock);
 
        status = riemann_send_msg(host, msg);
-
        if (status != 0) {
                riemann_disconnect (host);
                pthread_mutex_unlock (&host->lock);
@@ -315,7 +303,7 @@ riemann_send(struct riemann_host *host, Msg const *msg)
 
        pthread_mutex_unlock (&host->lock);
        return 0;
-}
+} /* }}} int riemann_send */
 
 static int riemann_event_add_tag (Event *event, char const *tag) /* {{{ */
 {
@@ -437,6 +425,9 @@ static Msg *riemann_notification_to_protobuf (struct riemann_host *host, /* {{{
                        n->type, n->type_instance);
        event->service = strdup (&service_buffer[1]);
 
+       if (n->message[0] != 0)
+               riemann_event_add_attribute (event, "description", n->message);
+
        /* Pull in values from threshold and add extra attributes */
        for (meta = n->meta; meta != NULL; meta = meta->next)
        {
@@ -620,8 +611,7 @@ static Msg *riemann_value_list_to_protobuf (struct riemann_host const *host, /*
        return (msg);
 } /* }}} Msg *riemann_value_list_to_protobuf */
 
-static int
-riemann_notification(const notification_t *n, user_data_t *ud)
+static int riemann_notification(const notification_t *n, user_data_t *ud) /* {{{ */
 {
        int                      status;
        struct riemann_host     *host = ud->data;
@@ -640,8 +630,7 @@ riemann_notification(const notification_t *n, user_data_t *ud)
        return (status);
 } /* }}} int riemann_notification */
 
-static int
-riemann_write(const data_set_t *ds,
+static int riemann_write(const data_set_t *ds, /* {{{ */
              const value_list_t *vl,
              user_data_t *ud)
 {
@@ -660,10 +649,9 @@ riemann_write(const data_set_t *ds,
 
        riemann_msg_protobuf_free (msg);
        return status;
-}
+} /* }}} int riemann_write */
 
-static void
-riemann_free(void *p)
+static void riemann_free(void *p) /* {{{ */
 {
        struct riemann_host     *host = p;
 
@@ -684,10 +672,9 @@ riemann_free(void *p)
        sfree(host->service);
        pthread_mutex_destroy (&host->lock);
        sfree(host);
-}
+} /* }}} void riemann_free */
 
-static int
-riemann_config_node(oconfig_item_t *ci)
+static int riemann_config_node(oconfig_item_t *ci) /* {{{ */
 {
        struct riemann_host     *host = NULL;
        int                      status = 0;
@@ -843,10 +830,9 @@ riemann_config_node(oconfig_item_t *ci)
        pthread_mutex_unlock (&host->lock);
 
        return status;
-}
+} /* }}} int riemann_config_node */
 
-static int
-riemann_config(oconfig_item_t *ci)
+static int riemann_config(oconfig_item_t *ci) /* {{{ */
 {
        int              i;
        oconfig_item_t  *child;
@@ -899,10 +885,9 @@ riemann_config(oconfig_item_t *ci)
                }
        }
        return (0);
-}
+} /* }}} int riemann_config */
 
-void
-module_register(void)
+void module_register(void)
 {
        plugin_register_complex_config ("write_riemann", riemann_config);
 }
index 2edba6d..96ffc54 100644 (file)
@@ -99,7 +99,7 @@ static int za_read_derive (kstat_t *ksp, const char *kstat_value,
   tmp = get_zfs_value (ksp, (char *)kstat_value);
   if (tmp == -1LL)
   {
-    ERROR ("zfs_arc plugin: Reading kstat value \"%s\" failed.", kstat_value);
+    WARNING ("zfs_arc plugin: Reading kstat value \"%s\" failed.", kstat_value);
     return (-1);
   }
 
@@ -117,7 +117,7 @@ static int za_read_gauge (kstat_t *ksp, const char *kstat_value,
   tmp = get_zfs_value (ksp, (char *)kstat_value);
   if (tmp == -1LL)
   {
-    ERROR ("zfs_arc plugin: Reading kstat value \"%s\" failed.", kstat_value);
+    WARNING ("zfs_arc plugin: Reading kstat value \"%s\" failed.", kstat_value);
     return (-1);
   }
 
@@ -161,9 +161,11 @@ static int za_read (void)
        za_read_gauge (ksp, "l2_size", "cache_size", "L2");
 
        /* Operations */
-       za_read_derive (ksp, "allocated","cache_operation", "allocated");
        za_read_derive (ksp, "deleted",  "cache_operation", "deleted");
+#if __FreeBSD__
+       za_read_derive (ksp, "allocated","cache_operation", "allocated");
        za_read_derive (ksp, "stolen",   "cache_operation", "stolen");
+#endif
 
        /* Issue indicators */
        za_read_derive (ksp, "mutex_miss", "mutex_operations", "miss");