Merge branch 'collectd-5.4'
authorMarc Fournier <marc.fournier@camptocamp.com>
Sat, 9 May 2015 22:14:18 +0000 (00:14 +0200)
committerMarc Fournier <marc.fournier@camptocamp.com>
Sat, 9 May 2015 22:14:18 +0000 (00:14 +0200)
1  2 
configure.ac
contrib/redhat/collectd.spec
src/daemon/meta_data.c
src/processes.c
src/swap.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])
  
@@@ -70,11 -70,9 +70,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$x$ac_system" = "xLinux"])
 +AM_CONDITIONAL([BUILD_SOLARIS],[test "x$x$ac_system" = "xSolaris"])
 +AM_CONDITIONAL([BUILD_DARWIN],[test "x$x$ac_system" = "xDarwin"])
 +AM_CONDITIONAL([BUILD_OPENBSD],[test "x$x$ac_system" = "xOpenBSD"])
 +AM_CONDITIONAL([BUILD_AIX],[test "x$x$ac_system" = "xAIX"])
 +AM_CONDITIONAL([BUILD_FREEBSD],[test "x$x$ac_system" = "xFreeBSD"])
 +
  if test "x$ac_system" = "xLinux"
  then
        AC_ARG_VAR([KERNEL_DIR], [path to Linux kernel sources])
@@@ -527,7 -518,7 +527,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)
@@@ -602,7 -593,7 +602,7 @@@ AC_HEADER_TIM
  # 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
  
@@@ -809,9 -800,7 +809,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);
@@@ -1006,7 -993,7 +1006,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;
@@@ -1061,7 -1048,7 +1061,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);
@@@ -1110,7 -1097,7 +1110,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"
@@@ -1190,6 -1166,7 +1190,7 @@@ FILE *fh
  struct mntent *me;
  fh = setmntent ("/etc/mtab", "r");
  me = getmntent (fh);
+ return(me->mnt_passno);
  ]]]
                        )],
                        [c_cv_have_one_getmntent="yes"],
                                 int status;
                                 fh = fopen ("/etc/mnttab", "r");
                                 status = getmntent (fh, &mt);
+                                return(status);
  ]]]
                        )],
                        [c_cv_have_two_getmntent="yes"],
@@@ -1259,7 -1237,7 +1261,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
@@@ -1315,7 -1293,7 +1317,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")
  # }}}
@@@ -1990,7 -1951,10 +1992,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
  
  # --with-java {{{
  with_java_home="$JAVA_HOME"
+ if test "x$with_java_home" = "x"
+ then
+       with_java_home="/usr/lib/jvm"
+ fi
  with_java_vmtype="client"
  with_java_cflags=""
  with_java_libs=""
@@@ -2108,7 -2098,7 +2114,7 @@@ the
        if test -d "$with_java_home"
        then
                AC_MSG_CHECKING([for jni.h])
-               TMPVAR=`find "$with_java_home" -name jni.h -type f -exec 'dirname' '{}' ';' 2>/dev/null | head -n 1`
+               TMPVAR=`find -L "$with_java_home" -name jni.h -type f -exec 'dirname' '{}' ';' 2>/dev/null | head -n 1`
                if test "x$TMPVAR" != "x"
                then
                        AC_MSG_RESULT([found in $TMPVAR])
                fi
  
                AC_MSG_CHECKING([for jni_md.h])
-               TMPVAR=`find "$with_java_home" -name jni_md.h -type f -exec 'dirname' '{}' ';' 2>/dev/null | head -n 1`
+               TMPVAR=`find -L "$with_java_home" -name jni_md.h -type f -exec 'dirname' '{}' ';' 2>/dev/null | head -n 1`
                if test "x$TMPVAR" != "x"
                then
                        AC_MSG_RESULT([found in $TMPVAR])
                fi
  
                AC_MSG_CHECKING([for libjvm.so])
-               TMPVAR=`find "$with_java_home" -name libjvm.so -type f -exec 'dirname' '{}' ';' 2>/dev/null | head -n 1`
+               TMPVAR=`find -L "$with_java_home" -name libjvm.so -type f -exec 'dirname' '{}' ';' 2>/dev/null | head -n 1`
                if test "x$TMPVAR" != "x"
                then
                        AC_MSG_RESULT([found in $TMPVAR])
                if test "x$JAVAC" = "x"
                then
                        AC_MSG_CHECKING([for javac])
-                       TMPVAR=`find "$with_java_home" -name javac -type f 2>/dev/null | head -n 1`
+                       TMPVAR=`find -L "$with_java_home" -name javac -type f 2>/dev/null | head -n 1`
                        if test "x$TMPVAR" != "x"
                        then
                                JAVAC="$TMPVAR"
                if test "x$JAR" = "x"
                then
                        AC_MSG_CHECKING([for jar])
-                       TMPVAR=`find "$with_java_home" -name jar -type f 2>/dev/null | head -n 1`
+                       TMPVAR=`find -L "$with_java_home" -name jar -type f 2>/dev/null | head -n 1`
                        if test "x$TMPVAR" != "x"
                        then
                                JAR="$TMPVAR"
@@@ -2251,64 -2241,6 +2257,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=""
@@@ -2343,7 -2275,7 +2349,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"
@@@ -2745,15 -2677,6 +2751,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)"],
@@@ -2877,7 -2800,7 +2883,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"
@@@ -3104,7 -3027,7 +3110,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"
@@@ -3115,7 -3038,7 +3121,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"
@@@ -3172,6 -3095,7 +3178,7 @@@ the
  ]]],
  [[[
    int val = PCAP_ERROR_IFACE_NOT_UP;
+   return(val);
  ]]]
                       )],
                       [c_cv_libpcap_have_pcap_error_iface_not_up="yes"],
  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="yes"
 +  else
 +    with_librdkafka="$withval"
 +  fi
 +],
 +[
 +  with_librdkafka="yes"
 +])
 +SAVE_CPPFLAGS="$CPPFLAGS"
 +SAVE_LDFLAGS="$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"
 +      BUILD_WITH_LIBRDKAFKA_LIBS="-lrdkafka"
 +      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
  # }}}
  
@@@ -4246,7 -4083,7 +4253,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(varnish/vapi/vsc.h,
 +              [AC_DEFINE([HAVE_VARNISH_V4], [1], [Varnish 4 API support])],
 +              [AC_CHECK_HEADERS(varnish/vsc.h,
 +                      [AC_DEFINE([HAVE_VARNISH_V3], [1], [Varnish 3 API support])],
 +                      [AC_CHECK_HEADERS(varnish/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
@@@ -5103,10 -4830,8 +5110,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"
@@@ -5116,7 -4841,6 +5123,7 @@@ plugin_curl_json="no
  plugin_curl_xml="no"
  plugin_df="no"
  plugin_disk="no"
 +plugin_drbd="no"
  plugin_entropy="no"
  plugin_ethstat="no"
  plugin_fscache="no"
@@@ -5124,8 -4848,8 +5131,8 @@@ 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"
@@@ -5139,14 -4863,12 +5146,14 @@@ plugin_tape="no
  plugin_tcpconns="no"
  plugin_ted="no"
  plugin_thermal="no"
 -plugin_users="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_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
  if test "x$ac_system" = "xAIX"
  then
          plugin_tcpconns="yes"
 +        plugin_ipc="yes"
  fi
  
  # FreeBSD
        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:])
  
@@@ -5476,10 -5158,8 +5483,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])
@@@ -5492,7 -5172,6 +5499,7 @@@ 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])
@@@ -5503,15 -5182,14 +5510,15 @@@ AC_PLUGIN([fscache],     [$plugin_fscac
  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])
