Merge branch 'collectd-5.4' into collectd-5.5
authorRuben Kerkhof <ruben@rubenkerkhof.com>
Fri, 26 Feb 2016 21:53:19 +0000 (22:53 +0100)
committerRuben Kerkhof <ruben@rubenkerkhof.com>
Fri, 26 Feb 2016 21:53:19 +0000 (22:53 +0100)
1  2 
configure.ac
src/apache.c
src/collectd.conf.in
src/modbus.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])
  
@@@ -44,6 -44,7 +44,7 @@@ AC_SYS_LARGEFIL
  #
  AC_PROG_CC
  AC_PROG_CPP
+ AC_PROG_EGREP
  AC_PROG_INSTALL
  AC_PROG_LN_S
  AC_PROG_MAKE_SET
@@@ -60,6 -61,18 +61,18 @@@ m4_pattern_forbid([^_?PKG_[A-Z_]+$],[**
  
  PKG_PROG_PKG_CONFIG
  
+ AC_CACHE_CHECK([if bison is the parser generator],
+       [collectd_cv_prog_bison],
+       [AS_IF([$YACC --version 2>/dev/null | $EGREP -q '^bison '],
+               [collectd_cv_prog_bison=yes], [collectd_cv_prog_bison=no]
+       )]
+ )
+ if test "x$collectd_cv_prog_bison" = "xno" && test ! -f "${srcdir}/liboconfig/parser.c"
+ then
+       AC_MSG_ERROR([bison is missing and you do not have ${srcdir}/liboconfig/parser.c. Please install bison])
+ fi
  AC_CHECK_PROG([have_protoc_c], [protoc-c], [yes], [no])
  if test "x$have_protoc_c" = "xno"
  then
@@@ -92,11 -105,9 +105,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])
@@@ -135,20 -139,7 +148,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.])
@@@ -459,6 -450,18 +472,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
@@@ -598,7 -601,7 +611,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)
@@@ -663,51 -666,20 +676,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
  
@@@ -914,9 -886,7 +927,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);
@@@ -1111,7 -1079,7 +1124,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;
@@@ -1166,7 -1134,7 +1179,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);
@@@ -1215,7 -1183,7 +1228,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"
@@@ -1368,7 -1325,7 +1381,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
@@@ -1424,7 -1381,7 +1437,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")
  # }}}
@@@ -2095,7 -2035,10 +2108,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
@@@ -2360,64 -2325,6 +2373,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=""
@@@ -2452,7 -2359,7 +2465,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"
@@@ -2856,15 -2763,6 +2869,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)"],
@@@ -2988,7 -2886,7 +3001,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"
@@@ -3215,7 -3113,7 +3228,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"
@@@ -3226,7 -3124,7 +3239,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
  # }}}
  
@@@ -4362,7 -4164,7 +4375,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
@@@ -5219,10 -4911,8 +5232,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"
@@@ -5232,17 -4922,15 +5245,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"
@@@ -5256,15 -4944,12 +5269,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:])
  
@@@ -5605,10 -5245,8 +5618,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])
@@@ -5621,27 -5259,24 +5634,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])
@@@ -5671,7 -5306,6 +5684,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])
@@@ -5684,14 -5318,13 +5697,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])
@@@ -5711,34 -5344,26 +5724,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"
@@@ -5883,7 -5498,7 +5896,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" \
@@@ -5916,21 -5531,18 +5929,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/apache.c
@@@ -18,7 -18,7 +18,7 @@@
   * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
   *
   * Authors:
 - *   Florian octo Forster <octo at verplant.org>
 + *   Florian octo Forster <octo at collectd.org>
   *   Florent EppO Monbillard <eppo at darox.net>
   *   - connections/lighttpd extension
   *   Amit Gupta <amit.gupta221 at gmail.com>
@@@ -45,16 -45,14 +45,16 @@@ struct apache_
        char *url;
        char *user;
        char *pass;
 -      int   verify_peer;
 -      int   verify_host;
 +      _Bool verify_peer;
 +      _Bool verify_host;
        char *cacert;
 +      char *ssl_ciphers;
        char *server; /* user specific server type */
        char *apache_buffer;
        char apache_curl_error[CURL_ERROR_SIZE];
        size_t apache_buffer_size;
        size_t apache_buffer_fill;
 +      int timeout;
        CURL *curl;
  }; /* apache_s */
  
