Merge branch 'collectd-5.4' into collectd-5.5
authorMarc Fournier <marc.fournier@camptocamp.com>
Fri, 11 Sep 2015 21:21:49 +0000 (23:21 +0200)
committerMarc Fournier <marc.fournier@camptocamp.com>
Fri, 11 Sep 2015 21:21:49 +0000 (23:21 +0200)
1  2 
configure.ac
src/snmp.c

diff --combined configure.ac
@@@ -1,6 -1,6 +1,6 @@@
  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_SRCDIR(src/)
  AC_CONFIG_HEADERS(src/config.h)
  AC_CONFIG_AUX_DIR([libltdl/config])
  
@@@ -77,11 -77,9 +77,11 @@@ case $host_os i
        ac_system="Solaris"
        ;;
        *darwin*)
 +      AC_DEFINE([KERNEL_DARWIN], 1, [True if program is to be compiled for a Darwin kernel])
        ac_system="Darwin"
        ;;
        *openbsd*)
 +      AC_DEFINE([KERNEL_OPENBSD], 1, [True if program is to be compiled for an OpenBSD kernel])
        ac_system="OpenBSD"
        ;;
        *aix*)
  esac
  AC_MSG_RESULT([$ac_system])
  
 +AM_CONDITIONAL([BUILD_LINUX],[test "x$ac_system" = "xLinux"])
 +AM_CONDITIONAL([BUILD_SOLARIS],[test "x$ac_system" = "xSolaris"])
 +AM_CONDITIONAL([BUILD_DARWIN],[test "x$ac_system" = "xDarwin"])
 +AM_CONDITIONAL([BUILD_OPENBSD],[test "x$ac_system" = "xOpenBSD"])
 +AM_CONDITIONAL([BUILD_AIX],[test "x$ac_system" = "xAIX"])
 +AM_CONDITIONAL([BUILD_FREEBSD],[test "x$ac_system" = "xFreeBSD"])
 +
  if test "x$ac_system" = "xLinux"
  then
        AC_ARG_VAR([KERNEL_DIR], [path to Linux kernel sources])
@@@ -120,20 -111,7 +120,20 @@@ 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.])
 +
 +      AC_MSG_CHECKING([whether compiler builds 64bit binaries])
 +      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
 +                         #ifndef _LP64
 +                         # error "Compiler not in 64bit mode."
 +                         #endif
 +                         ])],
 +                         [AC_MSG_RESULT([yes])],
 +                         [
 +                          AC_MSG_RESULT([no])
 +                          AC_MSG_NOTICE([Solaris detected. Please consider building a 64-bit binary.])
 +                         ])
  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.])
@@@ -444,6 -422,18 +444,6 @@@ AC_CHECK_HEADERS(sys/swap.h vm/anon.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
@@@ -583,7 -573,7 +583,7 @@@ AC_CHECK_HEADERS(linux/un.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)
 +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 sys/vmmeter.h kvm.h wordexp.h locale.h)
  
  # For the dns plugin
  AC_CHECK_HEADERS(arpa/nameser.h)
@@@ -648,51 -638,20 +648,51 @@@ AC_CHECK_HEADERS(net/pfvar.h
  have_termios_h="no"
  AC_CHECK_HEADERS(termios.h, [have_termios_h="yes"])
  
 +# For the turbostat plugin
 +have_asm_msrindex_h="no"
 +AC_CHECK_HEADERS(asm/msr-index.h, [have_asm_msrindex_h="yes"])
 +
 +if test "x$have_asm_msrindex_h" = "xyes"
 +then
 +  AC_CACHE_CHECK([whether asm/msr-index.h has MSR_PKG_C10_RESIDENCY],
 +                 [c_cv_have_usable_asm_msrindex_h],
 +                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
 +[[[
 +#include<asm/msr-index.h>
 +]]],
 +[[[
 +int y = MSR_PKG_C10_RESIDENCY;
 +return(y);
 +]]]
 +  )],
 +                 [c_cv_have_usable_asm_msrindex_h="yes"],
 +                 [c_cv_have_usable_asm_msrindex_h="no"],
 +                                  )
 +                 )
 +fi
 +
 +have_cpuid_h="no"
 +AC_CHECK_HEADERS(cpuid.h, [have_cpuid_h="yes"])
 +
 +AC_CHECK_HEADERS(sys/capability.h)
  #
  # Checks for typedefs, structures, and compiler characteristics.
  #
  AC_C_CONST
 +AC_C_INLINE
 +AC_TYPE_OFF_T
  AC_TYPE_PID_T
  AC_TYPE_SIZE_T
 +AC_TYPE_SSIZE_T
  AC_TYPE_UID_T
 +AC_TYPE_UINT32_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_CHECK_FUNCS(gettimeofday select strdup strtol getaddrinfo getnameinfo strchr memcpy strstr strcmp strncmp strncpy strlen strncasecmp strcasecmp openlog closelog sysconf setenv if_indextoname setlocale)
  
  AC_FUNC_STRERROR_R
  
@@@ -899,9 -858,7 +899,9 @@@ if test "x$have_swapctl" = "xyes"; the
  #  undef _LARGEFILE64_SOURCE
  #endif
  #include <sys/stat.h>
 +#include <sys/param.h>
  #include <sys/swap.h>
 +#include <unistd.h>
  ]]],
  [[[
  int num = swapctl(0, NULL);
  #  undef _LARGEFILE64_SOURCE
  #endif
  #include <sys/stat.h>
 +#include <sys/param.h>
  #include <sys/swap.h>
 +#include <unistd.h>
  ]]],
  [[[
  int num = swapctl(0, NULL, 0);
@@@ -1096,7 -1051,7 +1096,7 @@@ if test "x$fp_layout_type" = "xunknown"
        uint8_t c[8];
        double d;
  
 -      d = 8.642135e130; 
 +      d = 8.642135e130;
        memcpy ((void *) &i0, (void *) &d, 8);
  
        i1 = i0;
@@@ -1151,7 -1106,7 +1151,7 @@@ if test "x$fp_layout_type" = "xunknown"
        uint8_t c[8];
        double d;
  
 -      d = 8.642135e130; 
 +      d = 8.642135e130;
        memcpy ((void *) &i0, (void *) &d, 8);
  
        i1 = endianflip (i0);
@@@ -1200,7 -1155,7 +1200,7 @@@ if test "x$fp_layout_type" = "xunknown"
        uint8_t c[8];
        double d;
  
 -      d = 8.642135e130; 
 +      d = 8.642135e130;
        memcpy ((void *) &i0, (void *) &d, 8);
  
        i1 = intswap (i0);
    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"
@@@ -1351,7 -1295,7 +1351,7 @@@ AC_CACHE_CHECK([if have htonll defined]
      )],
      [c_cv_have_htonll="yes"],
      [c_cv_have_htonll="no"]
 -       )
 +  )
  )
  if test "x$c_cv_have_htonll" = "xyes"
  then