@@@ -5541,7 -5219,6 +5548,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])
@@@ -5554,14 -5231,13 +5561,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])
@@@ -5586,28 -5262,21 +5593,28 @@@ AC_PLUGIN([uptime],      [$plugin_uptim
  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"
@@@ -5752,7 -5411,7 +5759,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" \
@@@ -5785,21 -5444,18 +5792,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
      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
      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
  
  %{?el6:%global _has_ip_vs_h 1}
  %{?el6:%global _has_lvm2app_h 1}
  %{?el6:%global _has_libmodbus 1}
 +%{?el6:%global _has_libudev 1}
  %{?el6:%global _has_iproute 1}
 +%{?el6:%global _has_atasmart 1}
 +%{?el6:%global _has_hiredis 1}
  
  %{?el7:%global _has_libyajl 1}
  %{?el7:%global _has_recent_libpcap 1}
  %{?el7:%global _has_working_libiptc 1}
  %{?el7:%global _has_ip_vs_h 1}
  %{?el7:%global _has_lvm2app_h 1}
 +%{?el7:%global _has_libudev 1}
  %{?el7:%global _has_recent_librrd 1}
  %{?el7:%global _has_varnish4 1}
  %{?el7:%global _has_broken_libmemcached 1}
  %{?el7:%global _has_iproute 1}
 +%{?el7:%global _has_atasmart 1}
 +%{?el7:%global _has_hiredis 1}
  
  # plugins enabled by default
  %define with_aggregation 0%{!?_without_aggregation:1}
@@@ -75,7 -69,6 +75,7 @@@
  %define with_ascent 0%{!?_without_ascent:1}
  %define with_battery 0%{!?_without_battery:1}
  %define with_bind 0%{!?_without_bind:1}
 +%define with_ceph 0%{!?_without_ceph:0%{?_has_libyajl}}
  %define with_cgroups 0%{!?_without_cgroups:1}
  %define with_conntrack 0%{!?_without_conntrack:1}
  %define with_contextswitch 0%{!?_without_contextswitch:1}
@@@ -89,7 -82,6 +89,7 @@@
  %define with_df 0%{!?_without_df:1}
  %define with_disk 0%{!?_without_disk:1}
  %define with_dns 0%{!?_without_dns:0%{?_has_recent_libpcap}}
 +%define with_drbd 0%{!?_without_drbd:1}
  %define with_email 0%{!?_without_email:1}
  %define with_entropy 0%{!?_without_entropy:1}
  %define with_ethstat 0%{!?_without_ethstat:0%{?_has_recent_sockios_h}}
  %define with_gmond 0%{!?_without_gmond:0%{?_has_recent_libganglia}}
  %define with_hddtemp 0%{!?_without_hddtemp:1}
  %define with_interface 0%{!?_without_interface:1}
 +%define with_ipc 0%{!?_without_ipc:1}
  %define with_ipmi 0%{!?_without_ipmi:1}
  %define with_iptables 0%{!?_without_iptables:0%{?_has_working_libiptc}}
  %define with_ipvs 0%{!?_without_ipvs:0%{?_has_ip_vs_h}}
  %define with_irq 0%{!?_without_irq:1}
  %define with_java 0%{!?_without_java:1}
 -%define with_libvirt 0%{!?_without_libvirt:1}
 +%define with_virt 0%{!?_without_virt:1}
  %define with_load 0%{!?_without_load:1}
  %define with_logfile 0%{!?_without_logfile:1}
 +%define with_log_logstash 0%{!?_without_log_logstash:0%{?_has_libyajl}}
  %define with_lvm 0%{!?_without_lvm:0%{?_has_lvm2app_h}}
  %define with_madwifi 0%{!?_without_madwifi:1}
  %define with_mbmon 0%{!?_without_mbmon:1}
  %define with_numa 0%{!?_without_numa:1}
  %define with_nut 0%{!?_without_nut:1}
  %define with_olsrd 0%{!?_without_olsrd:1}
 +%define with_openldap 0%{!?_without_openldap:1}
  %define with_openvpn 0%{!?_without_openvpn:1}
  %define with_perl 0%{!?_without_perl:1}
  %define with_pinba 0%{!?_without_pinba:1}
  %define with_processes 0%{!?_without_processes:1}
  %define with_protocols 0%{!?_without_protocols:1}
  %define with_python 0%{!?_without_python:1}
 +%define with_redis 0%{!?_without_redis:0%{?_has_hiredis}}
  %define with_rrdcached 0%{!?_without_rrdcached:0%{?_has_recent_librrd}}
  %define with_rrdtool 0%{!?_without_rrdtool:1}
  %define with_sensors 0%{!?_without_sensors:1}
  %define with_serial 0%{!?_without_serial:1}
 +%define with_smart 0%{!?_without_smart:0%{?_has_atasmart}}
  %define with_snmp 0%{!?_without_snmp:1}
  %define with_statsd 0%{!?_without_statsd:1}
  %define with_swap 0%{!?_without_swap:1}
  %define with_wireless 0%{!?_without_wireless:1}
  %define with_write_graphite 0%{!?_without_write_graphite:1}
  %define with_write_http 0%{!?_without_write_http:1}
 +%define with_write_log 0%{!?_without_write_log:1}
 +%define with_write_redis 0%{!?_without_write_redis:0%{?_has_hiredis}}
  %define with_write_riemann 0%{!?_without_write_riemann:1}
 +%define with_write_sensu 0%{!?_without_write_sensu:1}
 +%define with_write_tsdb 0%{!?_without_write_tsdb:1}
 +%define with_zfs_arc 0%{!?_without_zfs_arc:1}
 +%define with_zookeeper 0%{!?_without_zookeeper:1}
  
  # Plugins not built by default because of dependencies on libraries not
  # available in RHEL or EPEL:
  %define with_apple_sensors 0%{!?_without_apple_sensors:0}
  # plugin aquaero disabled, requires a libaquaero5
  %define with_aquaero 0%{!?_without_aquaero:0}
 +# plugin barometer disabled, requires a libi2c
 +%define with_barometer 0%{!?_without_barometer:0}
  # plugin lpar disabled, requires AIX
  %define with_lpar 0%{!?_without_lpar:0}
  # plugin mic disabled, requires Mic
  %define with_oracle 0%{!?_without_oracle:0}
  # plugin oracle disabled, requires BSD
  %define with_pf 0%{!?_without_pf:0}
 -# plugin redis disabled, requires credis
 -%define with_redis 0%{!?_without_redis:0}
  # plugin routeros disabled, requires librouteros
  %define with_routeros 0%{!?_without_routeros:0}
  # plugin sigrok disabled, requires libsigrok
  %define with_tape 0%{!?_without_tape:0}
  # plugin tokyotyrant disabled, requires tcrdb.h
  %define with_tokyotyrant 0%{!?_without_tokyotyrant:0}
 +# plugin write_kafka disabled, requires librdkafka
 +%define with_write_kafka 0%{!?_without_write_kafka:0}
  # plugin write_mongodb disabled, requires libmongoc
  %define with_write_mongodb 0%{!?_without_write_mongodb:0}
 -# plugin write_redis disabled, requires credis
 -%define with_write_redis 0%{!?_without_write_redis:0}
  # plugin xmms disabled, requires xmms
  %define with_xmms 0%{!?_without_xmms:0}
 -# plugin zfs_arc disabled, requires FreeBSD/Solaris
 -%define with_zfs_arc 0%{!?_without_zfs_arc:0}
  
- Summary:      Statistics collection daemon for filling RRD files
+ Summary:      statistics collection and monitoring daemon
  Name:         collectd
  Version:      5.4.2
  Release:      1%{?dist}
@@@ -223,16 -206,9 +223,16 @@@ BuildRoot:       %{_tmppath}/%{name}-%{versio
  BuildRequires:        libgcrypt-devel, kernel-headers, libtool-ltdl-devel
  Vendor:               collectd development team <collectd@verplant.org>
  
 +%if 0%{?el7:1}
 +Requires(pre):                initscripts
 +Requires(post):               systemd
 +Requires(preun):      systemd
 +Requires(postun):     systemd
 +%else
  Requires(post):               chkconfig
  Requires(preun):      chkconfig, initscripts
  Requires(postun):     initscripts
 +%endif
  
  %description
  collectd is a small daemon which collects system information periodically and
@@@ -284,15 -260,6 +284,15 @@@ open-source server software for the gam
  Entertainment.
  %endif
  
 +%if %{with_barometer}
 +%package barometer
 +Summary:       barometer plugin for collectd
 +Group:         System Environment/Daemons
 +Requires:      %{name}%{?_isa} = %{version}-%{release}
 +%description barometer
 +Collects pressure and temperature from digital barometers.
 +%endif
 +
  %if %{with_bind}
  %package bind
  Summary:      Bind plugin for collectd
@@@ -304,16 -271,6 +304,16 @@@ The BIND plugin retrieves this informat
  via HTTP and submits the values to collectd.
  %endif
  
 +%if %{with_ceph}
 +%package ceph
 +Summary:       Ceph plugin for collectd
 +Group:         System Environment/Daemons
 +Requires:      %{name}%{?_isa} = %{version}-%{release}
 +BuildRequires: yajl-devel
 +%description ceph
 +Ceph plugin for collectd
 +%endif
 +
  %if %{with_curl}
  %package curl
  Summary:      Curl plugin for collectd
@@@ -358,17 -315,6 +358,17 @@@ The DBI plugin uses libdbi, a database 
  statements on a database and read back the result.
  %endif
  
 +%if %{with_disk}
 +%package disk
 +Summary:      disk plugin for collectd
 +Group:                System Environment/Daemons
 +Requires:     %{name}%{?_isa} = %{version}-%{release}
 +%{?_has_libudev:BuildRequires:  libudev-devel}
 +%description disk
 +The "disk" plugin collects information about the usage of physical disks and
 +logical disks (partitions).
 +%endif
 +
  %if %{with_dns}
  %package dns
  Summary:      DNS plugin for collectd
@@@ -446,14 -392,14 +446,14 @@@ This plugin for collectd allows plugin
  in an embedded JVM.
  %endif
  
 -%if %{with_libvirt}
 -%package libvirt
 -Summary:      Libvirt plugin for collectd
 -Group:                System Environment/Daemons
 -Requires:     %{name}%{?_isa} = %{version}-%{release}
 -BuildRequires:        libvirt-devel
 -%description libvirt
 -This plugin collects information from virtualized guests.
 +%if %{with_log_logstash}
 +%package log_logstash
 +Summary:       log_logstash plugin for collectd
 +Group:         System Environment/Daemons
 +Requires:      %{name}%{?_isa} = %{version}-%{release}
 +BuildRequires: yajl-devel
 +%description log_logstash
 +This plugin logs in logstash JSON format
  %endif
  
  %if %{with_lvm}
@@@ -562,27 -508,17 +562,27 @@@ BuildRequires:  nut-deve
  This plugin for collectd provides Network UPS Tools support.
  %endif
  
 +%if %{with_openldap}
 +%package openldap
 +Summary:       Openldap plugin for collectd
 +Group:         System Environment/Daemons
 +Requires:      %{name}%{?_isa} = %{version}-%{release}
 +BuildRequires: openldap-devel
 +%description openldap
 +This plugin reads monitoring information from OpenLDAP's cn=Monitor subtree.
 +%endif
 +
  %if %{with_perl}
  %package perl
  Summary:      Perl plugin for collectd
  Group:                System Environment/Daemons
  Requires:     %{name}%{?_isa} = %{version}-%{release}
  Requires:     perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))
 -%if 0%{?rhel} >= 6
 +      %if 0%{?rhel} >= 6
  BuildRequires:        perl-ExtUtils-Embed
 -%else
 +      %else
  BuildRequires:        perl
 -%endif
 +      %endif
  %description perl
  The Perl plugin embeds a Perl interpreter into collectd and exposes the
  application programming interface (API) to Perl-scripts.
@@@ -626,11 -562,11 +626,11 @@@ database
  Summary:      Python plugin for collectd
  Group:                System Environment/Daemons
  Requires:     %{name}%{?_isa} = %{version}-%{release}
 -%if 0%{?rhel} >= 6
 +      %if 0%{?rhel} >= 6
  BuildRequires: python-devel
 -%else
 +      %else
  BuildRequires: python26-devel
 -%endif
 +      %endif
  %description python
  The Python plugin embeds a Python interpreter into collectd and exposes the
  application programming interface (API) to Python-scripts.
  Summary:      Redis plugin for collectd
  Group:                System Environment/Daemons
  Requires:     %{name}%{?_isa} = %{version}-%{release}
 -BuildRequires:        credis-devel
 +BuildRequires:        hiredis-devel
  %description redis
  The Redis plugin connects to one or more instances of Redis, a key-value store,
 -and collects usage information using the credis library.
 +and collects usage information using the hiredis library.
  %endif
  
  %if %{with_rrdcached}
@@@ -689,17 -625,6 +689,17 @@@ measurements fed to collectd. This incl
  thermometers, and much more.
  %endif
  
 +%if %{with_smart}
 +%package smart
 +Summary:       SMART plugin for collectd
 +Group:         System Environment/Daemons
 +Requires:      %{name}%{?_isa} = %{version}-%{release}
 +BuildRequires: libatasmart-devel
 +%description smart
 +Collect SMART statistics, notably load cycle count, temperature and bad
 +sectors.
 +%endif
 +
  %if %{with_snmp}
  %package snmp
  Summary:      SNMP plugin for collectd
@@@ -720,16 -645,6 +720,16 @@@ BuildRequires:   varnish-libs-deve
  The Varnish plugin collects information about Varnish, an HTTP accelerator.
  %endif
  
 +%if %{with_virt}
 +%package virt
 +Summary:      Virt plugin for collectd
 +Group:                System Environment/Daemons
 +Requires:     %{name}%{?_isa} = %{version}-%{release}
 +BuildRequires:        libvirt-devel
 +%description virt
 +This plugin collects information from virtualized guests.
 +%endif
 +
  %if %{with_write_http}
  %package write_http
  Summary:      Write-HTTP plugin for collectd
@@@ -741,22 -656,12 +741,22 @@@ The Write-HTTP plugin sends the values 
  using HTTP POST requests.
  %endif
  
 +%if %{with_write_kafka}
 +%package write_kafka
 +Summary:       Write-kafka plugin for collectd
 +Group:         System Environment/Daemons
 +Requires:      %{name}%{?_isa} = %{version}-%{release}
 +BuildRequires: rdkafka-devel
 +%description write_kafka
 +The write_kafka plugin sends values to kafka, a distributed messaging system.
 +%endif
 +
  %if %{with_write_redis}
  %package write_redis
  Summary:      Write-Redis plugin for collectd
  Group:                System Environment/Daemons
  Requires:     %{name}%{?_isa} = %{version}-%{release}
 -BuildRequires:        credis-devel
 +BuildRequires:        hiredis-devel
  %description write_redis
  The Write Redis plugin stores values in Redis, a “data structures server”.
  %endif
@@@ -813,13 -718,6 +813,13 @@@ Requires:        libcollectdclient%{?_isa} = %
  %description -n libcollectdclient-devel
  Development files for libcollectdclient
  
 +%package -n collectd-utils
 +Summary:      Collectd utilities
 +Group:                System Environment/Daemons
 +Requires:     libcollectdclient%{?_isa} = %{version}-%{release}
 +Requires:     collectd%{?_isa} = %{version}-%{release}
 +%description -n collectd-utils
 +Collectd utilities
  
  %prep
  %setup -q
  %define _with_ascent --disable-ascent
  %endif
  
 +%if %{with_barometer}
 +%define _with_barometer --enable-barometer
 +%else
 +%define _with_barometer --disable-barometer
 +%endif
 +
  %if %{with_battery}
  %define _with_battery --enable-battery
  %else
  %define _with_csv --disable-csv
  %endif
  
 +%if %{with_ceph}
 +%define _with_ceph --enable-ceph
 +%else
 +%define _with_ceph --disable-ceph
 +%endif
 +
  %if %{with_curl}
  %define _with_curl --enable-curl
  %else
  %if %{with_dbi}
  %define _with_dbi --enable-dbi
  %else
- %define _with_dbi --disable-dbi --without-libdbi
+ %define _with_dbi --disable-dbi
  %endif
  
  %if %{with_df}
  %define _with_dns --disable-dns
  %endif
  
 +%if %{with_drbd}
 +%define _with_drbd --enable-drbd
 +%else
 +%define _with_drbd --disable-drbd
 +%endif
 +
  %if %{with_email}
  %define _with_email --enable-email
  %else
  %define _with_interface --disable-interface
  %endif
  
 +%if %{with_ipc}
 +%define _with_ipc --enable-ipc
 +%else
 +%define _with_ipc --disable-ipc
 +%endif
 +
  %if %{with_ipmi}
  %define _with_ipmi --enable-ipmi
  %else
  %define _with_java --disable-java
  %endif
  
 -%if %{with_libvirt}
 -%define _with_libvirt --enable-libvirt
 +%if %{with_virt}
 +%define _with_virt --enable-virt
  %else
 -%define _with_libvirt --disable-libvirt
 +%define _with_virt --disable-virt
  %endif
  
  %if %{with_load}
  %define _with_logfile --disable-logfile
  %endif
  
 +%if %{with_log_logstash}
 +%define _with_log_logstash --enable-log_logstash
 +%else
 +%define _with_log_logstash --disable-log_logstash
 +%endif
 +
  %if %{with_lpar}
  %define _with_lpar --enable-lpar
  %else
  %if %{with_notify_email}
  %define _with_notify_email --enable-notify_email
  %else
- %define _with_notify_email --disable-notify_email --without-libesmpt
+ %define _with_notify_email --disable-notify_email
  %endif
  
  %if %{with_ntpd}
  %define _with_onewire --disable-onewire
  %endif
  
 +%if %{with_openldap}
 +%define _with_openldap --enable-openldap
 +%else
 +%define _with_openldap --disable-openldap
 +%endif
 +
  %if %{with_openvpn}
  %define _with_openvpn --enable-openvpn
  %else
  %if %{with_perl}
  %define _with_perl --enable-perl --with-perl-bindings="INSTALLDIRS=vendor"
  %else
- %define _with_perl --disable-perl --without-libperl
+ %define _with_perl --disable-perl
  %endif
  
  %if %{with_pf}
  %endif
  
  %if %{with_python}
 -%if 0%{?rhel} >= 6
 +      %if 0%{?rhel} >= 6
  %define _with_python --enable-python
 -%else
 +      %else
  %define _with_python --enable-python --with-python=%{_bindir}/python2.6
 -%endif
 +      %endif
  %else
  %define _with_python --disable-python
  %endif
  %define _with_sigrok --disable-sigrok
  %endif
  
 +%if %{with_smart}
 +%define _with_smart --enable-smart
 +%else
 +%define _with_smart --disable-smart
 +%endif
 +
  %if %{with_snmp}
  %define _with_snmp --enable-snmp
  %else
  %define _with_write_http --disable-write_http
  %endif
  
 +%if %{with_write_kafka}
 +%define _with_write_kafka --enable-write_kafka
 +%else
 +%define _with_write_kafka --disable-write_kafka
 +%endif
 +
 +%if %{with_write_log}
 +%define _with_write_log --enable-write_log
 +%else
 +%define _with_write_log --disable-write_log
 +%endif
 +
  %if %{with_write_mongodb}
  %define _with_write_mongodb --enable-write_mongodb
  %else
- %define _with_write_mongodb --disable-write_mongodb --without-libmongoc
+ %define _with_write_mongodb --disable-write_mongodb
  %endif
  
  %if %{with_write_redis}
  %define _with_write_riemann --disable-write_riemann
  %endif
  
 +%if %{with_write_sensu}
 +%define _with_write_sensu --enable-write_sensu
 +%else
 +%define _with_write_sensu --disable-write_sensu
 +%endif
 +
 +%if %{with_write_tsdb}
 +%define _with_write_tsdb --enable-write_tsdb
 +%else
 +%define _with_write_tsdb --disable-write_tsdb
 +%endif
 +
  %if %{with_xmms}
  %define _with_xmms --enable-xmms
  %else
  %define _with_zfs_arc --disable-zfs_arc
  %endif
  
 +%if %{with_zookeeper}
 +%define _with_zookeeper --enable-zookeeper
 +%else
 +%define _with_zookeeper --disable-zookeeper
 +%endif
 +
  %configure CFLAGS="%{optflags} -DLT_LAZY_OR_NOW=\"RTLD_LAZY|RTLD_GLOBAL\"" \
        --disable-static \
        --without-included-ltdl \
        %{?_with_apple_sensors} \
        %{?_with_aquaero} \
        %{?_with_ascent} \
 +      %{?_with_barometer} \
        %{?_with_battery} \
        %{?_with_bind} \
 +      %{?_with_ceph} \
        %{?_with_cgroups} \
        %{?_with_conntrack} \
        %{?_with_contextswitch} \
        %{?_with_df} \
        %{?_with_disk} \
        %{?_with_dns} \
 +      %{?_with_drbd} \
        %{?_with_email} \
        %{?_with_entropy} \
        %{?_with_ethstat} \
        %{?_with_gmond} \
        %{?_with_hddtemp} \
        %{?_with_interface} \
 +      %{?_with_ipc} \
        %{?_with_ipmi} \
        %{?_with_iptables} \
        %{?_with_ipvs} \
        %{?_with_java} \
 -      %{?_with_libvirt} \
 +      %{?_with_virt} \
 +      %{?_with_log_logstash} \
        %{?_with_lpar} \
        %{?_with_lvm} \
        %{?_with_memcachec} \
        %{?_with_notify_email} \
        %{?_with_nut} \
        %{?_with_onewire} \
 +      %{?_with_openldap} \
        %{?_with_oracle} \
        %{?_with_perl} \
        %{?_with_pf} \
        %{?_with_rrdtool} \
        %{?_with_sensors} \
        %{?_with_sigrok} \
 +      %{?_with_smart} \
        %{?_with_snmp} \
        %{?_with_tape} \
        %{?_with_tokyotyrant} \
        %{?_with_varnish} \
        %{?_with_write_http} \
 +      %{?_with_write_kafka} \
        %{?_with_write_mongodb} \
        %{?_with_write_redis} \
        %{?_with_xmms} \
        %{?_with_zfs_arc} \
 +      %{?_with_zookeeper} \
        %{?_with_irq} \
        %{?_with_load} \
        %{?_with_logfile} \
        %{?_with_wireless}\
        %{?_with_write_graphite} \
        %{?_with_write_http} \
 -      %{?_with_write_riemann}
 +      %{?_with_write_log} \
 +      %{?_with_write_riemann} \
 +      %{?_with_write_sensu} \
 +      %{?_with_write_tsdb}
  
  
  %{__make} %{?_smp_mflags}
  %install
  rm -rf %{buildroot}
  %{__make} install DESTDIR=%{buildroot}
 -%{__install} -Dp -m 0755 contrib/redhat/init.d-collectd %{buildroot}%{_initrddir}/collectd
 +%if 0%{?el7:1}
 +%{__install} -Dp -m0644 contrib/systemd.collectd.service %{buildroot}%{_unitdir}/collectd.service
 +%else
 +%{__install} -Dp -m0755 contrib/redhat/init.d-collectd %{buildroot}%{_initrddir}/collectd
 +%endif
  %{__install} -Dp -m0644 src/collectd.conf %{buildroot}%{_sysconfdir}/collectd.conf
  %{__install} -d %{buildroot}%{_sharedstatedir}/collectd/
  %{__install} -d %{buildroot}%{_sysconfdir}/collectd.d/
@@@ -1762,44 -1572,19 +1762,44 @@@ rm -f %{buildroot}%{_mandir}/man5/colle
  %clean
  rm -rf %{buildroot}
  
 +%pre
 +%if 0%{?el7:1}
 +# stop sysv-based instance before upgrading to systemd
 +if [ $1 -eq 2 ] && [ -f /var/lock/subsys/collectd ]; then
 +      SYSTEMCTL_SKIP_REDIRECT=1 %{_initddir}/collectd stop >/dev/null 2>&1 || :
 +fi
 +%endif
 +
  %post
 -/sbin/chkconfig --add collectd
 +%if 0%{?el7:1}
 +if [ $1 -eq 2 ]; then
 +      /usr/bin/systemctl daemon-reload >/dev/null 2>&1 || :
 +fi
 +%systemd_post collectd.service
 +%else
 +/sbin/chkconfig --add collectd || :
 +%endif
  
  %preun
 +%if 0%{?el7:1}
 +%systemd_preun collectd.service
 +%else
 +# stop collectd only when uninstalling
  if [ $1 -eq 0 ]; then
 -      /sbin/service collectd stop &>/dev/null
 -      /sbin/chkconfig --del collectd
 +      /sbin/service collectd stop >/dev/null 2>&1 || :
 +      /sbin/chkconfig --del collectd || :
  fi
 +%endif
  
  %postun
 -if [ $1 -ge 1 ]; then
 -      /sbin/service collectd condrestart &>/dev/null || :
 +%if 0%{?el7:1}
 +%systemd_postun_with_restart collectd.service
 +%else
 +# restart collectd only when upgrading
 +if [ $1 -eq 1 ]; then
 +      /sbin/service collectd condrestart >/dev/null 2>&1 || :
  fi
 +%endif
  
  %post -n libcollectdclient -p /sbin/ldconfig
  %postun -n libcollectdclient -p /sbin/ldconfig
  %files
  %doc AUTHORS COPYING ChangeLog README
  %config(noreplace) %{_sysconfdir}/collectd.conf
 +%if 0%{?el7:1}
 +%{_unitdir}/collectd.service
 +%else
  %{_initrddir}/collectd
 +%endif
  %{_sbindir}/collectd
 -%{_bindir}/collectd-nagios
 -%{_bindir}/collectd-tg
 -%{_bindir}/collectdctl
  %{_sbindir}/collectdmon
  %{_datadir}/collectd/types.db
  %{_sharedstatedir}/collectd
 -%{_mandir}/man1/collectd-nagios.1*
  %{_mandir}/man1/collectd.1*
 -%{_mandir}/man1/collectdctl.1*
  %{_mandir}/man1/collectdmon.1*
 -%{_mandir}/man1/collectd-tg.1*
  %{_mandir}/man5/collectd-email.5*
  %{_mandir}/man5/collectd-exec.5*
  %{_mandir}/man5/collectd-threshold.5*
  %if %{with_df}
  %{_libdir}/%{name}/df.so
  %endif
 -%if %{with_disk}
 -%{_libdir}/%{name}/disk.so
 +%if %{with_drbd}
 +%{_libdir}/%{name}/drbd.so
  %endif
  %if %{with_ethstat}
  %{_libdir}/%{name}/ethstat.so
  %if %{with_interface}
  %{_libdir}/%{name}/interface.so
  %endif
 +%if %{with_ipc}
 +%{_libdir}/%{name}/ipc.so
 +%endif
  %if %{with_ipvs}
  %{_libdir}/%{name}/ipvs.so
  %endif
  %if %{with_thermal}
  %{_libdir}/%{name}/thermal.so
  %endif
- %if %{with_load}
+ %if %{with_threshold}
  %{_libdir}/%{name}/threshold.so
  %endif
  %if %{with_unixsock}
  %if %{with_write_graphite}
  %{_libdir}/%{name}/write_graphite.so
  %endif
 -
 +%if %{with_write_log}
 +%{_libdir}/%{name}/write_log.so
 +%endif
 +%if %{with_write_sensu}
 +%{_libdir}/%{name}/write_sensu.so
 +%endif
 +%if %{with_write_tsdb}
 +%{_libdir}/%{name}/write_tsdb.so
 +%endif
 +%if %{with_zfs_arc}
 +%{_libdir}/%{name}/zfs_arc.so
 +%endif
 +%if %{with_zookeeper}
 +%{_libdir}/%{name}/zookeeper.so
 +%endif
  
  %files -n libcollectdclient-devel
  %{_includedir}/collectd/client.h
  %{_libdir}/libcollectdclient.so
  %{_libdir}/libcollectdclient.so.*
  
 +%files -n collectd-utils
 +%{_bindir}/collectd-nagios
 +%{_bindir}/collectd-tg
 +%{_bindir}/collectdctl
 +%{_mandir}/man1/collectdctl.1*
 +%{_mandir}/man1/collectd-nagios.1*
 +%{_mandir}/man1/collectd-tg.1*
 +
  %if %{with_amqp}
  %files amqp
  %{_libdir}/%{name}/amqp.so
  %{_libdir}/%{name}/ascent.so
  %endif
  
 +%if %{with_barometer}
 +%files barometer
 +%{_libdir}/%{name}/barometer.so
 +%endif
 +
  %if %{with_bind}
  %files bind
  %{_libdir}/%{name}/bind.so
  %endif
  
 +%if %{with_ceph}
 +%files ceph
 +%{_libdir}/%{name}/ceph.so
 +%endif
 +
  %if %{with_curl}
  %files curl
  %{_libdir}/%{name}/curl.so
  %{_libdir}/%{name}/curl_xml.so
  %endif
  
 +%if %{with_disk}
 +%files disk
 +%{_libdir}/%{name}/disk.so
 +%endif
 +
  %if %{with_dns}
  %files dns
  %{_libdir}/%{name}/dns.so
  %{_mandir}/man5/collectd-java.5*
  %endif
  
 -%if %{with_libvirt}
 -%files libvirt
 -%{_libdir}/%{name}/libvirt.so
 +%if %{with_virt}
 +%files virt
 +%{_libdir}/%{name}/virt.so
 +%endif
 +
 +%if %{with_log_logstash}
 +%files log_logstash
 +%{_libdir}/%{name}/log_logstash.so
  %endif
  
  %if %{with_lvm}
  %{_libdir}/%{name}/nut.so
  %endif
  
 +%if %{with_openldap}
 +%files openldap
 +%{_libdir}/%{name}/openldap.so
 +%endif
 +
  %if %{with_perl}
  %files perl
  %{perl_vendorlib}/Collectd.pm
  %{_libdir}/%{name}/sigrok.so
  %endif
  
 +%if %{with_smart}
 +%files smart
 +%{_libdir}/%{name}/smart.so
 +%endif
 +
  %if %{with_snmp}
  %files snmp
  %{_mandir}/man5/collectd-snmp.5*
  %{_libdir}/%{name}/write_http.so
  %endif
  
 +%if %{with_write_kafka}
 +%files write_kafka
 +%{_libdir}/%{name}/write_kafka.so
 +%endif
 +
  %if %{with_write_redis}
  %files write_redis
  %{_libdir}/%{name}/write_redis.so
  %doc contrib/
  
  %changelog
 +# * TODO 5.5.0-1
 +# - New upstream version
 +# - New plugins enabled by default: ceph, drbd, log_logstash, write_tsdb, smart, openldap, redis, write_redis, zookeeper, write_log, write_sensu, ipc
 +# - New plugins disabled by default: barometer, write_kafka
 +# - Enable zfs_arc, now supported on Linux
 +# - Install disk plugin in a dedicated package, as it depends on libudev
 +# - use systemd on EL7, sysvinit on EL6 & EL5
 +# - Install collectdctl, collectd-tg and collectd-nagios in collectd-utils.rpm
 +
  * Mon Aug 19 2013 Marc Fournier <marc.fournier@camptocamp.com> 5.4.0-1
  - New upstream version
  - Build netlink plugin by default
  * Sat Nov 17 2012 Ruben Kerkhof <ruben@tilaa.nl> 5.1.0-2
  - Move perl stuff to perl_vendorlib
  - Replace hardcoded paths with macros
 -- Remove unneccesary Requires
 +- Remove unnecessary Requires
  - Removed .a and .la files
  - Some other small cleanups
  
  - New upstream version
  - Changes to support 5.1.0
  - Enabled all buildable plugins based on libraries available on EL6 + EPEL
 -- All plugins requiring external libraries are now shipped in seperate
 +- All plugins requiring external libraries are now shipped in separate
    packages.
  - No longer treat Java plugin as an exception, correctly set $JAVA_HOME during
    the build process + ensure build deps are installed.
diff --combined src/daemon/meta_data.c
index d3da9bb,0000000..6ee8446
mode 100644,000000..100644
--- /dev/null
@@@ -1,637 -1,0 +1,637 @@@
-     ERROR ("meta_data_get_signed_int: Type mismatch for key `%s'", e->key);
 +/**
 + * collectd - src/meta_data.c
 + * Copyright (C) 2008-2011  Florian octo Forster
 + *
 + * Permission is hereby granted, free of charge, to any person obtaining a
 + * copy of this software and associated documentation files (the "Software"),
 + * to deal in the Software without restriction, including without limitation
 + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 + * and/or sell copies of the Software, and to permit persons to whom the
 + * Software is furnished to do so, subject to the following conditions:
 + *
 + * The above copyright notice and this permission notice shall be included in
 + * all copies or substantial portions of the Software.
 + *
 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 + * DEALINGS IN THE SOFTWARE.
 + *
 + * Authors:
 + *   Florian octo Forster <octo at collectd.org>
 + **/
 +
 +#include "collectd.h"
 +#include "plugin.h"
 +#include "meta_data.h"
 +
 +#include <pthread.h>
 +
 +/*
 + * Data types
 + */
 +union meta_value_u
 +{
 +  char    *mv_string;
 +  int64_t  mv_signed_int;
 +  uint64_t mv_unsigned_int;
 +  double   mv_double;
 +  _Bool    mv_boolean;
 +};
 +typedef union meta_value_u meta_value_t;
 +
 +struct meta_entry_s;
 +typedef struct meta_entry_s meta_entry_t;
 +struct meta_entry_s
 +{
 +  char         *key;
 +  meta_value_t  value;
 +  int           type;
 +  meta_entry_t *next;
 +};
 +
 +struct meta_data_s
 +{
 +  meta_entry_t   *head;
 +  pthread_mutex_t lock;
 +};
 +
 +/*
 + * Private functions
 + */
 +static char *md_strdup (const char *orig) /* {{{ */
 +{
 +  size_t sz;
 +  char *dest;
 +
 +  if (orig == NULL)
 +    return (NULL);
 +
 +  sz = strlen (orig) + 1;
 +  dest = (char *) malloc (sz);
 +  if (dest == NULL)
 +    return (NULL);
 +
 +  memcpy (dest, orig, sz);
 +
 +  return (dest);
 +} /* }}} char *md_strdup */
 +
 +static meta_entry_t *md_entry_alloc (const char *key) /* {{{ */
 +{
 +  meta_entry_t *e;
 +
 +  e = (meta_entry_t *) malloc (sizeof (*e));
 +  if (e == NULL)
 +  {
 +    ERROR ("md_entry_alloc: malloc failed.");
 +    return (NULL);
 +  }
 +  memset (e, 0, sizeof (*e));
 +
 +  e->key = md_strdup (key);
 +  if (e->key == NULL)
 +  {
 +    free (e);
 +    ERROR ("md_entry_alloc: md_strdup failed.");
 +    return (NULL);
 +  }
 +
 +  e->type = 0;
 +  e->next = NULL;
 +
 +  return (e);
 +} /* }}} meta_entry_t *md_entry_alloc */
 +
 +static meta_entry_t *md_entry_clone (const meta_entry_t *orig) /* {{{ */
 +{
 +  meta_entry_t *copy;
 +
 +  if (orig == NULL)
 +    return (NULL);
 +
 +  copy = md_entry_alloc (orig->key);
 +  copy->type = orig->type;
 +  if (copy->type == MD_TYPE_STRING)
 +    copy->value.mv_string = strdup (orig->value.mv_string);
 +  else
 +    copy->value = orig->value;
 +
 +  copy->next = md_entry_clone (orig->next);
 +  return (copy);
 +} /* }}} meta_entry_t *md_entry_clone */
 +
 +static void md_entry_free (meta_entry_t *e) /* {{{ */
 +{
 +  if (e == NULL)
 +    return;
 +
 +  free (e->key);
 +
 +  if (e->type == MD_TYPE_STRING)
 +    free (e->value.mv_string);
 +
 +  if (e->next != NULL)
 +    md_entry_free (e->next);
 +
 +  free (e);
 +} /* }}} void md_entry_free */
 +
 +static int md_entry_insert (meta_data_t *md, meta_entry_t *e) /* {{{ */
 +{
 +  meta_entry_t *this;
 +  meta_entry_t *prev;
 +
 +  if ((md == NULL) || (e == NULL))
 +    return (-EINVAL);
 +
 +  pthread_mutex_lock (&md->lock);
 +
 +  prev = NULL;
 +  this = md->head;
 +  while (this != NULL)
 +  {
 +    if (strcasecmp (e->key, this->key) == 0)
 +      break;
 +
 +    prev = this;
 +    this = this->next;
 +  }
 +
 +  if (this == NULL)
 +  {
 +    /* This key does not exist yet. */
 +    if (md->head == NULL)
 +      md->head = e;
 +    else
 +    {
 +      assert (prev != NULL);
 +      prev->next = e;
 +    }
 +
 +    e->next = NULL;
 +  }
 +  else /* (this != NULL) */
 +  {
 +    if (prev == NULL)
 +      md->head = e;
 +    else
 +      prev->next = e;
 +
 +    e->next = this->next;
 +  }
 +
 +  pthread_mutex_unlock (&md->lock);
 +
 +  if (this != NULL)
 +  {
 +    this->next = NULL;
 +    md_entry_free (this);
 +  }
 +
 +  return (0);
 +} /* }}} int md_entry_insert */
 +
 +/* XXX: The lock on md must be held while calling this function! */
 +static meta_entry_t *md_entry_lookup (meta_data_t *md, /* {{{ */
 +    const char *key)
 +{
 +  meta_entry_t *e;
 +
 +  if ((md == NULL) || (key == NULL))
 +    return (NULL);
 +
 +  for (e = md->head; e != NULL; e = e->next)
 +    if (strcasecmp (key, e->key) == 0)
 +      break;
 +
 +  return (e);
 +} /* }}} meta_entry_t *md_entry_lookup */
 +
 +/*
 + * Public functions
 + */
 +meta_data_t *meta_data_create (void) /* {{{ */
 +{
 +  meta_data_t *md;
 +
 +  md = (meta_data_t *) malloc (sizeof (*md));
 +  if (md == NULL)
 +  {
 +    ERROR ("meta_data_create: malloc failed.");
 +    return (NULL);
 +  }
 +  memset (md, 0, sizeof (*md));
 +
 +  md->head = NULL;
 +  pthread_mutex_init (&md->lock, /* attr = */ NULL);
 +
 +  return (md);
 +} /* }}} meta_data_t *meta_data_create */
 +
 +meta_data_t *meta_data_clone (meta_data_t *orig) /* {{{ */
 +{
 +  meta_data_t *copy;
 +
 +  if (orig == NULL)
 +    return (NULL);
 +
 +  copy = meta_data_create ();
 +  if (copy == NULL)
 +    return (NULL);
 +
 +  pthread_mutex_lock (&orig->lock);
 +  copy->head = md_entry_clone (orig->head);
 +  pthread_mutex_unlock (&orig->lock);
 +
 +  return (copy);
 +} /* }}} meta_data_t *meta_data_clone */
 +
 +void meta_data_destroy (meta_data_t *md) /* {{{ */
 +{
 +  if (md == NULL)
 +    return;
 +
 +  pthread_mutex_destroy(&md->lock);
 +  md_entry_free (md->head);
 +  pthread_mutex_destroy (&md->lock);
 +  free (md);
 +} /* }}} void meta_data_destroy */
 +
 +int meta_data_exists (meta_data_t *md, const char *key) /* {{{ */
 +{
 +  meta_entry_t *e;
 +
 +  if ((md == NULL) || (key == NULL))
 +    return (-EINVAL);
 +
 +  pthread_mutex_lock (&md->lock);
 +
 +  for (e = md->head; e != NULL; e = e->next)
 +  {
 +    if (strcasecmp (key, e->key) == 0)
 +    {
 +      pthread_mutex_unlock (&md->lock);
 +      return (1);
 +    }
 +  }
 +
 +  pthread_mutex_unlock (&md->lock);
 +  return (0);
 +} /* }}} int meta_data_exists */
 +
 +int meta_data_type (meta_data_t *md, const char *key) /* {{{ */
 +{
 +  meta_entry_t *e;
 +
 +  if ((md == NULL) || (key == NULL))
 +    return -EINVAL;
 +
 +  pthread_mutex_lock (&md->lock);
 +
 +  for (e = md->head; e != NULL; e = e->next)
 +  {
 +    if (strcasecmp (key, e->key) == 0)
 +    {
 +      pthread_mutex_unlock (&md->lock);
 +      return e->type;
 +    }
 +  }
 +
 +  pthread_mutex_unlock (&md->lock);
 +  return 0;
 +} /* }}} int meta_data_type */
 +
 +int meta_data_toc (meta_data_t *md, char ***toc) /* {{{ */
 +{
 +  int i = 0, count = 0;
 +  meta_entry_t *e;
 +
 +  if ((md == NULL) || (toc == NULL))
 +    return -EINVAL;
 +
 +  pthread_mutex_lock (&md->lock);
 +
 +  for (e = md->head; e != NULL; e = e->next)
 +    ++count;    
 +
 +  if (count == 0)
 +  {
 +    pthread_mutex_unlock (&md->lock);
 +    return (count);
 +  }
 +
 +  *toc = calloc(count, sizeof(**toc));
 +  for (e = md->head; e != NULL; e = e->next)
 +    (*toc)[i++] = strdup(e->key);
 +  
 +  pthread_mutex_unlock (&md->lock);
 +  return count;
 +} /* }}} int meta_data_toc */
 +
 +int meta_data_delete (meta_data_t *md, const char *key) /* {{{ */
 +{
 +  meta_entry_t *this;
 +  meta_entry_t *prev;
 +
 +  if ((md == NULL) || (key == NULL))
 +    return (-EINVAL);
 +
 +  pthread_mutex_lock (&md->lock);
 +
 +  prev = NULL;
 +  this = md->head;
 +  while (this != NULL)
 +  {
 +    if (strcasecmp (key, this->key) == 0)
 +      break;
 +
 +    prev = this;
 +    this = this->next;
 +  }
 +
 +  if (this == NULL)
 +  {
 +    pthread_mutex_unlock (&md->lock);
 +    return (-ENOENT);
 +  }
 +
 +  if (prev == NULL)
 +    md->head = this->next;
 +  else
 +    prev->next = this->next;
 +
 +  pthread_mutex_unlock (&md->lock);
 +
 +  this->next = NULL;
 +  md_entry_free (this);
 +
 +  return (0);
 +} /* }}} int meta_data_delete */
 +
 +/*
 + * Add functions
 + */
 +int meta_data_add_string (meta_data_t *md, /* {{{ */
 +    const char *key, const char *value)
 +{
 +  meta_entry_t *e;
 +
 +  if ((md == NULL) || (key == NULL) || (value == NULL))
 +    return (-EINVAL);
 +
 +  e = md_entry_alloc (key);
 +  if (e == NULL)
 +    return (-ENOMEM);
 +
 +  e->value.mv_string = md_strdup (value);
 +  if (e->value.mv_string == NULL)
 +  {
 +    ERROR ("meta_data_add_string: md_strdup failed.");
 +    md_entry_free (e);
 +    return (-ENOMEM);
 +  }
 +  e->type = MD_TYPE_STRING;
 +
 +  return (md_entry_insert (md, e));
 +} /* }}} int meta_data_add_string */
 +
 +int meta_data_add_signed_int (meta_data_t *md, /* {{{ */
 +    const char *key, int64_t value)
 +{
 +  meta_entry_t *e;
 +
 +  if ((md == NULL) || (key == NULL))
 +    return (-EINVAL);
 +
 +  e = md_entry_alloc (key);
 +  if (e == NULL)
 +    return (-ENOMEM);
 +
 +  e->value.mv_signed_int = value;
 +  e->type = MD_TYPE_SIGNED_INT;
 +
 +  return (md_entry_insert (md, e));
 +} /* }}} int meta_data_add_signed_int */
 +
 +int meta_data_add_unsigned_int (meta_data_t *md, /* {{{ */
 +    const char *key, uint64_t value)
 +{
 +  meta_entry_t *e;
 +
 +  if ((md == NULL) || (key == NULL))
 +    return (-EINVAL);
 +
 +  e = md_entry_alloc (key);
 +  if (e == NULL)
 +    return (-ENOMEM);
 +
 +  e->value.mv_unsigned_int = value;
 +  e->type = MD_TYPE_UNSIGNED_INT;
 +
 +  return (md_entry_insert (md, e));
 +} /* }}} int meta_data_add_unsigned_int */
 +
 +int meta_data_add_double (meta_data_t *md, /* {{{ */
 +    const char *key, double value)
 +{
 +  meta_entry_t *e;
 +
 +  if ((md == NULL) || (key == NULL))
 +    return (-EINVAL);
 +
 +  e = md_entry_alloc (key);
 +  if (e == NULL)
 +    return (-ENOMEM);
 +
 +  e->value.mv_double = value;
 +  e->type = MD_TYPE_DOUBLE;
 +
 +  return (md_entry_insert (md, e));
 +} /* }}} int meta_data_add_double */
 +
 +int meta_data_add_boolean (meta_data_t *md, /* {{{ */
 +    const char *key, _Bool value)
 +{
 +  meta_entry_t *e;
 +
 +  if ((md == NULL) || (key == NULL))
 +    return (-EINVAL);
 +
 +  e = md_entry_alloc (key);
 +  if (e == NULL)
 +    return (-ENOMEM);
 +
 +  e->value.mv_boolean = value;
 +  e->type = MD_TYPE_BOOLEAN;
 +
 +  return (md_entry_insert (md, e));
 +} /* }}} int meta_data_add_boolean */
 +
 +/*
 + * Get functions
 + */
 +int meta_data_get_string (meta_data_t *md, /* {{{ */
 +    const char *key, char **value)
 +{
 +  meta_entry_t *e;
 +  char *temp;
 +
 +  if ((md == NULL) || (key == NULL) || (value == NULL))
 +    return (-EINVAL);
 +
 +  pthread_mutex_lock (&md->lock);
 +
 +  e = md_entry_lookup (md, key);
 +  if (e == NULL)
 +  {
 +    pthread_mutex_unlock (&md->lock);
 +    return (-ENOENT);
 +  }
 +
 +  if (e->type != MD_TYPE_STRING)
 +  {
++    ERROR ("meta_data_get_string: Type mismatch for key `%s'", e->key);
 +    pthread_mutex_unlock (&md->lock);
 +    return (-ENOENT);
 +  }
 +
 +  temp = md_strdup (e->value.mv_string);
 +  if (temp == NULL)
 +  {
 +    pthread_mutex_unlock (&md->lock);
 +    ERROR ("meta_data_get_string: md_strdup failed.");
 +    return (-ENOMEM);
 +  }
 + 
 +  pthread_mutex_unlock (&md->lock);
 +
 +  *value = temp;
 +
 +  return (0);
 +} /* }}} int meta_data_get_string */
 +
 +int meta_data_get_signed_int (meta_data_t *md, /* {{{ */
 +    const char *key, int64_t *value)
 +{
 +  meta_entry_t *e;
 +
 +  if ((md == NULL) || (key == NULL) || (value == NULL))
 +    return (-EINVAL);
 +
 +  pthread_mutex_lock (&md->lock);
 +
 +  e = md_entry_lookup (md, key);
 +  if (e == NULL)
 +  {
 +    pthread_mutex_unlock (&md->lock);
 +    return (-ENOENT);
 +  }
 +
 +  if (e->type != MD_TYPE_SIGNED_INT)
 +  {
 +    ERROR ("meta_data_get_signed_int: Type mismatch for key `%s'", e->key);
 +    pthread_mutex_unlock (&md->lock);
 +    return (-ENOENT);
 +  }
 +
 +  *value = e->value.mv_signed_int;
 +
 +  pthread_mutex_unlock (&md->lock);
 +  return (0);
 +} /* }}} int meta_data_get_signed_int */
 +
 +int meta_data_get_unsigned_int (meta_data_t *md, /* {{{ */
 +    const char *key, uint64_t *value)
 +{
 +  meta_entry_t *e;
 +
 +  if ((md == NULL) || (key == NULL) || (value == NULL))
 +    return (-EINVAL);
 +
 +  pthread_mutex_lock (&md->lock);
 +
 +  e = md_entry_lookup (md, key);
 +  if (e == NULL)
 +  {
 +    pthread_mutex_unlock (&md->lock);
 +    return (-ENOENT);
 +  }
 +
 +  if (e->type != MD_TYPE_UNSIGNED_INT)
 +  {
 +    ERROR ("meta_data_get_unsigned_int: Type mismatch for key `%s'", e->key);
 +    pthread_mutex_unlock (&md->lock);
 +    return (-ENOENT);
 +  }
 +
 +  *value = e->value.mv_unsigned_int;
 +
 +  pthread_mutex_unlock (&md->lock);
 +  return (0);
 +} /* }}} int meta_data_get_unsigned_int */
 +
 +int meta_data_get_double (meta_data_t *md, /* {{{ */
 +    const char *key, double *value)
 +{
 +  meta_entry_t *e;
 +
 +  if ((md == NULL) || (key == NULL) || (value == NULL))
 +    return (-EINVAL);
 +
 +  pthread_mutex_lock (&md->lock);
 +
 +  e = md_entry_lookup (md, key);
 +  if (e == NULL)
 +  {
 +    pthread_mutex_unlock (&md->lock);
 +    return (-ENOENT);
 +  }
 +
 +  if (e->type != MD_TYPE_DOUBLE)
 +  {
 +    ERROR ("meta_data_get_double: Type mismatch for key `%s'", e->key);
 +    pthread_mutex_unlock (&md->lock);
 +    return (-ENOENT);
 +  }
 +
 +  *value = e->value.mv_double;
 +
 +  pthread_mutex_unlock (&md->lock);
 +  return (0);
 +} /* }}} int meta_data_get_double */
 +
 +int meta_data_get_boolean (meta_data_t *md, /* {{{ */
 +    const char *key, _Bool *value)
 +{
 +  meta_entry_t *e;
 +
 +  if ((md == NULL) || (key == NULL) || (value == NULL))
 +    return (-EINVAL);
 +
 +  pthread_mutex_lock (&md->lock);
 +
 +  e = md_entry_lookup (md, key);
 +  if (e == NULL)
 +  {
 +    pthread_mutex_unlock (&md->lock);
 +    return (-ENOENT);
 +  }
 +
 +  if (e->type != MD_TYPE_BOOLEAN)
 +  {
 +    ERROR ("meta_data_get_boolean: Type mismatch for key `%s'", e->key);
 +    pthread_mutex_unlock (&md->lock);
 +    return (-ENOENT);
 +  }
 +
 +  *value = e->value.mv_boolean;
 +
 +  pthread_mutex_unlock (&md->lock);
 +  return (0);
 +} /* }}} int meta_data_get_boolean */
 +
 +/* vim: set sw=2 sts=2 et fdm=marker : */
diff --combined src/processes.c
@@@ -25,7 -25,7 +25,7 @@@
   *
   * Authors:
   *   Lyonel Vincent <lyonel at ezix.org>
 - *   Florian octo Forster <octo at verplant.org>
 + *   Florian octo Forster <octo at collectd.org>
   *   Oleg King <king2 at kaluga.ru>
   *   Sebastian Harl <sh at tokkee.org>
   *   Andrés J. Díaz <ajdiaz at connectical.com>
  #  endif
  /* #endif KERNEL_LINUX */
  
 -#elif HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC_FREEBSD
 +#elif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD)
  #  include <kvm.h>
  #  include <sys/param.h>
  #  include <sys/sysctl.h>
  #  include <sys/user.h>
  #  include <sys/proc.h>
 -/* #endif HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC_FREEBSD */
 +/* #endif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD) */
  
  #elif HAVE_PROCINFO_H
  #  include <procinfo.h>
  # include <kstat.h>
  #endif
  
 -#ifndef ARG_MAX
 -#  define ARG_MAX 4096
 +#ifndef CMDLINE_BUFFER_SIZE
 +# if defined(ARG_MAX) && (ARG_MAX < 4096)
 +#  define CMDLINE_BUFFER_SIZE ARG_MAX
 +# else
 +#  define CMDLINE_BUFFER_SIZE 4096
 +# endif
  #endif
  
  typedef struct procstat_entry_s
@@@ -214,9 -210,9 +214,9 @@@ static mach_msg_type_number_t     pset_
  static long pagesize_g;
  /* #endif KERNEL_LINUX */
  
 -#elif HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC_FREEBSD
 +#elif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD)
  static int pagesize;
 -/* #endif HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC_FREEBSD */
 +/* #endif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD) */
  
  #elif HAVE_PROCINFO_H
  static  struct procentry64 procentry[MAXPROCENTRY];
@@@ -623,9 -619,9 +623,9 @@@ static int ps_init (void
                        pagesize_g, CONFIG_HZ);
  /* #endif KERNEL_LINUX */
  
 -#elif HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC_FREEBSD
 +#elif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD)
        pagesize = getpagesize();
 -/* #endif HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC_FREEBSD */
 +/* #endif HAVE_LIBKVM_GETPROCS && (HAVE_STRUCT_KINFO_PROC_FREEBSD || HAVE_STRUCT_KINFO_PROC_OPENBSD) */
  
  #elif HAVE_PROCINFO_H
        pagesize = getpagesize();
@@@ -1690,7 -1686,7 +1690,7 @@@ static int ps_read (void
        DIR           *proc;
        int            pid;
  
 -      char cmdline[ARG_MAX];
 +      char cmdline[CMDLINE_BUFFER_SIZE];
  
        int        status;
        procstat_t ps;
        int wait     = 0;
  
        kvm_t *kd;
-       char errbuf[1024];
+       char errbuf[_POSIX2_LINE_MAX];
        struct kinfo_proc *procs;          /* array of processes */
        struct kinfo_proc *proc_ptr = NULL;
        int count;                         /* returns number of processes */
        ps_list_reset ();
  
        /* Open the kvm interface, get a descriptor */
-       kd = kvm_open (NULL, NULL, NULL, 0, errbuf);
+       kd = kvm_openfiles (NULL, "/dev/null", NULL, 0, errbuf);
        if (kd == NULL)
        {
                ERROR ("processes plugin: Cannot open kvm interface: %s",
                 * filter out threads (duplicate PID entries). */
                if ((proc_ptr == NULL) || (proc_ptr->ki_pid != procs[i].ki_pid))
                {
 -                      char cmdline[ARG_MAX] = "";
 +                      char cmdline[CMDLINE_BUFFER_SIZE] = "";
                        _Bool have_cmdline = 0;
  
                        proc_ptr = &(procs[i]);
                ps_submit_proc_list (ps_ptr);
  /* #endif HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC_FREEBSD */
  
 +#elif HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC_OPENBSD
 +      int running  = 0;
 +      int sleeping = 0;
 +      int zombies  = 0;
 +      int stopped  = 0;
 +      int onproc   = 0;
 +      int idle     = 0;
 +      int dead     = 0;
 +
 +      kvm_t *kd;
 +      char errbuf[1024];
 +      struct kinfo_proc *procs;          /* array of processes */
 +      struct kinfo_proc *proc_ptr = NULL;
 +      int count;                         /* returns number of processes */
 +      int i;
 +
 +      procstat_t *ps_ptr;
 +      procstat_entry_t pse;
 +
 +      ps_list_reset ();
 +
 +      /* Open the kvm interface, get a descriptor */
 +      kd = kvm_open (NULL, NULL, NULL, 0, errbuf);
 +      if (kd == NULL)
 +      {
 +              ERROR ("processes plugin: Cannot open kvm interface: %s",
 +                              errbuf);
 +              return (0);
 +      }
 +
 +      /* Get the list of processes. */
 +      procs = kvm_getprocs(kd, KERN_PROC_ALL, 0, sizeof(struct kinfo_proc), &count);
 +      if (procs == NULL)
 +      {
 +              ERROR ("processes plugin: Cannot get kvm processes list: %s",
 +                              kvm_geterr(kd));
 +              kvm_close (kd);
 +              return (0);
 +      }
 +
 +      /* Iterate through the processes in kinfo_proc */
 +      for (i = 0; i < count; i++)
 +      {
 +              /* Create only one process list entry per _process_, i.e.
 +               * filter out threads (duplicate PID entries). */
 +              if ((proc_ptr == NULL) || (proc_ptr->p_pid != procs[i].p_pid))
 +              {
 +                      char cmdline[CMDLINE_BUFFER_SIZE] = "";
 +                      _Bool have_cmdline = 0;
 +
 +                      proc_ptr = &(procs[i]);
 +                      /* Don't probe zombie processes  */
 +                      if (!P_ZOMBIE(proc_ptr))
 +                      {
 +                              char **argv;
 +                              int argc;
 +                              int status;
 +
 +                              /* retrieve the arguments */
 +                              argv = kvm_getargv (kd, proc_ptr, /* nchr = */ 0);
 +                              argc = 0;
 +                              if ((argv != NULL) && (argv[0] != NULL))
 +                              {
 +                                      while (argv[argc] != NULL)
 +                                              argc++;
 +
 +                                      status = strjoin (cmdline, sizeof (cmdline), argv, argc, " ");
 +                                      if (status < 0)
 +                                              WARNING ("processes plugin: Command line did not fit into buffer.");
 +                                      else
 +                                              have_cmdline = 1;
 +                              }
 +                      } /* if (process has argument list) */
 +
 +                      pse.id       = procs[i].p_pid;
 +                      pse.age      = 0;
 +
 +                      pse.num_proc = 1;
 +                      pse.num_lwp  = 1; /* XXX: accumulate p_tid values for a single p_pid ? */
 +
 +                      pse.vmem_rss = procs[i].p_vm_rssize * pagesize;
 +                      pse.vmem_data = procs[i].p_vm_dsize * pagesize;
 +                      pse.vmem_code = procs[i].p_vm_tsize * pagesize;
 +                      pse.stack_size = procs[i].p_vm_ssize * pagesize;
 +                      pse.vmem_size = pse.stack_size + pse.vmem_code + pse.vmem_data;
 +                      pse.vmem_minflt = 0;
 +                      pse.vmem_minflt_counter = procs[i].p_uru_minflt;
 +                      pse.vmem_majflt = 0;
 +                      pse.vmem_majflt_counter = procs[i].p_uru_majflt;
 +
 +                      pse.cpu_user = 0;
 +                      pse.cpu_system = 0;
 +                      pse.cpu_user_counter = procs[i].p_uutime_usec +
 +                                              (1000000lu * procs[i].p_uutime_sec);
 +                      pse.cpu_system_counter = procs[i].p_ustime_usec +
 +                                              (1000000lu * procs[i].p_ustime_sec);
 +
 +                      /* no I/O data */
 +                      pse.io_rchar = -1;
 +                      pse.io_wchar = -1;
 +                      pse.io_syscr = -1;
 +                      pse.io_syscw = -1;
 +
 +                      ps_list_add (procs[i].p_comm, have_cmdline ? cmdline : NULL, &pse);
 +              } /* if ((proc_ptr == NULL) || (proc_ptr->p_pid != procs[i].p_pid)) */
 +
 +              switch (procs[i].p_stat)
 +              {
 +                      case SSTOP:     stopped++;      break;
 +                      case SSLEEP:    sleeping++;     break;
 +                      case SRUN:      running++;      break;
 +                      case SIDL:      idle++;         break;
 +                      case SONPROC:   onproc++;       break;
 +                      case SDEAD:     dead++;         break;
 +                      case SZOMB:     zombies++;      break;
 +              }
 +      }
 +
 +      kvm_close(kd);
 +
 +      ps_submit_state ("running",  running);
 +      ps_submit_state ("sleeping", sleeping);
 +      ps_submit_state ("zombies",  zombies);
 +      ps_submit_state ("stopped",  stopped);
 +      ps_submit_state ("onproc",   onproc);
 +      ps_submit_state ("idle",     idle);
 +      ps_submit_state ("dead",     dead);
 +
 +      for (ps_ptr = list_head_g; ps_ptr != NULL; ps_ptr = ps_ptr->next)
 +              ps_submit_proc_list (ps_ptr);
 +/* #endif HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC_OPENBSD */
 +
  #elif HAVE_PROCINFO_H
        /* AIX */
        int running  = 0;
diff --combined src/swap.c
@@@ -1,6 -1,6 +1,6 @@@
  /**
   * collectd - src/swap.c
 - * Copyright (C) 2005-2012  Florian octo Forster
 + * Copyright (C) 2005-2014  Florian octo Forster
   * Copyright (C) 2009       Stefan Völkel
   * Copyright (C) 2009       Manuel Sanmartin
   * Copyright (C) 2010       Aurélien Reynaud
@@@ -97,45 -97,48 +97,45 @@@ int kvm_pagesize
  
  #elif HAVE_PERFSTAT
  static int pagesize;
 -static perfstat_memory_total_t pmemory;
  /*# endif HAVE_PERFSTAT */
  
  #else
  # error "No applicable input method."
  #endif /* HAVE_LIBSTATGRAB */
  
 -static const char *config_keys[] =
 -{
 -      "ReportBytes",
 -      "ReportByDevice"
 -};
 -static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
 +static _Bool values_absolute = 1;
 +static _Bool values_percentage = 0;
  
 -static int swap_config (const char *key, const char *value) /* {{{ */
 +static int swap_config (oconfig_item_t *ci) /* {{{ */
  {
 -      if (strcasecmp ("ReportBytes", key) == 0)
 +      int i;
 +
 +      for (i = 0; i < ci->children_num; i++)
        {
 +              oconfig_item_t *child = ci->children + i;
 +              if (strcasecmp ("ReportBytes", child->key) == 0)
  #if KERNEL_LINUX
 -              report_bytes = IS_TRUE (value) ? 1 : 0;
 +                      cf_util_get_boolean (child, &report_bytes);
  #else
 -              WARNING ("swap plugin: The \"ReportBytes\" option is only "
 -                              "valid under Linux. "
 -                              "The option is going to be ignored.");
 +                      WARNING ("swap plugin: The \"ReportBytes\" option "
 +                                      "is only valid under Linux. "
 +                                      "The option is going to be ignored.");
  #endif
 -      }
 -      else if (strcasecmp ("ReportByDevice", key) == 0)
 -      {
 +              else if (strcasecmp ("ReportByDevice", child->key) == 0)
  #if SWAP_HAVE_REPORT_BY_DEVICE
 -              if (IS_TRUE (value))
 -                      report_by_device = 1;
 -              else
 -                      report_by_device = 0;
 +                      cf_util_get_boolean (child, &report_by_device);
  #else
 -              WARNING ("swap plugin: The \"ReportByDevice\" option is not "
 -                              "supported on this platform. "
 -                              "The option is going to be ignored.");
 +                      WARNING ("swap plugin: The \"ReportByDevice\" option "
 +                                      "is not supported on this platform. "
 +                                      "The option is going to be ignored.");
  #endif /* SWAP_HAVE_REPORT_BY_DEVICE */
 -      }
 -      else
 -      {
 -              return (-1);
 +              else if (strcasecmp ("ValuesAbsolute", child->key) == 0)
 +                      cf_util_get_boolean (child, &values_absolute);
 +              else if (strcasecmp ("ValuesPercentage", child->key) == 0)
 +                      cf_util_get_boolean (child, &values_percentage);
 +              else
 +                      WARNING ("swap plugin: Unknown config option: \"%s\"",
 +                                      child->key);
        }
  
        return (0);
@@@ -157,6 -160,8 +157,8 @@@ static int swap_init (void) /* {{{ *
  /* #endif defined(VM_SWAPUSAGE) */
  
  #elif HAVE_LIBKVM_GETSWAPINFO
+       char errbuf[_POSIX2_LINE_MAX];
        if (kvm_obj != NULL)
        {
                kvm_close (kvm_obj);
  
        kvm_pagesize = getpagesize ();
  
-       if ((kvm_obj = kvm_open (NULL, /* execfile */
-                                       NULL, /* corefile */
-                                       NULL, /* swapfile */
-                                       O_RDONLY, /* flags */
-                                       NULL)) /* errstr */
-                       == NULL)
+       kvm_obj = kvm_openfiles (NULL, "/dev/null", NULL, O_RDONLY, errbuf);
+       if (kvm_obj == NULL)
        {
-               ERROR ("swap plugin: kvm_open failed.");
+               ERROR ("swap plugin: kvm_openfiles failed, %s", errbuf);
                return (-1);
        }
  /* #endif HAVE_LIBKVM_GETSWAPINFO */
        return (0);
  } /* }}} int swap_init */
  
 -static void swap_submit (const char *plugin_instance, /* {{{ */
 -              const char *type, const char *type_instance,
 -              value_t value)
 +static void swap_submit_usage (char const *plugin_instance, /* {{{ */
 +              gauge_t used, gauge_t free,
 +              char const *other_name, gauge_t other_value)
  {
 +      value_t v[1];
        value_list_t vl = VALUE_LIST_INIT;
  
 -      assert (type != NULL);
 -
 -      vl.values = &value;
 -      vl.values_len = 1;
 +      vl.values = v;
 +      vl.values_len = STATIC_ARRAY_SIZE (v);
        sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "swap", sizeof (vl.plugin));
        if (plugin_instance != NULL)
 -              sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
 -      sstrncpy (vl.type, type, sizeof (vl.type));
 -      if (type_instance != NULL)
 -              sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
 -
 -      plugin_dispatch_values (&vl);
 -} /* }}} void swap_submit_inst */
 +              sstrncpy (vl.plugin_instance, plugin_instance,
 +                              sizeof (vl.plugin_instance));
 +      sstrncpy (vl.type, "swap", sizeof (vl.type));
 +
 +      if (values_absolute)
 +              plugin_dispatch_multivalue (&vl, 0, DS_TYPE_GAUGE,
 +                              "used", used, "free", free,
 +                              other_name, other_value, NULL);
 +      if (values_percentage)
 +              plugin_dispatch_multivalue (&vl, 1, DS_TYPE_GAUGE,
 +                              "used", used, "free", free,
 +                              other_name, other_value, NULL);
 +} /* }}} void swap_submit_usage */
  
 -static void swap_submit_gauge (const char *plugin_instance, /* {{{ */
 -              const char *type_instance, gauge_t value)
 +#if KERNEL_LINUX || HAVE_PERFSTAT
 +__attribute__((nonnull(1)))
 +static void swap_submit_derive (char const *type_instance, /* {{{ */
 +              derive_t value)
  {
 -      value_t v;
 +      value_list_t vl = VALUE_LIST_INIT;
 +      value_t v[1];
  
 -      v.gauge = value;
 -      swap_submit (plugin_instance, "swap", type_instance, v);
 -} /* }}} void swap_submit_gauge */
 +      v[0].derive = value;
  
 -#if KERNEL_LINUX || HAVE_PERFSTAT
 -static void swap_submit_derive (const char *plugin_instance, /* {{{ */
 -              const char *type_instance, derive_t value)
 -{
 -      value_t v;
 +      vl.values = v;
 +      vl.values_len = STATIC_ARRAY_SIZE (v);
 +      sstrncpy (vl.host, hostname_g, sizeof (vl.host));
 +      sstrncpy (vl.plugin, "swap", sizeof (vl.plugin));
 +      sstrncpy (vl.type, "swap_io", sizeof (vl.type));
 +      sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
  
 -      v.derive = value;
 -      swap_submit (plugin_instance, "swap_io", type_instance, v);
 +      plugin_dispatch_values (&vl);
  } /* }}} void swap_submit_derive */
  #endif
  
@@@ -257,8 -253,9 +256,8 @@@ static int swap_read_separate (void) /
                char *endptr;
  
                char path[PATH_MAX];
 -              gauge_t size;
 +              gauge_t total;
                gauge_t used;
 -              gauge_t free;
  
                numfields = strsplit (buffer, fields, STATIC_ARRAY_SIZE (fields));
                if (numfields != 5)
  
                errno = 0;
                endptr = NULL;
 -              size = strtod (fields[2], &endptr);
 +              total = strtod (fields[2], &endptr);
                if ((endptr == fields[2]) || (errno != 0))
                        continue;
  
                if ((endptr == fields[3]) || (errno != 0))
                        continue;
  
 -              if (size < used)
 +              if (total < used)
                        continue;
  
 -              free = size - used;
 -
 -              swap_submit_gauge (path, "used", used);
 -              swap_submit_gauge (path, "free", free);
 +              swap_submit_usage (path, used, total - used, NULL, NAN);
        }
  
        fclose (fh);
@@@ -295,10 -295,11 +294,10 @@@ static int swap_read_combined (void) /
        FILE *fh;
        char buffer[1024];
  
 -      uint8_t have_data = 0;
 -      gauge_t swap_used   = 0.0;
 -      gauge_t swap_cached = 0.0;
 -      gauge_t swap_free   = 0.0;
 -      gauge_t swap_total  = 0.0;
 +      gauge_t swap_used   = NAN;
 +      gauge_t swap_cached = NAN;
 +      gauge_t swap_free   = NAN;
 +      gauge_t swap_total  = NAN;
  
        fh = fopen ("/proc/meminfo", "r");
        if (fh == NULL)
                        continue;
  
                if (strcasecmp (fields[0], "SwapTotal:") == 0)
 -              {
 -                      swap_total = strtod (fields[1], /* endptr = */ NULL);
 -                      have_data |= 0x01;
 -              }
 +                      strtogauge (fields[1], &swap_total);
                else if (strcasecmp (fields[0], "SwapFree:") == 0)
 -              {
 -                      swap_free = strtod (fields[1], /* endptr = */ NULL);
 -                      have_data |= 0x02;
 -              }
 +                      strtogauge (fields[1], &swap_free);
                else if (strcasecmp (fields[0], "SwapCached:") == 0)
 -              {
 -                      swap_cached = strtod (fields[1], /* endptr = */ NULL);
 -                      have_data |= 0x04;
 -              }
 +                      strtogauge (fields[1], &swap_cached);
        }
  
        fclose (fh);
  
 -      if ((have_data & 0x03) != 0x03)
 +      if (isnan (swap_total) || isnan (swap_free))
                return (ENOENT);
  
 -      if (isnan (swap_total)
 -                      || (swap_total <= 0.0)
 -                      || ((swap_free + swap_cached) > swap_total))
 -              return (EINVAL);
 -
 -      swap_used = swap_total - (swap_free + swap_cached);
 +      /* Some systems, OpenVZ for example, don't provide SwapCached. */
 +      if (isnan (swap_cached))
 +              swap_used = swap_total - swap_free;
 +      else
 +              swap_used = swap_total - (swap_free + swap_cached);
 +      assert (!isnan (swap_used));
  
 -      swap_submit_gauge (NULL, "used",   1024.0 * swap_used);
 -      swap_submit_gauge (NULL, "free",   1024.0 * swap_free);
 -      if (have_data & 0x04)
 -              swap_submit_gauge (NULL, "cached", 1024.0 * swap_cached);
 +      if (swap_used < 0.0)
 +              return (EINVAL);
  
 +      swap_submit_usage (NULL, swap_used, swap_free,
 +                      isnan (swap_cached) ? NULL : "cached", swap_cached);
        return (0);
  } /* }}} int swap_read_combined */
  
@@@ -420,8 -430,8 +419,8 @@@ static int swap_read_io (void) /* {{{ *
                swap_out = swap_out * pagesize;
        }
  
 -      swap_submit_derive (NULL, "in",  swap_in);
 -      swap_submit_derive (NULL, "out", swap_out);
 +      swap_submit_derive ("in",  swap_in);
 +      swap_submit_derive ("out", swap_out);
  
        return (0);
  } /* }}} int swap_read_io */
@@@ -452,9 -462,9 +451,9 @@@ static int swap_read (void) /* {{{ *
  /* kstat-based read function */
  static int swap_read_kstat (void) /* {{{ */
  {
 -      derive_t swap_alloc;
 -      derive_t swap_resv;
 -      derive_t swap_avail;
 +      gauge_t swap_alloc;
 +      gauge_t swap_resv;
 +      gauge_t swap_avail;
  
        struct anoninfo ai;
  
         * swap_alloc = pagesize * ( ai.ani_max - ai.ani_free );
         * can suffer from a 32bit overflow.
         */
 -      swap_alloc  = (derive_t) ((ai.ani_max - ai.ani_free) * pagesize);
 -      swap_resv   = (derive_t) ((ai.ani_resv + ai.ani_free - ai.ani_max)
 -                      * pagesize);
 -      swap_avail  = (derive_t) ((ai.ani_max - ai.ani_resv) * pagesize);
 -
 -      swap_submit_gauge (NULL, "used", swap_alloc);
 -      swap_submit_gauge (NULL, "free", swap_avail);
 -      swap_submit_gauge (NULL, "reserved", swap_resv);
 +      swap_alloc = (gauge_t) ((ai.ani_max - ai.ani_free) * pagesize);
 +      swap_resv  = (gauge_t) ((ai.ani_resv + ai.ani_free - ai.ani_max) * pagesize);
 +      swap_avail = (gauge_t) ((ai.ani_max - ai.ani_resv) * pagesize);
  
 +      swap_submit_usage (NULL, swap_alloc, swap_avail, "reserved", swap_resv);
        return (0);
  } /* }}} int swap_read_kstat */
  /* #endif 0 && HAVE_LIBKSTAT */
@@@ -506,8 -520,8 +505,8 @@@ static int swap_read (void) /* {{{ *
          int status;
          int i;
  
 -        derive_t avail = 0;
 -        derive_t total = 0;
 +        gauge_t avail = 0;
 +        gauge_t total = 0;
  
          swap_num = swapctl (SC_GETNSWP, NULL);
          if (swap_num < 0)
          for (i = 0; i < swap_num; i++)
          {
                char path[PATH_MAX];
 -              derive_t this_total;
 -              derive_t this_avail;
 +              gauge_t this_total;
 +              gauge_t this_avail;
  
                  if ((s->swt_ent[i].ste_flags & ST_INDEL) != 0)
                          continue;
  
 -              this_total = ((derive_t) s->swt_ent[i].ste_pages) * pagesize;
 -              this_avail = ((derive_t) s->swt_ent[i].ste_free)  * pagesize;
 +              this_total = (gauge_t) (s->swt_ent[i].ste_pages * pagesize);
 +              this_avail = (gauge_t) (s->swt_ent[i].ste_free  * pagesize);
  
                /* Shortcut for the "combined" setting (default) */
                if (!report_by_device)
                sstrncpy (path, s->swt_ent[i].ste_path, sizeof (path));
                escape_slashes (path, sizeof (path));
  
 -              swap_submit_gauge (path, "used", (gauge_t) (this_total - this_avail));
 -              swap_submit_gauge (path, "free", (gauge_t) this_avail);
 +              swap_submit_usage (path, this_total - this_avail, this_avail,
 +                              NULL, NAN);
          } /* for (swap_num) */
  
          if (total < avail)
          {
 -                ERROR ("swap plugin: Total swap space (%"PRIi64") "
 -                                "is less than free swap space (%"PRIi64").",
 +                ERROR ("swap plugin: Total swap space (%g) is less than free swap space (%g).",
                                  total, avail);
                sfree (s_paths);
                  sfree (s);
                  return (-1);
          }
  
 -      /* If the "separate" option was specified (report_by_device == 2), all
 +      /* If the "separate" option was specified (report_by_device == 1), all
         * values have already been dispatched from within the loop. */
        if (!report_by_device)
 -      {
 -              swap_submit_gauge (NULL, "used", (gauge_t) (total - avail));
 -              swap_submit_gauge (NULL, "free", (gauge_t) avail);
 -      }
 +              swap_submit_usage (NULL, total - avail, avail, NULL, NAN);
  
        sfree (s_paths);
          sfree (s);
@@@ -622,8 -640,8 +621,8 @@@ static int swap_read (void) /* {{{ *
        int status;
        int i;
  
 -      derive_t used  = 0;
 -      derive_t total = 0;
 +      gauge_t used  = 0;
 +      gauge_t total = 0;
  
        swap_num = swapctl (SWAP_NSWAP, NULL, 0);
        if (swap_num < 0)
        }
  
  #if defined(DEV_BSIZE) && (DEV_BSIZE > 0)
 -# define C_SWAP_BLOCK_SIZE ((derive_t) DEV_BSIZE)
 +# define C_SWAP_BLOCK_SIZE ((gauge_t) DEV_BSIZE)
  #else
 -# define C_SWAP_BLOCK_SIZE ((derive_t) 512)
 +# define C_SWAP_BLOCK_SIZE 512.0
  #endif
  
 +      /* TODO: Report per-device stats. The path name is available from
 +       * swap_entries[i].se_path */
        for (i = 0; i < swap_num; i++)
        {
                if ((swap_entries[i].se_flags & SWF_ENABLE) == 0)
                        continue;
  
 -              used  += ((derive_t) swap_entries[i].se_inuse)
 -                      * C_SWAP_BLOCK_SIZE;
 -              total += ((derive_t) swap_entries[i].se_nblks)
 -                      * C_SWAP_BLOCK_SIZE;
 +              used  += ((gauge_t) swap_entries[i].se_inuse) * C_SWAP_BLOCK_SIZE;
 +              total += ((gauge_t) swap_entries[i].se_nblks) * C_SWAP_BLOCK_SIZE;
        }
  
        if (total < used)
        {
 -              ERROR ("swap plugin: Total swap space (%"PRIu64") "
 -                              "is less than used swap space (%"PRIu64").",
 +              ERROR ("swap plugin: Total swap space (%g) is less than used swap space (%g).",
                                total, used);
                return (-1);
        }
  
 -      swap_submit_gauge (NULL, "used", (gauge_t) used);
 -      swap_submit_gauge (NULL, "free", (gauge_t) (total - used));
 +      swap_submit_usage (NULL, used, total - used, NULL, NAN);
  
        sfree (swap_entries);
 -
        return (0);
  } /* }}} int swap_read */
  /* #endif HAVE_SWAPCTL && HAVE_SWAPCTL_THREE_ARGS */
@@@ -700,9 -721,8 +699,9 @@@ static int swap_read (void) /* {{{ *
                return (-1);
  
        /* The returned values are bytes. */
 -      swap_submit_gauge (NULL, "used", (gauge_t) sw_usage.xsu_used);
 -      swap_submit_gauge (NULL, "free", (gauge_t) sw_usage.xsu_avail);
 +      swap_submit_usage (NULL,
 +                      (gauge_t) sw_usage.xsu_used, (gauge_t) sw_usage.xsu_avail,
 +                      NULL, NAN);
  
        return (0);
  } /* }}} int swap_read */