@@@ -74,7 -72,6 +74,7 @@@ static void apache_free (apache_t *st
        sfree (st->user);
        sfree (st->pass);
        sfree (st->cacert);
 +      sfree (st->ssl_ciphers);
        sfree (st->server);
        sfree (st->apache_buffer);
        if (st->curl) {
@@@ -169,23 -166,94 +169,23 @@@ static size_t apache_header_callback (v
   *   URL ...
   * </Plugin>
   */
 -static int config_set_string (char **ret_string, /* {{{ */
 -                                  oconfig_item_t *ci)
 -{
 -      char *string;
 -
 -      if ((ci->values_num != 1)
 -                      || (ci->values[0].type != OCONFIG_TYPE_STRING))
 -      {
 -              WARNING ("apache plugin: The `%s' config option "
 -                              "needs exactly one string argument.", ci->key);
 -              return (-1);
 -      }
 -
 -      string = strdup (ci->values[0].value.string);
 -      if (string == NULL)
 -      {
 -              ERROR ("apache plugin: strdup failed.");
 -              return (-1);
 -      }
 -
 -      if (*ret_string != NULL)
 -              free (*ret_string);
 -      *ret_string = string;
 -
 -      return (0);
 -} /* }}} int config_set_string */
 -
 -static int config_set_boolean (int *ret_boolean, /* {{{ */
 -                                  oconfig_item_t *ci)
 -{
 -      if ((ci->values_num != 1)
 -                      || ((ci->values[0].type != OCONFIG_TYPE_BOOLEAN)
 -                              && (ci->values[0].type != OCONFIG_TYPE_STRING)))
 -      {
 -              WARNING ("apache plugin: The `%s' config option "
 -                              "needs exactly one boolean argument.", ci->key);
 -              return (-1);
 -      }
 -
 -      if (ci->values[0].type == OCONFIG_TYPE_BOOLEAN)
 -      {
 -              if (ci->values[0].value.boolean)
 -                      *ret_boolean = 1;
 -              else
 -                      *ret_boolean = 0;
 -      }
 -      else /* if (ci->values[0].type != OCONFIG_TYPE_STRING) */
 -      {
 -              char *string = ci->values[0].value.string;
 -              if (IS_TRUE (string))
 -                      *ret_boolean = 1;
 -              else if (IS_FALSE (string))
 -                      *ret_boolean = 0;
 -              else
 -              {
 -                      ERROR ("apache plugin: Cannot parse string "
 -                                      "as boolean value: %s", string);
 -                      return (-1);
 -              }
 -      }
 -
 -      return (0);
 -} /* }}} int config_set_boolean */
 -
  static int config_add (oconfig_item_t *ci)
  {
        apache_t *st;
        int i;
        int status;
  
 -      if ((ci->values_num != 1)
 -              || (ci->values[0].type != OCONFIG_TYPE_STRING))
 -      {
 -              WARNING ("apache plugin: The `%s' config option "
 -                      "needs exactly one string argument.", ci->key);
 -              return (-1);
 -      }
 -
 -      st = (apache_t *) malloc (sizeof (*st));
 +      st = malloc (sizeof (*st));
        if (st == NULL)
        {
                ERROR ("apache plugin: malloc failed.");
                return (-1);
        }
 -
        memset (st, 0, sizeof (*st));
  
 -      status = config_set_string (&st->name, ci);
 +      st->timeout = -1;
 +
 +      status = cf_util_get_string (ci, &st->name);
        if (status != 0)
        {
                sfree (st);
                oconfig_item_t *child = ci->children + i;
  
                if (strcasecmp ("URL", child->key) == 0)
 -                      status = config_set_string (&st->url, child);
 +                      status = cf_util_get_string (child, &st->url);
                else if (strcasecmp ("Host", child->key) == 0)
 -                      status = config_set_string (&st->host, child);
 +                      status = cf_util_get_string (child, &st->host);
                else if (strcasecmp ("User", child->key) == 0)
 -                      status = config_set_string (&st->user, child);
 +                      status = cf_util_get_string (child, &st->user);
                else if (strcasecmp ("Password", child->key) == 0)
 -                      status = config_set_string (&st->pass, child);
 +                      status = cf_util_get_string (child, &st->pass);
                else if (strcasecmp ("VerifyPeer", child->key) == 0)
 -                      status = config_set_boolean (&st->verify_peer, child);
 +                      status = cf_util_get_boolean (child, &st->verify_peer);
                else if (strcasecmp ("VerifyHost", child->key) == 0)
 -                      status = config_set_boolean (&st->verify_host, child);
 +                      status = cf_util_get_boolean (child, &st->verify_host);
                else if (strcasecmp ("CACert", child->key) == 0)
 -                      status = config_set_string (&st->cacert, child);
 +                      status = cf_util_get_string (child, &st->cacert);
 +              else if (strcasecmp ("SSLCiphers", child->key) == 0)
 +                      status = cf_util_get_string (child, &st->ssl_ciphers);
                else if (strcasecmp ("Server", child->key) == 0)
 -                      status = config_set_string (&st->server, child);
 +                      status = cf_util_get_string (child, &st->server);
 +              else if (strcasecmp ("Timeout", child->key) == 0)
 +                      status = cf_util_get_int (child, &st->timeout);
                else
                {
                        WARNING ("apache plugin: Option `%s' not allowed here.",
  
        if (status != 0)
        {
 -              apache_free(st);
 +              apache_free (st);
                return (-1);
        }
  
@@@ -293,6 -357,8 +293,6 @@@ static int config (oconfig_item_t *ci
  /* initialize curl for each host */
  static int init_host (apache_t *st) /* {{{ */
  {
 -      static char credentials[1024];
 -
        assert (st->url != NULL);
        /* (Assured by `config_add') */
  
                curl_easy_setopt (st->curl, CURLOPT_WRITEHEADER, st);
        }
  
 -      curl_easy_setopt (st->curl, CURLOPT_USERAGENT, PACKAGE_NAME"/"PACKAGE_VERSION);
 +      curl_easy_setopt (st->curl, CURLOPT_USERAGENT, COLLECTD_USERAGENT);
        curl_easy_setopt (st->curl, CURLOPT_ERRORBUFFER, st->apache_curl_error);
  
        if (st->user != NULL)
        {
 +#ifdef HAVE_CURLOPT_USERNAME
 +              curl_easy_setopt (st->curl, CURLOPT_USERNAME, st->user);
 +              curl_easy_setopt (st->curl, CURLOPT_PASSWORD,
 +                              (st->pass == NULL) ? "" : st->pass);
 +#else
 +              static char credentials[1024];
                int status;
  
                status = ssnprintf (credentials, sizeof (credentials), "%s:%s",
                }
  
                curl_easy_setopt (st->curl, CURLOPT_USERPWD, credentials);
 +#endif
        }
  
        curl_easy_setopt (st->curl, CURLOPT_URL, st->url);
        curl_easy_setopt (st->curl, CURLOPT_FOLLOWLOCATION, 1L);
        curl_easy_setopt (st->curl, CURLOPT_MAXREDIRS, 50L);
  
 -      if (st->verify_peer != 0)
 -      {
 -              curl_easy_setopt (st->curl, CURLOPT_SSL_VERIFYPEER, 1L);
 -      }
 -      else
 -      {
 -              curl_easy_setopt (st->curl, CURLOPT_SSL_VERIFYPEER, 0L);
 -      }
 -
 -      if (st->verify_host != 0)
 -      {
 -              curl_easy_setopt (st->curl, CURLOPT_SSL_VERIFYHOST, 2L);
 -      }
 -      else
 -      {
 -              curl_easy_setopt (st->curl, CURLOPT_SSL_VERIFYHOST, 0L);
 -      }
 -
 +      curl_easy_setopt (st->curl, CURLOPT_SSL_VERIFYPEER,
 +                      (long) st->verify_peer);
 +      curl_easy_setopt (st->curl, CURLOPT_SSL_VERIFYHOST,
 +                      st->verify_host ? 2L : 0L);
        if (st->cacert != NULL)
 -      {
                curl_easy_setopt (st->curl, CURLOPT_CAINFO, st->cacert);
 -      }
 +      if (st->ssl_ciphers != NULL)
 +              curl_easy_setopt (st->curl, CURLOPT_SSL_CIPHER_LIST,st->ssl_ciphers);
 +
 +#ifdef HAVE_CURLOPT_TIMEOUT_MS
 +      if (st->timeout >= 0)
 +              curl_easy_setopt (st->curl, CURLOPT_TIMEOUT_MS, (long) st->timeout);
 +      else
 +              curl_easy_setopt (st->curl, CURLOPT_TIMEOUT_MS,
 +                              CDTIME_T_TO_MS(plugin_get_interval()));
 +#endif
  
        return (0);
  } /* }}} int init_host */
@@@ -531,13 -596,16 +531,16 @@@ static int apache_read_host (user_data_
  
        st = user_data->data;
  
+       int status;
+       char *content_type;
+       static const char *text_plain = "text/plain";
        assert (st->url != NULL);
        /* (Assured by `config_add') */
  
        if (st->curl == NULL)
        {
-               int status;
                status = init_host (st);
                if (status != 0)
                        return (-1);
                st->server_type = APACHE;
        }
  
+       status = curl_easy_getinfo (st->curl, CURLINFO_CONTENT_TYPE, &content_type);
+       if ((status == CURLE_OK) && (content_type != NULL) &&
+           (strncasecmp (content_type, text_plain, strlen (text_plain)) != 0))
+       {
+               WARNING ("apache plugin: `Content-Type' response header is not `%s' "
+                       "(received: `%s'). Expecting unparseable data. Please check `URL' "
+                       "parameter (missing `?auto' suffix ?)",
+                       text_plain, content_type);
+       }
        ptr = st->apache_buffer;
        saveptr = NULL;
        while ((line = strtok_r (ptr, "\n\r", &saveptr)) != NULL)
diff --combined src/collectd.conf.in
  #AutoLoadPlugin false
  
  #----------------------------------------------------------------------------#
 +# When enabled, internal statistics are collected, using "collectd" as the   #
 +# plugin name.                                                               #
 +# Disabled by default.                                                       #
 +#----------------------------------------------------------------------------#
 +#CollectInternalStats false
 +
 +#----------------------------------------------------------------------------#
  # Interval at which to query values. This may be overwritten on a per-plugin #
  # base by using the 'Interval' option of the LoadPlugin block:               #
  #   <LoadPlugin foo>                                                         #
  #----------------------------------------------------------------------------#
  #Interval     10
  
 -#Timeout      2
 -#ReadThreads  5
 -#WriteThreads 5
 +#MaxReadInterval 86400
 +#Timeout         2
 +#ReadThreads     5
 +#WriteThreads    5
  
  # Limit the size of the write queue. Default is no limit. Setting up a limit is
  # recommended for servers handling a high volume of traffic.
@@@ -60,7 -52,6 +60,7 @@@
  
  @LOAD_PLUGIN_SYSLOG@LoadPlugin syslog
  @LOAD_PLUGIN_LOGFILE@LoadPlugin logfile
 +@LOAD_PLUGIN_LOG_LOGSTASH@LoadPlugin log_logstash
  
  #<Plugin logfile>
  #     LogLevel @DEFAULT_LOG_LEVEL@
  #     PrintSeverity false
  #</Plugin>
  
 +#<Plugin log_logstash>
 +#     LogLevel @DEFAULT_LOG_LEVEL@
 +#     File "@localstatedir@/log/@PACKAGE_NAME@.json.log"
 +#</Plugin>
 +
  #<Plugin syslog>
  #     LogLevel @DEFAULT_LOG_LEVEL@
  #</Plugin>
@@@ -84,7 -70,7 +84,7 @@@
  # Lines beginning with a single `#' belong to plugins which have been built  #
  # but are disabled by default.                                               #
  #                                                                            #
- # Lines begnning with `##' belong to plugins which have not been built due   #
+ # Lines beginning with `##' belong to plugins which have not been built due  #
  # to missing dependencies or because they have been deactivated explicitly.  #
  ##############################################################################
  
  #@BUILD_PLUGIN_APPLE_SENSORS_TRUE@LoadPlugin apple_sensors
  #@BUILD_PLUGIN_AQUAERO_TRUE@LoadPlugin aquaero
  #@BUILD_PLUGIN_ASCENT_TRUE@LoadPlugin ascent
 +#@BUILD_PLUGIN_BAROMETER_TRUE@LoadPlugin barometer
  #@BUILD_PLUGIN_BATTERY_TRUE@LoadPlugin battery
  #@BUILD_PLUGIN_BIND_TRUE@LoadPlugin bind
 +#@BUILD_PLUGIN_CEPH_TRUE@LoadPlugin ceph
 +#@BUILD_PLUGIN_CGROUPS_TRUE@LoadPlugin cgroups
  #@BUILD_PLUGIN_CONNTRACK_TRUE@LoadPlugin conntrack
  #@BUILD_PLUGIN_CONTEXTSWITCH_TRUE@LoadPlugin contextswitch
 -#@BUILD_PLUGIN_CGROUPS_TRUE@LoadPlugin cgroups
  @BUILD_PLUGIN_CPU_TRUE@@BUILD_PLUGIN_CPU_TRUE@LoadPlugin cpu
  #@BUILD_PLUGIN_CPUFREQ_TRUE@LoadPlugin cpufreq
  @LOAD_PLUGIN_CSV@LoadPlugin csv
  #@BUILD_PLUGIN_DF_TRUE@LoadPlugin df
  #@BUILD_PLUGIN_DISK_TRUE@LoadPlugin disk
  #@BUILD_PLUGIN_DNS_TRUE@LoadPlugin dns
 +#@BUILD_PLUGIN_DRBD_TRUE@LoadPlugin drbd
  #@BUILD_PLUGIN_EMAIL_TRUE@LoadPlugin email
  #@BUILD_PLUGIN_ENTROPY_TRUE@LoadPlugin entropy
  #@BUILD_PLUGIN_ETHSTAT_TRUE@LoadPlugin ethstat
  #@BUILD_PLUGIN_EXEC_TRUE@LoadPlugin exec
 +#@BUILD_PLUGIN_FHCOUNT_TRUE@LoadPlugin fhcount
  #@BUILD_PLUGIN_FILECOUNT_TRUE@LoadPlugin filecount
  #@BUILD_PLUGIN_FSCACHE_TRUE@LoadPlugin fscache
  #@BUILD_PLUGIN_GMOND_TRUE@LoadPlugin gmond
  #@BUILD_PLUGIN_HDDTEMP_TRUE@LoadPlugin hddtemp
  @BUILD_PLUGIN_INTERFACE_TRUE@@BUILD_PLUGIN_INTERFACE_TRUE@LoadPlugin interface
 -#@BUILD_PLUGIN_IPTABLES_TRUE@LoadPlugin iptables
 +#@BUILD_PLUGIN_IPC_TRUE@@BUILD_PLUGIN_IPC_TRUE@LoadPlugin ipc
  #@BUILD_PLUGIN_IPMI_TRUE@LoadPlugin ipmi
 +#@BUILD_PLUGIN_IPTABLES_TRUE@LoadPlugin iptables
  #@BUILD_PLUGIN_IPVS_TRUE@LoadPlugin ipvs
  #@BUILD_PLUGIN_IRQ_TRUE@LoadPlugin irq
  #@BUILD_PLUGIN_JAVA_TRUE@LoadPlugin java
 -#@BUILD_PLUGIN_LIBVIRT_TRUE@LoadPlugin libvirt
  @BUILD_PLUGIN_LOAD_TRUE@@BUILD_PLUGIN_LOAD_TRUE@LoadPlugin load
  #@BUILD_PLUGIN_LPAR_TRUE@LoadPlugin lpar
  #@BUILD_PLUGIN_LVM_TRUE@LoadPlugin lvm
  #@BUILD_PLUGIN_MEMCACHEC_TRUE@LoadPlugin memcachec
  #@BUILD_PLUGIN_MEMCACHED_TRUE@LoadPlugin memcached
  @BUILD_PLUGIN_MEMORY_TRUE@@BUILD_PLUGIN_MEMORY_TRUE@LoadPlugin memory
 +#@BUILD_PLUGIN_MIC_TRUE@LoadPlugin mic
  #@BUILD_PLUGIN_MODBUS_TRUE@LoadPlugin modbus
  #@BUILD_PLUGIN_MULTIMETER_TRUE@LoadPlugin multimeter
  #@BUILD_PLUGIN_MYSQL_TRUE@LoadPlugin mysql
  #@BUILD_PLUGIN_NUT_TRUE@LoadPlugin nut
  #@BUILD_PLUGIN_OLSRD_TRUE@LoadPlugin olsrd
  #@BUILD_PLUGIN_ONEWIRE_TRUE@LoadPlugin onewire
 +#@BUILD_PLUGIN_OPENLDAP_TRUE@LoadPlugin openldap
  #@BUILD_PLUGIN_OPENVPN_TRUE@LoadPlugin openvpn
  #@BUILD_PLUGIN_ORACLE_TRUE@LoadPlugin oracle
  #@BUILD_PLUGIN_PERL_TRUE@LoadPlugin perl
  #@BUILD_PLUGIN_SENSORS_TRUE@LoadPlugin sensors
  #@BUILD_PLUGIN_SERIAL_TRUE@LoadPlugin serial
  #@BUILD_PLUGIN_SIGROK_TRUE@LoadPlugin sigrok
 +#@BUILD_PLUGIN_SMART_TRUE@LoadPlugin smart
  #@BUILD_PLUGIN_SNMP_TRUE@LoadPlugin snmp
  #@BUILD_PLUGIN_STATSD_TRUE@LoadPlugin statsd
  #@BUILD_PLUGIN_SWAP_TRUE@LoadPlugin swap
  #@BUILD_PLUGIN_TED_TRUE@LoadPlugin ted
  #@BUILD_PLUGIN_THERMAL_TRUE@LoadPlugin thermal
  #@BUILD_PLUGIN_TOKYOTYRANT_TRUE@LoadPlugin tokyotyrant
 +#@BUILD_PLUGIN_TURBOSTAT_TRUE@LoadPlugin turbostat
  #@BUILD_PLUGIN_UNIXSOCK_TRUE@LoadPlugin unixsock
  #@BUILD_PLUGIN_UPTIME_TRUE@LoadPlugin uptime
  #@BUILD_PLUGIN_USERS_TRUE@LoadPlugin users
  #@BUILD_PLUGIN_UUID_TRUE@LoadPlugin uuid
  #@BUILD_PLUGIN_VARNISH_TRUE@LoadPlugin varnish
 -#@BUILD_PLUGIN_MIC_TRUE@LoadPlugin mic
 +#@BUILD_PLUGIN_VIRT_TRUE@LoadPlugin virt
  #@BUILD_PLUGIN_VMEM_TRUE@LoadPlugin vmem
  #@BUILD_PLUGIN_VSERVER_TRUE@LoadPlugin vserver
  #@BUILD_PLUGIN_WIRELESS_TRUE@LoadPlugin wireless
  #@BUILD_PLUGIN_WRITE_GRAPHITE_TRUE@LoadPlugin write_graphite
  #@BUILD_PLUGIN_WRITE_HTTP_TRUE@LoadPlugin write_http
 +#@BUILD_PLUGIN_WRITE_KAFKA_TRUE@LoadPlugin write_kafka
 +#@BUILD_PLUGIN_WRITE_LOG_TRUE@LoadPlugin write_log
  #@BUILD_PLUGIN_WRITE_MONGODB_TRUE@LoadPlugin write_mongodb
  #@BUILD_PLUGIN_WRITE_REDIS_TRUE@LoadPlugin write_redis
  #@BUILD_PLUGIN_WRITE_RIEMANN_TRUE@LoadPlugin write_riemann
 +#@BUILD_PLUGIN_WRITE_SENSU_TRUE@LoadPlugin write_sensu
 +#@BUILD_PLUGIN_WRITE_TSDB_TRUE@LoadPlugin write_tsdb
  #@BUILD_PLUGIN_XMMS_TRUE@LoadPlugin xmms
  #@BUILD_PLUGIN_ZFS_ARC_TRUE@LoadPlugin zfs_arc
 +#@BUILD_PLUGIN_ZOOKEEPER_TRUE@LoadPlugin zookeeper
  
  ##############################################################################
  # Plugin configuration                                                       #
  # ription of those options is available in the collectd.conf(5) manual page. #
  ##############################################################################
  
 -#<Plugin "aggregation">
 +#<Plugin aggregation>
  #  <Aggregation>
  #    #Host "unspecified"
  #    Plugin "cpu"
  #  </Aggregation>
  #</Plugin>
  
 -#<Plugin "amqp">
 +#<Plugin amqp>
  #  <Publish "name">
  #    Host "localhost"
  #    Port "5672"
  #    RoutingKey "collectd"
  #    Persistent false
  #    StoreRates false
 +#    ConnectionRetryDelay 0
  #  </Publish>
  #</Plugin>
  
  #     CACert "/etc/ssl/ca.crt"
  #</Plugin>
  
 +#<Plugin "barometer">
 +#   Device            "/dev/i2c-0";
 +#   Oversampling      512
 +#   PressureOffset    0.0
 +#   TemperatureOffset 0.0
 +#   Normalization     2
 +#   Altitude          238.0
 +#   TemperatureSensor "myserver/onewire-F10FCA000800/temperature"
 +#</Plugin>
 +
 +#<Plugin "battery">
 +#  ValuesPercentage false
 +#  ReportDegraded false
 +#</Plugin>
 +
  #<Plugin "bind">
  #  URL "http://localhost:8053/"
  #  ParseTime       false
  #  </View>
  #</Plugin>
  
 +#<Plugin ceph>
 +#  LongRunAvgLatency false
 +#  ConvertSpecialMetricTypes true
 +#  <Daemon "osd.0">
 +#    SocketPath "/var/run/ceph/ceph-osd.0.asok"
 +#  </Daemon>
 +#  <Daemon "osd.1">
 +#    SocketPath "/var/run/ceph/ceph-osd.1.asok"
 +#  </Daemon>
 +#  <Daemon "mon.a">
 +#    SocketPath "/var/run/ceph/ceph-mon.ceph1.asok"
 +#  </Daemon>
 +#  <Daemon "mds.a">
 +#    SocketPath "/var/run/ceph/ceph-mds.ceph1.asok"
 +#  </Daemon>
 +#</Plugin>
 +
  #<Plugin cgroups>
  #  CGroup "libvirt"
  #  IgnoreSelected false
  #</Plugin>
  
 +#<Plugin cpu>
 +#  ReportByCpu true
 +#  ReportByState true
 +#  ValuesPercentage false
 +#</Plugin>
 +#
  #<Plugin csv>
  #     DataDir "@localstatedir@/lib/@PACKAGE_NAME@/csv"
  #     StoreRates false
  #    URL "http://finance.google.com/finance?q=NYSE%3AAMD"
  #    User "foo"
  #    Password "bar"
 +#    Digest false
 +#    VerifyPeer true
 +#    VerifyHost true
 +#    CACert "/path/to/ca.crt"
 +#    Header "X-Custom-Header: foobar"
 +#    Post "foo=bar"
 +#
  #    MeasureResponseTime false
 +#    MeasureResponseCode false
  #    <Match>
  #      Regex "<span +class=\"pr\"[^>]*> *([0-9]*\\.[0-9]+) *</span>"
  #      DSType "GaugeAverage"
  #  </URL>
  #</Plugin>
  
 -#<Plugin "curl_xml">
 +#<Plugin curl_xml>
  #  <URL "http://localhost/stats.xml">
  #    Host "my_host"
  #    Instance "some_instance"
  #    User "collectd"
  #    Password "thaiNg0I"
 +#    Digest false
  #    VerifyPeer true
  #    VerifyHost true
  #    CACert "/path/to/ca.crt"
 +#    Header "X-Custom-Header: foobar"
 +#    Post "foo=bar"
  #
  #    <XPath "table[@id=\"magic_level\"]/tr">
  #      Type "magic_level"
  #<Plugin disk>
  #     Disk "/^[hs]d[a-f][0-9]?$/"
  #     IgnoreSelected false
 +#     UseBSDName false
 +#     UdevNameAttr "DEVNAME"
  #</Plugin>
  
  #<Plugin dns>
  #     NotificationExec "user:group" "/path/to/exec"
  #</Plugin>
  
 +#<Plugin fhcount>
 +#     ValuesAbsolute true
 +#     ValuesPercentage false
 +#</Plugin>
 +
  #<Plugin filecount>
  #     <Directory "/path/to/dir">
  #             Instance "foodir"
  #     </Directory>
  #</Plugin>
  
 -#<Plugin "gmond">
 +#<Plugin gmond>
  #  MCReceiveFrom "239.2.11.71" "8649"
  #  <Metric "swap_total">
  #    Type "swap"
  #     IgnoreSelected true
  #</Plugin>
  
 -#<Plugin "java">
 +#<Plugin java>
  #     JVMArg "-verbose:jni"
  #     JVMArg "-Djava.class.path=@prefix@/share/collectd/java/collectd-api.jar"
  #
  #     </Plugin>
  #</Plugin>
  
 -#<Plugin libvirt>
 -#     Connection "xen:///"
 -#     RefreshInterval 60
 -#     Domain "name"
 -#     BlockDevice "name:device"
 -#     InterfaceDevice "name:device"
 -#     IgnoreSelected false
 -#     HostnameFormat name
 -#     InterfaceFormat name
 +#<Plugin load>
 +#        ReportRelative true
  #</Plugin>
  
  #<Plugin lpar>
  #     </Instance>
  #</Plugin>
  
 +#<Plugin memory>
 +#     ValuesAbsolute true
 +#     ValuesPercentage false
 +#</Plugin>
 +
  #<Plugin modbus>
  #     <Data "data_name">
  #             RegisterBase 1234
 +#             RegisterCmd ReadHolding
  #             RegisterType float
  #             Type gauge
  #             Instance "..."
  #             Password "secret"
  #             Database "db_name"
  #             MasterStats true
 +#             ConnectTimeout 10
 +#             InnodbStats true
  #     </Database>
  #
  #     <Database db_name2>
 +#             Alias "squeeze"
  #             Host "localhost"
  #             Socket "/var/run/mysql/mysqld.sock"
  #             SlaveStats true
  #             Username "user"
  #             Password "secret"
  #             Interface "eth0"
 +#             ResolveInterval 14400
  @LOAD_PLUGIN_NETWORK@ </Server>
  #     TimeToLive 128
  #
  #     IgnoreSelected false
  #</Plugin>
  
 +#<Plugin openldap>
 +#  <Instance "localhost">
 +#    URL "ldap://localhost:389"
 +#    StartTLS false
 +#    VerifyHost true
 +#    CACert "/path/to/ca.crt"
 +#    Timeout -1
 +#    Version 3
 +#  </Instance>
 +#</Plugin>
 +
  #<Plugin openvpn>
  #     StatusFile "/etc/openvpn/openvpn-status.log"
  #     ImprovedNamingSchema false
  #  </Device>
  #</Plugin>
  
 +#<Plugin smart>
 +#  Disk "/^[hs]d[a-f][0-9]?$/"
 +#  IgnoreSelected false
 +#</Plugin>
 +
  #<Plugin snmp>
  #   <Data "powerplus_voltge_input">
  #       Type "voltage"
  #  TimerCount     false
  #</Plugin>
  
 -#<Plugin "swap">
 +#<Plugin swap>
  #     ReportByDevice false
  #     ReportBytes true
 +#     ValuesAbsolute true
 +#     ValuesPercentage false
  #</Plugin>
  
 -#<Plugin "table">
 +#<Plugin table>
  #     <Table "/proc/slabinfo">
  #             Instance "slabinfo"
  #             Separator " "
  #     </Table>
  #</Plugin>
  
 -#<Plugin "tail">
 +#<Plugin tail>
  #  <File "/var/log/exim4/mainlog">
  #    Instance "exim"
 +#    Interval 60
  #    <Match>
  #      Regex "S=([1-9][0-9]*)"
  #      DSType "CounterAdd"
  #  </File>
  #</Plugin>
  
 -#<Plugin "tail_csv">
 +#<Plugin tail_csv>
  #   <Metric "dropped">
  #       Type "percent"
  #       Instance "dropped"
  
  #<Plugin tcpconns>
  #     ListeningPorts false
 +#     AllPortsSummary false
  #     LocalPort "25"
  #     RemotePort "25"
  #</Plugin>
  #     Port "1978"
  #</Plugin>
  
 +#<Plugin turbostat>
 +##    None of the following option should be set manually
 +##    This plugin automatically detect most optimal options
 +##    Only set values here if:
 +##    - The module ask you to
 +##    - You want to disable the collection of some data
 +##    - Your (intel) CPU is not supported (yet) by the module
 +##    - The module generate a lot of errors 'MSR offset 0x... read failed'
 +##    In the last two cases, please open a bug request
 +#
 +#     TCCActivationTemp "100"
 +#     CoreCstates "392"
 +#     PackageCstates "396"
 +#     SystemManagementInterrupt true
 +#     DigitalTemperatureSensor true
 +#     PackageThermalManagement true
 +#     RunningAveragePowerLimit "7"    
 +#</Plugin>
 +
  #<Plugin unixsock>
  #     SocketFile "@prefix@/var/run/@PACKAGE_NAME@-unixsock"
  #     SocketGroup "collectd"
  #   If you prefer defining another instance you can do
  #   so by using <Instance "myinstance">
  #   <Instance>
 -#      CollectCache true
  #      CollectBackend true
 -#      CollectBan false           # Varnish 3 only
 +#      CollectBan false           # Varnish 3 and above
 +#      CollectCache true
  #      CollectConnections true
  #      CollectDirectorDNS false   # Varnish 3 only
 -#      CollectSHM true
  #      CollectESI false
  #      CollectFetch false
  #      CollectHCB false
  #      CollectObjects false
  #      CollectPurge false         # Varnish 2 only
  #      CollectSession false
 +#      CollectSHM true
  #      CollectSMA false           # Varnish 2 only
  #      CollectSMS false
  #      CollectSM false            # Varnish 2 only
  #      CollectStruct false
  #      CollectTotals false
 -#      CollectUptime false
 +#      CollectUptime false        # Varnish 3 and above
  #      CollectVCL false
 +#      CollectVSM false           # Varnish 4 only
  #      CollectWorkers false
  #   </Instance>
  #</Plugin>
  
 +#<Plugin virt>
 +#     Connection "xen:///"
 +#     RefreshInterval 60
 +#     Domain "name"
 +#     BlockDevice "name:device"
 +#     InterfaceDevice "name:device"
 +#     IgnoreSelected false
 +#     HostnameFormat name
 +#     InterfaceFormat name
 +#     PluginInstanceFormat name
 +#</Plugin>
 +
  #<Plugin vmem>
  #     Verbose false
  #</Plugin>
  #</Plugin>
  
  #<Plugin write_http>
 -#     <URL "http://example.com/collectd-post">
 +#     <Node "example">
 +#             URL "http://example.com/collectd-post"
  #             User "collectd"
  #             Password "weCh3ik0"
  #             VerifyPeer true
  #             VerifyHost true
  #             CACert "/etc/ssl/ca.crt"
 +#             CAPath "/etc/ssl/certs/"
 +#             ClientKey "/etc/ssl/client.pem"
 +#             ClientCert "/etc/ssl/client.crt"
 +#             ClientKeyPass "secret"
 +#             SSLVersion "TLSv1"
  #             Format "Command"
  #             StoreRates false
 -#     </URL>
 +#             BufferSize 4096
 +#             LowSpeedLimit 0
 +#             Timeout 0
 +#     </Node>
 +#</Plugin>
 +
 +#<Plugin write_kafka>
 +#  Property "metadata.broker.list" "localhost:9092"
 +#  <Topic "collectd">
 +#    Format JSON
 +#  </Topic>
  #</Plugin>
  
  #<Plugin write_mongodb>
  #     <Node "example">
  #             Host "localhost"
  #             Port 5555
 -#             Protocol UDP
 +#             Protocol TCP
 +#             Batch true
 +#             BatchMaxSize 8192
  #             StoreRates true
  #             AlwaysAppendDS false
  #             TTLFactor 2.0
 +#             Notifications true
 +#             CheckThresholds false
 +#             EventServicePrefix ""
 +#     </Node>
 +#     Tag "foobar"
 +#     Attribute "foo" "bar"
 +#</Plugin>
 +
 +#<Plugin write_sensu>
 +#     <Node "example">
 +#             Host "localhost"
 +#             Port 3030
 +#             StoreRates true
 +#             AlwaysAppendDS false
 +#             Notifications true
 +#             Metrics true
 +#             EventServicePrefix ""
 +#             MetricHandler "influx"
 +#             MetricHandler "default"
 +#             NotificationHandler "flapjack"
 +#             NotificationHandler "howling_monkey"
  #     </Node>
  #     Tag "foobar"
 +#     Attribute "foo" "bar"
 +#</Plugin>
 +
 +#<Plugin write_tsdb>
 +#     <Node>
 +#             Host "localhost"
 +#             Port "4242"
 +#             HostTags "status=production"
 +#             StoreRates false
 +#             AlwaysAppendDS false
 +#     </Node>
 +#</Plugin>
 +
 +#<Plugin zookeeper>
 +#    Host "localhost"
 +#    Port "2181"
  #</Plugin>
  
  ##############################################################################
  ##############################################################################
  
  #@BUILD_PLUGIN_THRESHOLD_TRUE@LoadPlugin "threshold"
 -#<Plugin "threshold">
 +#<Plugin threshold>
  #  <Type "foo">
  #    WarningMin    0.00
  #    WarningMax 1000.00
diff --combined src/modbus.c
@@@ -47,7 -47,6 +47,7 @@@
  /*
   * <Data "data_name">
   *   RegisterBase 1234
 + *   RegisterCmd ReadHolding
   *   RegisterType float
   *   Type gauge
   *   Instance "..."
   * <Host "name">
   *   Address "addr"
   *   Port "1234"
 + *   # Or:
 + *   # Device "/dev/ttyUSB0"
 + *   # Baudrate 38400
 + *   # (Assumes 8N1)
   *   Interval 60
   *
   *   <Slave 1>
@@@ -80,21 -75,7 +80,21 @@@ enum mb_register_type_e /* {{{ *
    REG_TYPE_UINT32,
    REG_TYPE_FLOAT
  }; /* }}} */
 +enum mb_mreg_type_e /* {{{ */ 
 +{
 +  MREG_HOLDING,
 +  MREG_INPUT
 +}; /* }}} */
  typedef enum mb_register_type_e mb_register_type_t;
 +typedef enum mb_mreg_type_e mb_mreg_type_t;
 +
 +/* TCP or RTU depending on what is specified in host config block */
 +enum mb_conntype_e /* {{{ */
 +{
 +  MBCONN_TCP,
 +  MBCONN_RTU
 +}; /* }}} */
 +typedef enum mb_conntype_e mb_conntype_t;
  
  struct mb_data_s;
  typedef struct mb_data_s mb_data_t;
@@@ -103,7 -84,6 +103,7 @@@ struct mb_data_s /* {{{ *
    char *name;
    int register_base;
    mb_register_type_t register_type;
 +  mb_mreg_type_t modbus_register_type;
    char type[DATA_MAX_NAME_LEN];
    char instance[DATA_MAX_NAME_LEN];
  
@@@ -121,11 -101,9 +121,11 @@@ typedef struct mb_slave_s mb_slave_t
  struct mb_host_s /* {{{ */
  {
    char host[DATA_MAX_NAME_LEN];
 -  char node[NI_MAXHOST];
 +  char node[NI_MAXHOST];      /* TCP hostname or RTU serial device */
    /* char service[NI_MAXSERV]; */
 -  int port;
 +  int port;                   /* for Modbus/TCP */
 +  int baudrate;                       /* for Modbus/RTU */
 +  mb_conntype_t conntype;
    cdtime_t interval;
  
    mb_slave_t *slaves;
@@@ -310,38 -288,28 +310,40 @@@ static int mb_init_connection (mb_host_
    if (host == NULL)
      return (EINVAL);
  
+ #if COLLECT_DEBUG
    modbus_set_debug (&host->connection, 1);
+ #endif
  
    /* We'll do the error handling ourselves. */
    modbus_set_error_handling (&host->connection, NOP_ON_ERROR);
  
 -  if ((host->port < 1) || (host->port > 65535))
 -    host->port = MODBUS_TCP_DEFAULT_PORT;
 +  if (host->conntype == MBCONN_TCP)
 +  {
 +    if ((host->port < 1) || (host->port > 65535))
 +      host->port = MODBUS_TCP_DEFAULT_PORT;
 +
 +    DEBUG ("Modbus plugin: Trying to connect to \"%s\", port %i.",
 +        host->node, host->port);
  
 -  DEBUG ("Modbus plugin: Trying to connect to \"%s\", port %i.",
 -      host->node, host->port);
 +    modbus_init_tcp (&host->connection,
 +        /* host = */ host->node,
 +        /* port = */ host->port);
 +  }
 +  else        /* MBCONN_RTU */
 +  {
 +    DEBUG ("Modbus plugin: Trying to connect to \"%s\".", host->node);
  
 -  modbus_init_tcp (&host->connection,
 -      /* host = */ host->node,
 -      /* port = */ host->port);
 +    modbus_init_rtu (&host->connection,
 +       /* device = */ host->node,
 +     /* baudrate = */ host->baudrate,
 +                      'N', 8, 1, 0);
 +  }
  
    status = modbus_connect (&host->connection);
    if (status != 0)
    {
      ERROR ("Modbus plugin: modbus_connect (%s, %i) failed with status %i.",
 -        host->node, host->port, status);
 +        host->node, host->port ? host->port : host->baudrate, status);
      return (status);
    }
  
@@@ -362,35 -330,22 +364,37 @@@ static int mb_init_connection (mb_host_
    if (host->connection != NULL)
      return (0);
  
 -  if ((host->port < 1) || (host->port > 65535))
 -    host->port = MODBUS_TCP_DEFAULT_PORT;
 +  if (host->conntype == MBCONN_TCP)
 +  {
 +    if ((host->port < 1) || (host->port > 65535))
 +      host->port = MODBUS_TCP_DEFAULT_PORT;
  
 -  DEBUG ("Modbus plugin: Trying to connect to \"%s\", port %i.",
 -      host->node, host->port);
 +    DEBUG ("Modbus plugin: Trying to connect to \"%s\", port %i.",
 +        host->node, host->port);
  
 -  host->connection = modbus_new_tcp (host->node, host->port);
 -  if (host->connection == NULL)
 +    host->connection = modbus_new_tcp (host->node, host->port);
 +    if (host->connection == NULL)
 +    {
 +      ERROR ("Modbus plugin: Creating new Modbus/TCP object failed.");
 +      return (-1);
 +    }
 +  }
 +  else
    {
 -    ERROR ("Modbus plugin: Creating new Modbus/TCP object failed.");
 -    return (-1);
 +    DEBUG ("Modbus plugin: Trying to connect to \"%s\", baudrate %i.",
 +        host->node, host->baudrate);
 +
 +    host->connection = modbus_new_rtu (host->node, host->baudrate, 'N', 8, 1);
 +    if (host->connection == NULL)
 +    {
 +      ERROR ("Modbus plugin: Creating new Modbus/RTU object failed.");
 +      return (-1);
 +    }
    }
  
+ #if COLLECT_DEBUG
    modbus_set_debug (host->connection, 1);
+ #endif
  
    /* We'll do the error handling ourselves. */
    modbus_set_error_recovery (host->connection, 0);
    if (status != 0)
    {
      ERROR ("Modbus plugin: modbus_connect (%s, %i) failed with status %i.",
 -        host->node, host->port, status);
 +        host->node, host->port ? host->port : host->baudrate, status);
      modbus_free (host->connection);
      host->connection = NULL;
      return (status);
@@@ -467,7 -422,7 +471,7 @@@ static int mb_read_data (mb_host_t *hos
    {
      status = EBADF;
    }
 -  else
 +  else if (host->conntype == MBCONN_TCP)
    {
      struct sockaddr sockaddr;
      socklen_t saddrlen = sizeof (sockaddr);
      return (-1);
    }
  #endif
 -
 -  status = modbus_read_registers (host->connection,
 +  if (data->modbus_register_type == MREG_INPUT){
 +    status = modbus_read_input_registers (host->connection,
          /* start_addr = */ data->register_base,
          /* num_registers = */ values_num, /* buffer = */ values);
 +  }
 +  else{
 +    status = modbus_read_registers (host->connection,
 +        /* start_addr = */ data->register_base,
 +        /* num_registers = */ values_num, /* buffer = */ values);
 +  }
    if (status != values_num)
    {
 -    ERROR ("Modbus plugin: modbus_read_registers (%s/%s) failed. status = %i, values_num = %i "
 -        "Giving up.", host->host, host->node, status, values_num);
 +    ERROR ("Modbus plugin: modbus read function (%s/%s) failed. "
 +           " status = %i, values_num = %i. Giving up.",
 +           host->host, host->node, status, values_num);
  #if LEGACY_LIBMODBUS
      modbus_close (&host->connection);
  #else
@@@ -763,28 -711,6 +767,28 @@@ static int mb_config_add_data (oconfig_
          status = -1;
        }
      }
 +    else if (strcasecmp ("RegisterCmd", child->key) == 0)
 +    {
 +#if LEGACY_LIBMODBUS
 +      ERROR("Modbus plugin: RegisterCmd parameter can not be used "
 +            "with your libmodbus version");
 +#else
 +      char tmp[16];
 +      status = cf_util_get_string_buffer (child, tmp, sizeof (tmp));
 +      if (status != 0)
 +        /* do nothing */;
 +      else if (strcasecmp ("ReadHolding", tmp) == 0)
 +        data.modbus_register_type = MREG_HOLDING;
 +      else if (strcasecmp ("ReadInput", tmp) == 0)
 +        data.modbus_register_type = MREG_INPUT;
 +      else
 +      {
 +        ERROR ("Modbus plugin: The modbus_register_type \"%s\" is unknown.",
 +               tmp);
 +        status = -1;
 +      }
 +#endif
 +    }
      else
      {
        ERROR ("Modbus plugin: Unknown configuration option: %s", child->key);
@@@ -963,8 -889,6 +967,8 @@@ static int mb_config_add_host (oconfig_
        status = cf_util_get_string_buffer (child, buffer, sizeof (buffer));
        if (status == 0)
          status = mb_config_set_host_address (host, buffer);
 +      if (status == 0)
 +        host->conntype = MBCONN_TCP;
      }
      else if (strcasecmp ("Port", child->key) == 0)
      {
        if (host->port <= 0)
          status = -1;
      }
 +    else if (strcasecmp ("Device", child->key) == 0)
 +    {
 +      status = cf_util_get_string_buffer (child, host->node, sizeof (host->node));
 +      if (status == 0)
 +        host->conntype = MBCONN_RTU;
 +    }
 +    else if (strcasecmp ("Baudrate", child->key) == 0)
 +      status = cf_util_get_int(child, &host->baudrate);
      else if (strcasecmp ("Interval", child->key) == 0)
        status = cf_util_get_cdtime (child, &host->interval);
      else if (strcasecmp ("Slave", child->key) == 0)
    } /* for (i = 0; i < ci->children_num; i++) */
  
    assert (host->host[0] != 0);
 -  if (host->host[0] == 0)
 +  if (host->node[0] == 0)
    {
 -    ERROR ("Modbus plugin: Data block \"%s\": No type has been specified.",
 +    ERROR ("Modbus plugin: Data block \"%s\": No address or device has been specified.",
 +        host->host);
 +    status = -1;
 +  }
 +  if (host->conntype == MBCONN_RTU && !host->baudrate)
 +  {
 +    ERROR ("Modbus plugin: Data block \"%s\": No serial baudrate has been specified.",
 +        host->host);
 +    status = -1;
 +  }
 +  if ((host->conntype == MBCONN_TCP && host->baudrate) ||
 +      (host->conntype == MBCONN_RTU && host->port))
 +  {
 +    ERROR ("Modbus plugin: Data block \"%s\": You've mixed up RTU and TCP options.",
          host->host);
      status = -1;
    }