@@@ -1407,7 -1351,7 +1407,7 @@@ AC_CHECK_MEMBERS([struct kinfo_proc.ki_
  #include <sys/user.h>
        ])
  
 -AC_CHECK_MEMBERS([struct kinfo_proc.kp_proc, struct kinfo_proc.kp_eproc],
 +AC_CHECK_MEMBERS([struct kinfo_proc.p_pid, struct kinfo_proc.p_vm_rssize],
        [
                AC_DEFINE(HAVE_STRUCT_KINFO_PROC_OPENBSD, 1,
                        [Define if struct kinfo_proc exists in the OpenBSD variant.])
  
  AC_CHECK_MEMBERS([struct udphdr.uh_dport, struct udphdr.uh_sport], [], [],
  [#define _BSD_SOURCE
 +#define _DEFAULT_SOURCE
  #if HAVE_STDINT_H
  # include <stdint.h>
  #endif
  ])
  AC_CHECK_MEMBERS([struct udphdr.dest, struct udphdr.source], [], [],
  [#define _BSD_SOURCE
 +#define _DEFAULT_SOURCE
  #if HAVE_STDINT_H
  # include <stdint.h>
  #endif
  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"
  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.])],
 +# --with-libhiredis {{{
 +AC_ARG_WITH(libhiredis, [AS_HELP_STRING([--with-libhiredis@<:@=PREFIX@:>@],
 +      [Path to libhiredis.])],
  [
   if test "x$withval" = "xyes"
   then
 -       with_libcredis="yes"
 +       with_libhiredis="yes"
   else if test "x$withval" = "xno"
   then
 -       with_libcredis="no"
 +       with_libhiredis="no"
   else
 -       with_libcredis="yes"
 -       LIBCREDIS_CPPFLAGS="$LIBCREDIS_CPPFLAGS -I$withval/include"
 -       LIBCREDIS_LDFLAGS="$LIBCREDIS_LDFLAGS -L$withval/lib"
 +       with_libhiredis="yes"
 +       LIBHIREDIS_CPPFLAGS="$LIBHIREDIS_CPPFLAGS -I$withval/include"
 +       LIBHIREDIS_LDFLAGS="$LIBHIREDIS_LDFLAGS -L$withval/lib"
   fi; fi
  ],
 -[with_libcredis="yes"])
 +[with_libhiredis="yes"])
  
  SAVE_CPPFLAGS="$CPPFLAGS"
  SAVE_LDFLAGS="$LDFLAGS"
  
 -CPPFLAGS="$CPPFLAGS $LIBCREDIS_CPPFLAGS"
 -LDFLAGS="$LDFLAGS $LIBCREDIS_LDFLAGS"
 +CPPFLAGS="$CPPFLAGS $LIBHIREDIS_CPPFLAGS"
 +LDFLAGS="$LDFLAGS $LIBHIREDIS_LDFLAGS"
  
 -if test "x$with_libcredis" = "xyes"
 +if test "x$with_libhiredis" = "xyes"
  then
 -      if test "x$LIBCREDIS_CPPFLAGS" != "x"
 +      if test "x$LIBHIREDIS_CPPFLAGS" != "x"
        then
 -              AC_MSG_NOTICE([libcredis CPPFLAGS: $LIBCREDIS_CPPFLAGS])
 +              AC_MSG_NOTICE([libhiredis CPPFLAGS: $LIBHIREDIS_CPPFLAGS])
        fi
 -      AC_CHECK_HEADERS(credis.h,
 -      [with_libcredis="yes"],
 -      [with_libcredis="no (credis.h not found)"])
 +      AC_CHECK_HEADERS(hiredis/hiredis.h,
 +      [with_libhiredis="yes"],
 +      [with_libhiredis="no (hiredis.h not found)"])
  fi
 -if test "x$with_libcredis" = "xyes"
 +if test "x$with_libhiredis" = "xyes"
  then
 -      if test "x$LIBCREDIS_LDFLAGS" != "x"
 +      if test "x$LIBHIREDIS_LDFLAGS" != "x"
        then
 -              AC_MSG_NOTICE([libcredis LDFLAGS: $LIBCREDIS_LDFLAGS])
 +              AC_MSG_NOTICE([libhiredis LDFLAGS: $LIBHIREDIS_LDFLAGS])
        fi
 -      AC_CHECK_LIB(credis, credis_info,
 -      [with_libcredis="yes"],
 -      [with_libcredis="no (symbol 'credis_info' not found)"])
 +      AC_CHECK_LIB(hiredis, redisCommand,
 +      [with_libhiredis="yes"],
 +      [with_libhiredis="no (symbol 'redisCommand' not found)"])
  
  fi
  
  CPPFLAGS="$SAVE_CPPFLAGS"
  LDFLAGS="$SAVE_LDFLAGS"
  
 -if test "x$with_libcredis" = "xyes"
 +if test "x$with_libhiredis" = "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)
 +      BUILD_WITH_LIBHIREDIS_CPPFLAGS="$LIBHIREDIS_CPPFLAGS"
 +      BUILD_WITH_LIBHIREDIS_LDFLAGS="$LIBHIREDIS_LDFLAGS"
 +      AC_SUBST(BUILD_WITH_LIBHIREDIS_CPPFLAGS)
 +      AC_SUBST(BUILD_WITH_LIBHIREDIS_LDFLAGS)
  fi
 -AM_CONDITIONAL(BUILD_WITH_LIBCREDIS, test "x$with_libcredis" = "xyes")
 +AM_CONDITIONAL(BUILD_WITH_LIBHIREDIS, test "x$with_libhiredis" = "xyes")
  # }}}
  
  # --with-libcurl {{{
                 [with_libcurl="yes"],
                 [with_libcurl="no (symbol 'curl_easy_init' not found)"],
                 [$with_curl_libs])
 +              AC_CHECK_DECL(CURLOPT_USERNAME,
 +               [have_curlopt_username="yes"],
 +               [have_curlopt_username="no"],
 +               [[#include <curl/curl.h>]])
 +              AC_CHECK_DECL(CURLOPT_TIMEOUT_MS,
 +               [have_curlopt_timeout="yes"],
 +               [have_curlopt_timeout="no"],
 +               [[#include <curl/curl.h>]])
        fi
  fi
  if test "x$with_libcurl" = "xyes"
        BUILD_WITH_LIBCURL_LIBS="$with_curl_libs"
        AC_SUBST(BUILD_WITH_LIBCURL_CFLAGS)
        AC_SUBST(BUILD_WITH_LIBCURL_LIBS)
 +
 +      if test "x$have_curlopt_username" = "xyes"
 +      then
 +              AC_DEFINE(HAVE_CURLOPT_USERNAME, 1, [Define if libcurl supports CURLOPT_USERNAME option.])
 +      fi
 +
 +      if test "x$have_curlopt_timeout" = "xyes"
 +      then
 +              AC_DEFINE(HAVE_CURLOPT_TIMEOUT_MS, 1, [Define if libcurl supports CURLOPT_TIMEOUT_MS option.])
 +      fi
  fi
  AM_CONDITIONAL(BUILD_WITH_LIBCURL, test "x$with_libcurl" = "xyes")
  # }}}
@@@ -2082,7 -2009,10 +2082,7 @@@ AM_CONDITIONAL(BUILD_WITH_LIBGCRYPT, te
  # --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"
 +      if test "x$withval" = "xyes"
        then
                with_libiptc="pkgconfig"
        else if test "x$withval" = "xno"
                with_libiptc="yes"
                with_libiptc_cflags="-I$withval/include"
                with_libiptc_libs="-L$withval/lib"
 -      fi; fi; fi
 +      fi; fi
  ],
  [
        if test "x$ac_system" = "xLinux"
  
  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
@@@ -2347,64 -2299,6 +2347,64 @@@ AC_SUBST(JAVA_LIBS
  AM_CONDITIONAL(BUILD_WITH_JAVA, test "x$with_java" = "xyes")
  # }}}
  
 +# --with-libldap {{{
 +AC_ARG_WITH(libldap, [AS_HELP_STRING([--with-libldap@<:@=PREFIX@:>@], [Path to libldap.])],
 +[
 + if test "x$withval" = "xyes"
 + then
 +       with_libldap="yes"
 + else if test "x$withval" = "xno"
 + then
 +       with_libldap="no"
 + else
 +       with_libldap="yes"
 +       LIBLDAP_CPPFLAGS="$LIBLDAP_CPPFLAGS -I$withval/include"
 +       LIBLDAP_LDFLAGS="$LIBLDAP_LDFLAGS -L$withval/lib"
 + fi; fi
 +],
 +[with_libldap="yes"])
 +
 +SAVE_CPPFLAGS="$CPPFLAGS"
 +SAVE_LDFLAGS="$LDFLAGS"
 +
 +CPPFLAGS="$CPPFLAGS $LIBLDAP_CPPFLAGS"
 +LDFLAGS="$LDFLAGS $LIBLDAP_LDFLAGS"
 +
 +if test "x$with_libldap" = "xyes"
 +then
 +      if test "x$LIBLDAP_CPPFLAGS" != "x"
 +      then
 +              AC_MSG_NOTICE([libldap CPPFLAGS: $LIBLDAP_CPPFLAGS])
 +      fi
 +      AC_CHECK_HEADERS(ldap.h,
 +      [with_libldap="yes"],
 +      [with_libldap="no ('ldap.h' not found)"])
 +fi
 +if test "x$with_libldap" = "xyes"
 +then
 +      if test "x$LIBLDAP_LDFLAGS" != "x"
 +      then
 +              AC_MSG_NOTICE([libldap LDFLAGS: $LIBLDAP_LDFLAGS])
 +      fi
 +      AC_CHECK_LIB(ldap, ldap_initialize,
 +      [with_libldap="yes"],
 +      [with_libldap="no (symbol 'ldap_initialize' not found)"])
 +
 +fi
 +
 +CPPFLAGS="$SAVE_CPPFLAGS"
 +LDFLAGS="$SAVE_LDFLAGS"
 +
 +if test "x$with_libldap" = "xyes"
 +then
 +      BUILD_WITH_LIBLDAP_CPPFLAGS="$LIBLDAP_CPPFLAGS"
 +      BUILD_WITH_LIBLDAP_LDFLAGS="$LIBLDAP_LDFLAGS"
 +      AC_SUBST(BUILD_WITH_LIBLDAP_CPPFLAGS)
 +      AC_SUBST(BUILD_WITH_LIBLDAP_LDFLAGS)
 +fi
 +AM_CONDITIONAL(BUILD_WITH_LIBLDAP, test "x$with_libldap" = "xyes")
 +# }}}
 +
  # --with-liblvm2app {{{
  with_liblvm2app_cppflags=""
  with_liblvm2app_ldflags=""
@@@ -2439,7 -2333,7 +2439,7 @@@ the
          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)"])
 +        AC_CHECK_LIB(lvm2app, lvm_lv_get_property, [with_liblvm2app="yes"], [with_liblvm2app="no (Symbol 'lvm_lv_get_property' not found)"])
  
          CPPFLAGS="$SAVE_CPPFLAGS"
          LDFLAGS="$SAVE_LDFLAGS"
@@@ -2691,7 -2585,7 +2691,7 @@@ AC_ARG_WITH(libmysql, [AS_HELP_STRING([
  ])
  if test "x$with_libmysql" = "xyes"
  then
-       with_mysql_cflags=`$with_mysql_config --cflags 2>/dev/null`
+       with_mysql_cflags=`$with_mysql_config --include 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,
+               SAVE_CPPFLAGS="$CPPFLAGS"
+               CPPFLAGS="$CPPFLAGS $with_mysql_cflags"
+               SAVE_LIBS="$LIBS"
+               LIBS="$with_mysql_libs"
+               AC_SEARCH_LIBS([mysql_get_server_version],
+                [],
                 [with_libmysql="yes"],
                 [with_libmysql="no (symbol 'mysql_get_server_version' not found)"],
-                [$with_mysql_libs])
+                [])
+               CPPFLAGS="$SAVE_CPPFLAGS"
+               LIBS="$SAVE_LIBS"
        fi
  fi
  if test "x$with_libmysql" = "xyes"
@@@ -2841,15 -2737,6 +2843,15 @@@ return (retval)
  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)"],
@@@ -2973,7 -2860,7 +2975,7 @@@ the
        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"
@@@ -3200,7 -3087,7 +3202,7 @@@ 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"
@@@ -3211,7 -3098,7 +3213,7 @@@ the
        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"
  fi
  # }}}
  
 +# --with-librdkafka {{{
 +AC_ARG_WITH(librdkafka, [AS_HELP_STRING([--with-librdkafka@<:@=PREFIX@:>@], [Path to librdkafka.])],
 +[
 +  if test "x$withval" != "xno" && test "x$withval" != "xyes"
 +  then
 +    with_librdkafka_cppflags="-I$withval/include"
 +    with_librdkafka_ldflags="-L$withval/lib"
 +    with_librdkafka_rpath="$withval/lib"
 +    with_librdkafka="yes"
 +  else
 +    with_librdkafka="$withval"
 +  fi
 +],
 +[
 +  with_librdkafka="yes"
 +])
 +SAVE_CPPFLAGS="$CPPFLAGS"
 +SAVE_LDFLAGS="$LDFLAGS"
 +
 +CPPFLAGS="$CPPFLAGS $with_librdkafka_cppflags"
 +LDFLAGS="$LDFLAGS $with_librdkafka_ldflags"
 +
 +if test "x$with_librdkafka" = "xyes"
 +then
 +      AC_CHECK_HEADERS(librdkafka/rdkafka.h, [with_librdkafka="yes"], [with_librdkafka="no (librdkafka/rdkafka.h not found)"])
 +fi
 +
 +if test "x$with_librdkafka" = "xyes"
 +then
 +      AC_CHECK_LIB(rdkafka, rd_kafka_new, [with_librdkafka="yes"], [with_librdkafka="no (Symbol 'rd_kafka_new' not found)"])
 +  AC_CHECK_LIB(rdkafka, rd_kafka_conf_set_log_cb, [with_librdkafka_log_cb="yes"], [with_librdkafka_log_cb="no"])
 +  AC_CHECK_LIB(rdkafka, rd_kafka_set_logger, [with_librdkafka_logger="yes"], [with_librdkafka_logger="no"])
 +fi
 +if test "x$with_librdkafka" = "xyes"
 +then
 +      BUILD_WITH_LIBRDKAFKA_CPPFLAGS="$with_librdkafka_cppflags"
 +      BUILD_WITH_LIBRDKAFKA_LDFLAGS="$with_librdkafka_ldflags"
 +      if test "x$with_librdkafka_rpath" != "x"
 +      then
 +              BUILD_WITH_LIBRDKAFKA_LIBS="-Wl,-rpath,$with_librdkafka_rpath -lrdkafka"
 +      else
 +              BUILD_WITH_LIBRDKAFKA_LIBS="-lrdkafka"
 +      fi
 +      AC_SUBST(BUILD_WITH_LIBRDKAFKA_CPPFLAGS)
 +      AC_SUBST(BUILD_WITH_LIBRDKAFKA_LDFLAGS)
 +      AC_SUBST(BUILD_WITH_LIBRDKAFKA_LIBS)
 +      AC_DEFINE(HAVE_LIBRDKAFKA, 1, [Define if librdkafka is present and usable.])
 +  if test "x$with_librdkafka_log_cb" = "xyes"
 +  then
 +        AC_DEFINE(HAVE_LIBRDKAFKA_LOG_CB, 1, [Define if librdkafka log facility is present and usable.])
 +  fi
 +  if test "x$with_librdkafka_logger" = "xyes"
 +  then
 +        AC_DEFINE(HAVE_LIBRDKAFKA_LOGGER, 1, [Define if librdkafka log facility is present and usable.])
 +  fi
 +fi
 +CPPFLAGS="$SAVE_CPPFLAGS"
 +LDFLAGS="$SAVE_LDFLAGS"
 +AM_CONDITIONAL(BUILD_WITH_LIBRDKAFKA, test "x$with_librdkafka" = "xyes")
 +
 +# }}}
 +
  # --with-librouteros {{{
  AC_ARG_WITH(librouteros, [AS_HELP_STRING([--with-librouteros@<:@=PREFIX@:>@], [Path to librouteros.])],
  [
    LDFLAGS="$SAVE_LDFLAGS"
  fi
  
 +if test "x$with_libstatgrab" = "xyes"
 +then
 +  SAVE_CFLAGS="$CFLAGS"
 +  SAVE_LIBS="$LIBS"
 +
 +  CFLAGS="$CFLAGS $with_libstatgrab_cflags"
 +  LDFLAGS="$LDFLAGS $with_libstatgrab_ldflags"
 +  LIBS="-lstatgrab $LIBS"
 +
 +  AC_CACHE_CHECK([if libstatgrab >= 0.90],
 +          [c_cv_have_libstatgrab_0_90],
 +          AC_LINK_IFELSE([AC_LANG_PROGRAM(
 +[[[
 +#include <stdio.h>
 +#include <statgrab.h>
 +]]],
 +[[[
 +      if (sg_init()) return 0;
 +]]]
 +    )],
 +    [c_cv_have_libstatgrab_0_90="no"],
 +    [c_cv_have_libstatgrab_0_90="yes"]
 +          )
 +  )
 +
 +  CFLAGS="$SAVE_CFLAGS"
 +  LDFLAGS="$SAVE_LDFLAGS"
 +  LIBS="$SAVE_LIBS"
 +fi
 +
  AM_CONDITIONAL(BUILD_WITH_LIBSTATGRAB, test "x$with_libstatgrab" = "xyes")
  if test "x$with_libstatgrab" = "xyes"
  then
    BUILD_WITH_LIBSTATGRAB_LDFLAGS="$with_libstatgrab_ldflags"
    AC_SUBST(BUILD_WITH_LIBSTATGRAB_CFLAGS)
    AC_SUBST(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
 +  if test "x$c_cv_have_libstatgrab_0_90" = "xyes"
 +  then
 +        AC_DEFINE(HAVE_LIBSTATGRAB_0_90, 1, [Define to 1 if libstatgrab version >= 0.90])
 +  fi
  fi
  # }}}
  
@@@ -4347,7 -4138,7 +4349,7 @@@ CPPFLAGS="$SAVE_CPPFLAGS
  LDFLAGS="$SAVE_LDFLAGS"
  
  if test "x$with_libtokyotyrant" = "xyes"
 -then 
 +then
    BUILD_WITH_LIBTOKYOTYRANT_CPPFLAGS="$with_libtokyotyrant_cppflags"
    BUILD_WITH_LIBTOKYOTYRANT_LDFLAGS="$with_libtokyotyrant_ldflags"
    BUILD_WITH_LIBTOKYOTYRANT_LIBS="$with_libtokyotyrant_libs"
  AM_CONDITIONAL(BUILD_WITH_LIBTOKYOTYRANT, test "x$with_libtokyotyrant" = "xyes")
  # }}}
  
 +# --with-libudev {{{
 +with_libudev_cflags=""
 +with_libudev_ldflags=""
 +AC_ARG_WITH(libudev, [AS_HELP_STRING([--with-libudev@<:@=PREFIX@:>@], [Path to libudev.])],
 +[
 +      if test "x$withval" = "xno"
 +      then
 +              with_libudev="no"
 +      else
 +              with_libudev="yes"
 +              if test "x$withval" != "xyes"
 +              then
 +                      with_libudev_cflags="-I$withval/include"
 +                      with_libudev_ldflags="-L$withval/lib"
 +                      with_libudev="yes"
 +              fi
 +      fi
 +],
 +[
 +      if test "x$ac_system" = "xLinux"
 +      then
 +              with_libudev="yes"
 +      else
 +              with_libudev="no (Linux only library)"
 +      fi
 +])
 +if test "x$with_libudev" = "xyes"
 +then
 +      SAVE_CPPFLAGS="$CPPFLAGS"
 +      CPPFLAGS="$CPPFLAGS $with_libudev_cflags"
 +
 +      AC_CHECK_HEADERS(libudev.h, [], [with_libudev="no (libudev.h not found)"])
 +
 +      CPPFLAGS="$SAVE_CPPFLAGS"
 +fi
 +if test "x$with_libudev" = "xyes"
 +then
 +      SAVE_CPPFLAGS="$CPPFLAGS"
 +      SAVE_LDFLAGS="$LDFLAGS"
 +      CPPFLAGS="$CPPFLAGS $with_libudev_cflags"
 +      LDFLAGS="$LDFLAGS $with_libudev_ldflags"
 +
 +      AC_CHECK_LIB(udev, udev_new,
 +      [
 +              AC_DEFINE(HAVE_LIBUDEV, 1, [Define to 1 if you have the udev library (-ludev).])
 +      ],
 +      [with_libudev="no (libudev not found)"])
 +
 +      CPPFLAGS="$SAVE_CPPFLAGS"
 +      LDFLAGS="$SAVE_LDFLAGS"
 +fi
 +if test "x$with_libudev" = "xyes"
 +then
 +      BUILD_WITH_LIBUDEV_CFLAGS="$with_libudev_cflags"
 +      BUILD_WITH_LIBUDEV_LDFLAGS="$with_libudev_ldflags"
 +      AC_SUBST(BUILD_WITH_LIBUDEV_CFLAGS)
 +      AC_SUBST(BUILD_WITH_LIBUDEV_LDFLAGS)
 +fi
 +AM_CONDITIONAL(BUILD_WITH_LIBUDEV, test "x$with_libudev" = "xyes")
 +# }}}
 +
  # --with-libupsclient {{{
  with_libupsclient_config=""
  with_libupsclient_cflags=""
  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])])
 +      AC_CHECK_HEADERS(vapi/vsc.h,
 +              [AC_DEFINE([HAVE_VARNISH_V4], [1], [Varnish 4 API support])],
 +              [AC_CHECK_HEADERS(vsc.h,
 +                      [AC_DEFINE([HAVE_VARNISH_V3], [1], [Varnish 3 API support])],
 +                      [AC_CHECK_HEADERS(varnishapi.h,
 +                              [AC_DEFINE([HAVE_VARNISH_V2], [1], [Varnish 2 API support])],
 +                              [with_libvarnish="no (found none of the varnish header files)"])])])
  
        CPPFLAGS="$SAVE_CPPFLAGS"
 -      #LDFLAGS="$SAVE_LDFLAGS"
  fi
  if test "x$with_libvarnish" = "xyes"
  then
  fi
  # }}}
  
 +# --with-libatasmart {{{
 +with_libatasmart_cppflags=""
 +with_libatasmart_ldflags=""
 +AC_ARG_WITH(libatasmart, [AS_HELP_STRING([--with-libatasmart@<:@=PREFIX@:>@], [Path to libatasmart.])],
 +[
 +      if test "x$withval" != "xno" && test "x$withval" != "xyes"
 +      then
 +              with_libatasmart_cppflags="-I$withval/include"
 +              with_libatasmart_ldflags="-L$withval/lib"
 +              with_libatasmart="yes"
 +      else
 +              with_libatasmart="$withval"
 +      fi
 +],
 +[
 +      if test "x$ac_system" = "xLinux"
 +      then
 +              with_libatasmart="yes"
 +      else
 +              with_libatasmart="no (Linux only library)"
 +      fi
 +])
 +if test "x$with_libatasmart" = "xyes"
 +then
 +      SAVE_CPPFLAGS="$CPPFLAGS"
 +      CPPFLAGS="$CPPFLAGS $with_libatasmart_cppflags"
 +
 +      AC_CHECK_HEADERS(atasmart.h, [with_libatasmart="yes"], [with_libatasmart="no (atasmart.h not found)"])
 +
 +      CPPFLAGS="$SAVE_CPPFLAGS"
 +fi
 +if test "x$with_libatasmart" = "xyes"
 +then
 +      SAVE_CPPFLAGS="$CPPFLAGS"
 +      SAVE_LDFLAGS="$LDFLAGS"
 +      CPPFLAGS="$CPPFLAGS $with_libatasmart_cppflags"
 +      LDFLAGS="$LDFLAGS $with_libatasmart_ldflags"
 +
 +      AC_CHECK_LIB(atasmart, sk_disk_open, [with_libatasmart="yes"], [with_libatasmart="no (Symbol 'sk_disk_open' not found)"])
 +
 +      CPPFLAGS="$SAVE_CPPFLAGS"
 +      LDFLAGS="$SAVE_LDFLAGS"
 +fi
 +if test "x$with_libatasmart" = "xyes"
 +then
 +      BUILD_WITH_LIBATASMART_CPPFLAGS="$with_libatasmart_cppflags"
 +      BUILD_WITH_LIBATASMART_LDFLAGS="$with_libatasmart_ldflags"
 +      BUILD_WITH_LIBATASMART_LIBS="-latasmart"
 +      AC_SUBST(BUILD_WITH_LIBATASMART_CPPFLAGS)
 +      AC_SUBST(BUILD_WITH_LIBATASMART_LDFLAGS)
 +      AC_SUBST(BUILD_WITH_LIBATASMART_LIBS)
 +      AC_DEFINE(HAVE_LIBATASMART, 1, [Define if libatasmart is present and usable.])
 +fi
 +AM_CONDITIONAL(BUILD_WITH_LIBATASMART, test "x$with_libatasmart" = "xyes")
 +# }}}
 +
  PKG_CHECK_MODULES([LIBNOTIFY], [libnotify],
                [with_libnotify="yes"],
                [if test "x$LIBNOTIFY_PKG_ERRORS" = "x"; then
@@@ -5204,10 -4885,8 +5206,10 @@@ dependency_warning="no
  dependency_error="no"
  
  plugin_ascent="no"
 +plugin_barometer="no"
  plugin_battery="no"
  plugin_bind="no"
 +plugin_ceph="no"
  plugin_cgroups="no"
  plugin_conntrack="no"
  plugin_contextswitch="no"
@@@ -5217,17 -4896,15 +5219,17 @@@ plugin_curl_json="no
  plugin_curl_xml="no"
  plugin_df="no"
  plugin_disk="no"
 +plugin_drbd="no"
  plugin_entropy="no"
  plugin_ethstat="no"
 +plugin_fhcount="no"
  plugin_fscache="no"
  plugin_interface="no"
  plugin_ipmi="no"
  plugin_ipvs="no"
  plugin_irq="no"
 -plugin_libvirt="no"
  plugin_load="no"
 +plugin_log_logstash="no"
  plugin_memory="no"
  plugin_multimeter="no"
  plugin_nfs="no"
@@@ -5241,15 -4918,12 +5243,15 @@@ plugin_tape="no
  plugin_tcpconns="no"
  plugin_ted="no"
  plugin_thermal="no"
 -plugin_users="no"
 +plugin_turbostat="no"
  plugin_uptime="no"
 +plugin_users="no"
 +plugin_virt="no"
  plugin_vmem="no"
  plugin_vserver="no"
  plugin_wireless="no"
  plugin_zfs_arc="no"
 +plugin_zookeeper="no"
  
  # Linux
  if test "x$ac_system" = "xLinux"
        plugin_cpu="yes"
        plugin_cpufreq="yes"
        plugin_disk="yes"
 +      plugin_drbd="yes"
        plugin_entropy="yes"
 +      plugin_fhcount="yes"
        plugin_fscache="yes"
        plugin_interface="yes"
 +      plugin_ipc="yes"
        plugin_irq="yes"
        plugin_load="yes"
        plugin_lvm="yes"
        plugin_vmem="yes"
        plugin_vserver="yes"
        plugin_wireless="yes"
 +      plugin_zfs_arc="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
 +      if test "x$c_cv_have_usable_asm_msrindex_h" = "xyes" && test "x$have_cpuid_h" = "xyes"
 +      then
 +              plugin_turbostat="yes"
 +      fi
  fi
  
  if test "x$ac_system" = "xOpenBSD"
  
  if test "x$ac_system" = "xAIX"
  then
 -        plugin_tcpconns="yes"
 +      plugin_tcpconns="yes"
 +      plugin_ipc="yes"
  fi
  
  # FreeBSD
  
  if test "x$ac_system" = "xFreeBSD"
  then
 -        plugin_zfs_arc="yes"
 +      plugin_zfs_arc="yes"
  fi
  
  
        plugin_tape="yes"
  fi
  
 +# libi2c-dev
 +with_libi2c="no"
 +if test "x$ac_system" = "xLinux"
 +then
 +AC_CHECK_DECL(i2c_smbus_read_i2c_block_data,
 +      [with_libi2c="yes"],
 +      [with_libi2c="no (symbol i2c_smbus_read_i2c_block_data not found - have you installed libi2c-dev ?)"],
 +      [[#include <stdlib.h>
 +      #include <linux/i2c-dev.h>]])
 +fi
 +
 +if test "x$with_libi2c" = "xyes"
 +then
 +      plugin_barometer="yes"
 +fi
 +
 +
  # libstatgrab
  if test "x$with_libstatgrab" = "xyes"
  then
        plugin_curl_xml="yes"
  fi
  
 +if test "x$with_libyajl" = "xyes"
 +then
 +      plugin_ceph="yes"
 +fi
 +
  if test "x$have_processor_info" = "xyes"
  then
        plugin_cpu="yes"
        plugin_interface="yes"
  fi
  
 -if test "x$with_libxml2" = "xyes" && test "x$with_libvirt" = "xyes"
 +if test "x$have_getloadavg" = "xyes"
  then
 -      plugin_libvirt="yes"
 +      plugin_load="yes"
  fi
  
 -if test "x$have_getloadavg" = "xyes"
 +if test "x$with_libyajl" = "xyes"
  then
 -      plugin_load="yes"
 +      plugin_log_logstash="yes"
  fi
  
  if test "x$c_cv_have_libperl$c_cv_have_perl_ithreads" = "xyesyes"
  
  if test "x$have_termios_h" = "xyes"
  then
 -      plugin_multimeter="yes"
 +      if test "x$ac_system" != "xAIX"
 +      then
 +              plugin_multimeter="yes"
 +      fi
        plugin_ted="yes"
  fi
  
        plugin_processes="yes"
  fi
  
 +if test "x$with_kvm_getprocs" = "xyes" && test "x$have_struct_kinfo_proc_openbsd" = "xyes"
 +then
 +      plugin_processes="yes"
 +fi
 +
  if test "x$with_kvm_getswapinfo" = "xyes"
  then
        plugin_swap="yes"
        plugin_users="yes"
  fi
  
 +if test "x$with_libxml2" = "xyes" && test "x$with_libvirt" = "xyes"
 +then
 +      plugin_virt="yes"
 +fi
 +
 +
  m4_divert_once([HELP_ENABLE], [
  collectd plugins:])
  
@@@ -5585,10 -5214,8 +5587,10 @@@ AC_PLUGIN([apcups],      [yes]
  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([barometer],   [$plugin_barometer],  [Barometer sensor on I2C])
  AC_PLUGIN([battery],     [$plugin_battery],    [Battery statistics])
  AC_PLUGIN([bind],        [$plugin_bind],       [ISC Bind nameserver statistics])
 +AC_PLUGIN([ceph],        [$plugin_ceph],       [Ceph daemon 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])
@@@ -5601,27 -5228,24 +5603,27 @@@ AC_PLUGIN([cgroups],     [$plugin_cgrou
  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([drbd],        [$plugin_drbd],       [DRBD 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([fhcount],     [$plugin_fhcount],    [File handles statistics])
  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([ipc],         [$plugin_ipc],        [IPC 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([log_logstash], [$plugin_log_logstash], [Logstash json_event compatible logging])
  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])
@@@ -5651,7 -5275,6 +5653,7 @@@ AC_PLUGIN([numa],        [$plugin_numa]
  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([openldap],    [$with_libldap],      [OpenLDAP statistics])
  AC_PLUGIN([openvpn],     [yes],                [OpenVPN client statistics])
  AC_PLUGIN([oracle],      [$with_oracle],       [Oracle plugin])
  AC_PLUGIN([perl],        [$plugin_perl],       [Embed a Perl interpreter])
@@@ -5664,14 -5287,13 +5666,14 @@@ AC_PLUGIN([powerdns],    [yes]
  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([redis],       [$with_libhiredis],    [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([smart],       [$with_libatasmart],  [SMART statistics])
  AC_PLUGIN([snmp],        [$with_libnetsnmp],   [SNMP querying plugin])
  AC_PLUGIN([statsd],      [yes],                [StatsD plugin])
  AC_PLUGIN([swap],        [$plugin_swap],       [Swap usage statistics])
@@@ -5691,34 -5313,26 +5693,34 @@@ AC_PLUGIN([ted],         [$plugin_ted]
  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([turbostat],   [$plugin_turbostat],  [Advanced statistic on Intel cpu states])
  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([virt],        [$plugin_virt],       [Virtual machine 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_kafka],  [$with_librdkafka],  [Kafka output plugin])
 +AC_PLUGIN([write_log], [yes],                  [Log output plugin])
  AC_PLUGIN([write_mongodb], [$with_libmongoc],  [MongoDB output plugin])
 -AC_PLUGIN([write_redis], [$with_libcredis],    [Redis output plugin])
 +AC_PLUGIN([write_redis], [$with_libhiredis],    [Redis output plugin])
  AC_PLUGIN([write_riemann], [$have_protoc_c],   [Riemann output plugin])
 +AC_PLUGIN([write_sensu], [yes],                [Sensu output plugin])
 +AC_PLUGIN([write_tsdb],  [yes],                [TSDB output plugin])
  AC_PLUGIN([xmms],        [$with_libxmms],      [XMMS statistics])
  AC_PLUGIN([zfs_arc],     [$plugin_zfs_arc],    [ZFS ARC statistics])
 +AC_PLUGIN([zookeeper],   [yes],              [Zookeeper statistics])
  
  dnl Default configuration file
  # Load either syslog or logfile
  LOAD_PLUGIN_SYSLOG=""
  LOAD_PLUGIN_LOGFILE=""
 +LOAD_PLUGIN_LOG_LOGSTASH=""
  
  AC_MSG_CHECKING([which default log plugin to load])
  default_log_plugin="none"
  else
        LOAD_PLUGIN_LOGFILE="##"
  fi
 +
 +if test "x$enable_log_logstash" = "xyes"
 +then
 +  LOAD_PLUGIN_LOG_LOGSTASH="#"
 +else
 +  LOAD_PLUGIN_LOG_LOGSTASH="##"
 +fi
 +
 +
  AC_MSG_RESULT([$default_log_plugin])
  
  AC_SUBST(LOAD_PLUGIN_SYSLOG)
  AC_SUBST(LOAD_PLUGIN_LOGFILE)
 +AC_SUBST(LOAD_PLUGIN_LOG_LOGSTASH)
  
  DEFAULT_LOG_LEVEL="info"
  if test "x$enable_debug" = "xyes"
@@@ -5863,7 -5467,7 +5865,7 @@@ 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_CONFIG_FILES([Makefile src/Makefile src/daemon/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" \
@@@ -5896,21 -5500,18 +5898,21 @@@ Configuration
    Libraries:
      intel mic . . . . . . $with_mic
      libaquaero5 . . . . . $with_libaquaero5
 -    libcredis . . . . . . $with_libcredis
 +    libatasmart . . . . . $with_libatasmart
      libcurl . . . . . . . $with_libcurl
      libdbi  . . . . . . . $with_libdbi
      libesmtp  . . . . . . $with_libesmtp
      libganglia  . . . . . $with_libganglia
      libgcrypt . . . . . . $with_libgcrypt
      libhal  . . . . . . . $with_libhal
 +    libhiredis  . . . . . $with_libhiredis
 +    libi2c-dev  . . . . . $with_libi2c
      libiokit  . . . . . . $with_libiokit
      libiptc . . . . . . . $with_libiptc
      libjvm  . . . . . . . $with_java
      libkstat  . . . . . . $with_kstat
      libkvm  . . . . . . . $with_libkvm
 +    libldap . . . . . . . $with_libldap
      liblvm2app  . . . . . $with_liblvm2app
      libmemcached  . . . . $with_libmemcached
      libmnl  . . . . . . . $with_libmnl
      libpq . . . . . . . . $with_libpq
      libpthread  . . . . . $with_libpthread
      librabbitmq . . . . . $with_librabbitmq
 +    librdkafka  . . . . . $with_librdkafka
      librouteros . . . . . $with_librouteros
      librrd  . . . . . . . $with_librrd
      libsensors  . . . . . $with_libsensors
      libsigrok   . . . . . $with_libsigrok
      libstatgrab . . . . . $with_libstatgrab
      libtokyotyrant  . . . $with_libtokyotyrant
 +    libudev . . . . . . . $with_libudev
      libupsclient  . . . . $with_libupsclient
      libvarnish  . . . . . $with_libvarnish
      libvirt . . . . . . . $with_libvirt
      amqp    . . . . . . . $enable_amqp
      apache  . . . . . . . $enable_apache
      apcups  . . . . . . . $enable_apcups
 -    aquaero . . . . . . . $enable_aquaero
      apple_sensors . . . . $enable_apple_sensors
 +    aquaero . . . . . . . $enable_aquaero
      ascent  . . . . . . . $enable_ascent
 +    barometer . . . . . . $enable_barometer
      battery . . . . . . . $enable_battery
      bind  . . . . . . . . $enable_bind
 +    ceph  . . . . . . . . $enable_ceph
 +    cgroups . . . . . . . $enable_cgroups
      conntrack . . . . . . $enable_conntrack
      contextswitch . . . . $enable_contextswitch
 -    cgroups . . . . . . . $enable_cgroups
      cpu . . . . . . . . . $enable_cpu
      cpufreq . . . . . . . $enable_cpufreq
      csv . . . . . . . . . $enable_csv
      df  . . . . . . . . . $enable_df
      disk  . . . . . . . . $enable_disk
      dns . . . . . . . . . $enable_dns
 +    drbd  . . . . . . . . $enable_drbd
      email . . . . . . . . $enable_email
      entropy . . . . . . . $enable_entropy
      ethstat . . . . . . . $enable_ethstat
      exec  . . . . . . . . $enable_exec
 +    fhcount . . . . . . . $enable_fhcount
      filecount . . . . . . $enable_filecount
      fscache . . . . . . . $enable_fscache
      gmond . . . . . . . . $enable_gmond
      hddtemp . . . . . . . $enable_hddtemp
      interface . . . . . . $enable_interface
 +    ipc . . . . . . . . . $enable_ipc
      ipmi  . . . . . . . . $enable_ipmi
      iptables  . . . . . . $enable_iptables
      ipvs  . . . . . . . . $enable_ipvs
      irq . . . . . . . . . $enable_irq
      java  . . . . . . . . $enable_java
 -    libvirt . . . . . . . $enable_libvirt
      load  . . . . . . . . $enable_load
      logfile . . . . . . . $enable_logfile
 +    log_logstash  . . . . $enable_log_logstash
      lpar  . . . . . . . . $enable_lpar
      lvm . . . . . . . . . $enable_lvm
      madwifi . . . . . . . $enable_madwifi
      nut . . . . . . . . . $enable_nut
      olsrd . . . . . . . . $enable_olsrd
      onewire . . . . . . . $enable_onewire
 +    openldap  . . . . . . $enable_openldap
      openvpn . . . . . . . $enable_openvpn
      oracle  . . . . . . . $enable_oracle
      perl  . . . . . . . . $enable_perl
      sensors . . . . . . . $enable_sensors
      serial  . . . . . . . $enable_serial
      sigrok  . . . . . . . $enable_sigrok
 +    smart . . . . . . . . $enable_smart
      snmp  . . . . . . . . $enable_snmp
      statsd  . . . . . . . $enable_statsd
      swap  . . . . . . . . $enable_swap
      syslog  . . . . . . . $enable_syslog
      table . . . . . . . . $enable_table
 -    tail  . . . . . . . . $enable_tail
      tail_csv  . . . . . . $enable_tail_csv
 +    tail  . . . . . . . . $enable_tail
      tape  . . . . . . . . $enable_tape
      target_notification . $enable_target_notification
      target_replace  . . . $enable_target_replace
      thermal . . . . . . . $enable_thermal
      threshold . . . . . . $enable_threshold
      tokyotyrant . . . . . $enable_tokyotyrant
 +    turbostat . . . . . . $enable_turbostat
      unixsock  . . . . . . $enable_unixsock
      uptime  . . . . . . . $enable_uptime
      users . . . . . . . . $enable_users
      uuid  . . . . . . . . $enable_uuid
      varnish . . . . . . . $enable_varnish
 +    virt  . . . . . . . . $enable_virt
      vmem  . . . . . . . . $enable_vmem
      vserver . . . . . . . $enable_vserver
      wireless  . . . . . . $enable_wireless
      write_graphite  . . . $enable_write_graphite
      write_http  . . . . . $enable_write_http
 +    write_kafka . . . . . $enable_write_kafka
 +    write_log . . . . . . $enable_write_log
      write_mongodb . . . . $enable_write_mongodb
      write_redis . . . . . $enable_write_redis
      write_riemann . . . . $enable_write_riemann
 +    write_sensu . . . . . $enable_write_sensu
 +    write_tsdb  . . . . . $enable_write_tsdb
      xmms  . . . . . . . . $enable_xmms
      zfs_arc . . . . . . . $enable_zfs_arc
 +    zookeeper . . . . . . $enable_zookeeper
  
  EOF
  
diff --combined src/snmp.c
@@@ -2,23 -2,18 +2,23 @@@
   * collectd - src/snmp.c
   * Copyright (C) 2007-2012  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
 - * Free Software Foundation; only version 2 of the License is applicable.
 + * 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:
   *
 - * 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
 - * General Public License for more details.
 + * The above copyright notice and this permission notice shall be included in
 + * all copies or substantial portions of the Software.
   *
 - * You should have received a copy of the GNU General Public License along
 - * with this program; if not, write to the Free Software Foundation, Inc.,
 - * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 + * 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.
   *
   * Authors:
   *   Florian octo Forster <octo at collectd.org>
@@@ -34,8 -29,6 +34,8 @@@
  #include <net-snmp/net-snmp-config.h>
  #include <net-snmp/net-snmp-includes.h>
  
 +#include <fnmatch.h>
 +
  /*
   * Private data structes
   */
@@@ -57,7 -50,7 +57,7 @@@ struct data_definition_
  {
    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;
@@@ -65,9 -58,6 +65,9 @@@
    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;
  
@@@ -75,22 -65,8 +75,22 @@@ struct host_definition_
  {
    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;
@@@ -207,10 -183,6 +207,10 @@@ static void csnmp_host_definition_destr
    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);
   *  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)
  {
    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));
    }
  
  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)
    {
      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)
    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)
  {
    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;
  
      oconfig_item_t *option = ci->children + i;
  
      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)
      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);
      sfree (dd->name);
      sfree (dd->instance_prefix);
      sfree (dd->values);
 +    sfree (dd->ignores);
      sfree (dd);
      return (-1);
    }
    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;
    }
  
    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);
    }
  
@@@ -550,92 -589,6 +550,92 @@@ static int csnmp_config_add_host_collec
    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;
    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);
    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;
      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);
        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) */
@@@ -820,75 -723,15 +820,75 @@@ static int csnmp_config (oconfig_item_
  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);
@@@ -992,8 -835,7 +992,8 @@@ static value_t csnmp_value_list_to_valu
        status = parse_value (string, &ret, type);
        if (status != 0)
        {
 -        ERROR ("snmp plugin: csnmp_value_list_to_value: Parsing string as %s failed: %s",
 +        ERROR ("snmp plugin: host %s: csnmp_value_list_to_value: Parsing string as %s failed: %s",
 +            (host_name != NULL) ? host_name : "UNKNOWN",
              DS_TYPE_TO_STRING (type), string);
        }
      }
@@@ -1128,8 -970,6 +1128,8 @@@ static int csnmp_instance_list_add (csn
    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;
      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))
@@@ -1548,8 -1366,7 +1548,8 @@@ static int csnmp_read_table (host_defin
          if (csnmp_instance_list_add (&instance_list_head, &instance_list_tail,
                res, host, data) != 0)
          {
 -          ERROR ("snmp plugin: csnmp_instance_list_add failed.");
 +          ERROR ("snmp plugin: host %s: csnmp_instance_list_add failed.",
 +              host->name);
            status = -1;
            break;
          }
@@@ -1671,7 -1488,7 +1671,7 @@@ static int csnmp_read_value (host_defin
  
    if (host->sess_handle == NULL)
    {
-     DEBUG ("snmp plugin: csnmp_read_table: host->sess_handle == NULL");
+     DEBUG ("snmp plugin: csnmp_read_value: host->sess_handle == NULL");
      return (-1);
    }
  
@@@ -1845,7 -1662,6 +1845,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;