@@@ -714,8 -734,9 +713,8 @@@ static int swap_read (void) /* {{{ *
        struct kvm_swap data_s;
        int             status;
  
 -      derive_t used;
 -      derive_t free;
 -      derive_t total;
 +      gauge_t used;
 +      gauge_t total;
  
        if (kvm_obj == NULL)
                return (-1);
        if (status == -1)
                return (-1);
  
 -      total = (derive_t) data_s.ksw_total;
 -      used  = (derive_t) data_s.ksw_used;
 -
 -      total *= (derive_t) kvm_pagesize;
 -      used  *= (derive_t) kvm_pagesize;
 +      total = (gauge_t) data_s.ksw_total;
 +      used  = (gauge_t) data_s.ksw_used;
  
 -      free = total - used;
 +      total *= (gauge_t) kvm_pagesize;
 +      used  *= (gauge_t) kvm_pagesize;
  
 -      swap_submit_gauge (NULL, "used", (gauge_t) used);
 -      swap_submit_gauge (NULL, "free", (gauge_t) free);
 +      swap_submit_usage (NULL, used, total - used, NULL, NAN);
  
        return (0);
  } /* }}} int swap_read */
@@@ -743,11 -767,12 +742,11 @@@ static int swap_read (void) /* {{{ *
        sg_swap_stats *swap;
  
        swap = sg_get_swap_stats ();
 -
        if (swap == NULL)
                return (-1);
  
 -      swap_submit_gauge (NULL, "used", (gauge_t) swap->used);
 -      swap_submit_gauge (NULL, "free", (gauge_t) swap->free);
 +      swap_submit_usage (NULL, (gauge_t) swap->used, (gauge_t) swap->free,
 +                      NULL, NAN);
  
        return (0);
  } /* }}} int swap_read */
  #elif HAVE_PERFSTAT
  static int swap_read (void) /* {{{ */
  {
 -        if(perfstat_memory_total(NULL, &pmemory, sizeof(perfstat_memory_total_t), 1) < 0)
 +      perfstat_memory_total_t pmemory;
 +      int status;
 +
 +      gauge_t total;
 +      gauge_t free;
 +      gauge_t reserved;
 +
 +      memset (&pmemory, 0, sizeof (pmemory));
 +        status = perfstat_memory_total (NULL, &pmemory, sizeof(perfstat_memory_total_t), 1);
 +      if (status < 0)
        {
                  char errbuf[1024];
 -                WARNING ("memory plugin: perfstat_memory_total failed: %s",
 +                WARNING ("swap plugin: perfstat_memory_total failed: %s",
                          sstrerror (errno, errbuf, sizeof (errbuf)));
                  return (-1);
          }
  
 -      swap_submit_gauge (NULL, "used", (gauge_t) (pmemory.pgsp_total - pmemory.pgsp_free) * pagesize);
 -      swap_submit_gauge (NULL, "free", (gauge_t) pmemory.pgsp_free * pagesize );
 -      swap_submit_gauge (NULL, "reserved", (gauge_t) pmemory.pgsp_rsvd * pagesize);
 -      swap_submit_derive (NULL, "in",  (derive_t) pmemory.pgspins * pagesize);
 -      swap_submit_derive (NULL, "out", (derive_t) pmemory.pgspouts * pagesize);
 +      total    = (gauge_t) (pmemory.pgsp_total * pagesize);
 +      free     = (gauge_t) (pmemory.pgsp_free * pagesize);
 +      reserved = (gauge_t) (pmemory.pgsp_rsvd * pagesize);
 +
 +      swap_submit_usage (NULL, total - free, free, "reserved", reserved);
 +      swap_submit_derive ("in",  (derive_t) pmemory.pgspins * pagesize);
 +      swap_submit_derive ("out", (derive_t) pmemory.pgspouts * pagesize);
  
        return (0);
  } /* }}} int swap_read */
  
  void module_register (void)
  {
 -      plugin_register_config ("swap", swap_config,
 -                      config_keys, config_keys_num);
 +      plugin_register_complex_config ("swap", swap_config);
        plugin_register_init ("swap", swap_init);
        plugin_register_read ("swap", swap_read);
  } /* void module_register */