Merge branch 'collectd-5.5'
authorRuben Kerkhof <ruben@rubenkerkhof.com>
Wed, 25 May 2016 14:54:54 +0000 (16:54 +0200)
committerRuben Kerkhof <ruben@rubenkerkhof.com>
Wed, 25 May 2016 14:54:54 +0000 (16:54 +0200)
Conflicts:
configure.ac

1  2 
configure.ac
src/Makefile.am
src/collectd.conf.in
src/processes.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/)
 +AC_CONFIG_SRCDIR(src/target_set.c)
  AC_CONFIG_HEADERS(src/config.h)
  AC_CONFIG_AUX_DIR([libltdl/config])
  
@@@ -112,10 -112,6 +112,10 @@@ case $host_os i
        AC_DEFINE([KERNEL_OPENBSD], 1, [True if program is to be compiled for an OpenBSD kernel])
        ac_system="OpenBSD"
        ;;
 +      *netbsd*)
 +      AC_DEFINE([KERNEL_NETBSD], 1, [True if program is to be compiled for a NetBSD kernel])
 +      ac_system="NetBSD"
 +      ;;
        *aix*)
        AC_DEFINE([KERNEL_AIX], 1, [True if program is to be compiled for a AIX kernel])
        ac_system="AIX"
@@@ -203,19 -199,6 +203,19 @@@ AC_HEADER_STDBOO
  
  AC_CHECK_HEADERS(stdio.h errno.h math.h stdarg.h syslog.h fcntl.h signal.h assert.h sys/types.h sys/socket.h sys/select.h poll.h netdb.h arpa/inet.h sys/resource.h sys/param.h kstat.h regex.h sys/ioctl.h endian.h sys/isa_defs.h fnmatch.h libgen.h)
  
 +# For entropy plugin on newer NetBSD
 +AC_CHECK_HEADERS(sys/rndio.h, [], [],
 +[#if HAVE_SYS_TYPES_H
 +# include <sys/types.h>
 +#endif
 +#if HAVE_SYS_IOCTL_H
 +# include <sys/ioctl.h>
 +#endif
 +#if HAVE_SYS_PARAM_H
 +# include <sys/param.h>
 +#endif
 +])
 +
  # For ping library
  AC_CHECK_HEADERS(netinet/in_systm.h, [], [],
  [#if HAVE_STDINT_H
@@@ -430,7 -413,7 +430,7 @@@ AC_CHECK_HEADERS(sys/sysctl.h, [], []
  AC_MSG_CHECKING([for sysctl kern.cp_times])
  if test -x /sbin/sysctl
  then
 -      /sbin/sysctl kern.cp_times 2>/dev/null
 +      /sbin/sysctl kern.cp_times >/dev/null 2>&1
        if test $? -eq 0
        then
                AC_MSG_RESULT([yes])
@@@ -443,22 -426,6 +443,22 @@@ els
        AC_MSG_RESULT([no])
  fi
  
 +AC_MSG_CHECKING([for sysctl kern.cp_time])
 +if test -x /sbin/sysctl
 +then
 +      /sbin/sysctl kern.cp_time >/dev/null 2>&1
 +      if test $? -eq 0
 +      then
 +              AC_MSG_RESULT([yes])
 +              AC_DEFINE(HAVE_SYSCTL_KERN_CP_TIME, 1,
 +                      [Define if sysctl supports kern.cp_time])
 +      else
 +              AC_MSG_RESULT([no])
 +      fi
 +else
 +      AC_MSG_RESULT([no])
 +fi
 +
  # For hddtemp module
  AC_CHECK_HEADERS(linux/major.h)
  
@@@ -477,7 -444,7 +477,7 @@@ els
        have_linux_raid_md_u_h="no"
  fi
  
 -# For the swap module
 +# For the wireless module
  have_linux_wireless_h="no"
  if test "x$ac_system" = "xLinux"
  then
@@@ -712,6 -679,8 +712,6 @@@ AC_CHECK_HEADERS(netinet/if_ether.h, []
  #endif
  ])
  
 -AC_CHECK_HEADERS(netinet/ip_compat.h)
 -
  have_net_pfvar_h="no"
  AC_CHECK_HEADERS(net/pfvar.h,
                 [have_net_pfvar_h="yes"],
@@@ -766,9 -735,13 +766,9 @@@ AC_CHECK_HEADERS(sys/capability.h
  # Checks for typedefs, structures, and compiler characteristics.
  #
  AC_C_CONST
 -AC_C_INLINE
 -AC_TYPE_OFF_T
  AC_TYPE_PID_T
  AC_TYPE_SIZE_T
 -AC_TYPE_SSIZE_T
  AC_TYPE_UID_T
 -AC_TYPE_UINT32_T
  AC_HEADER_TIME
  
  #
@@@ -878,6 -851,8 +878,6 @@@ f
  if test "x$have_clock_gettime" = "xyes"
  then
        AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if the clock_gettime(2) function is available.])
 -else
 -      AC_MSG_WARN(cannot find clock_gettime)
  fi
  
  nanosleep_needs_rt="no"
@@@ -1505,24 -1480,6 +1505,24 @@@ AC_CHECK_MEMBERS([struct kinfo_proc.p_p
  #include <kvm.h>
        ])
  
 +
 +AC_CHECK_MEMBERS([struct kinfo_proc2.p_pid, struct kinfo_proc2.p_uru_maxrss],
 +      [
 +              AC_DEFINE(HAVE_STRUCT_KINFO_PROC2_NETBSD, 1,
 +                      [Define if struct kinfo_proc2 exists in the NetBSD variant.])
 +              have_struct_kinfo_proc2_netbsd="yes"
 +      ],
 +      [
 +              have_struct_kinfo_proc2_netbsd="no"
 +      ],
 +      [
 +#include <sys/param.h>
 +#include <sys/sysctl.h>
 +#include <kvm.h>
 +      ])
 +
 +
 +
  AC_CHECK_MEMBERS([struct udphdr.uh_dport, struct udphdr.uh_sport], [], [],
  [#define _BSD_SOURCE
  #define _DEFAULT_SOURCE
@@@ -1603,46 -1560,6 +1603,46 @@@ if test "x$with_libhal" = "xyes"; the
        fi
  fi
  
 +# --with-libpthread {{{
 +AC_ARG_WITH(libpthread, [AS_HELP_STRING([--with-libpthread=@<:@=PREFIX@:>@], [Path to libpthread.])],
 +[     if test "x$withval" != "xno" \
 +              && test "x$withval" != "xyes"
 +      then
 +              LDFLAGS="$LDFLAGS -L$withval/lib"
 +              CPPFLAGS="$CPPFLAGS -I$withval/include"
 +              with_libpthread="yes"
 +      else
 +              if test "x$withval" = "xno"
 +              then
 +                      with_libpthread="no (disabled)"
 +              fi
 +      fi
 +], [with_libpthread="yes"])
 +
 +AC_SUBST([PTHREAD_LIBS])
 +if test "x$with_libpthread" = "xyes"
 +then
 +      SAVE_LIBS="$LIBS"
 +      AC_CHECK_LIB(pthread, pthread_create, [], [with_libpthread="no (Symbol 'pthread_create' not found)"], [])
 +      PTHREAD_LIBS="$LIBS"
 +      LIBS="$SAVE_LIBS"
 +fi
 +
 +if test "x$with_libpthread" = "xyes"
 +then
 +      AC_CHECK_HEADERS(pthread.h,, [with_libpthread="no (pthread.h not found)"])
 +fi
 +if test "x$with_libpthread" = "xyes"
 +then
 +      collect_pthread=1
 +else
 +      collect_pthread=0
 +fi
 +AC_DEFINE_UNQUOTED(HAVE_LIBPTHREAD, [$collect_pthread],
 +      [Wether or not to use pthread (POSIX threads) library])
 +AM_CONDITIONAL(BUILD_WITH_LIBPTHREAD, test "x$with_libpthread" = "xyes")
 +# }}}
 +
  m4_divert_once([HELP_WITH], [
  collectd additional packages:])
  
@@@ -2193,6 -2110,12 +2193,6 @@@ the
        AC_CHECK_LIB(gcrypt, gcry_md_hash_buffer,
                [with_libgcrypt="yes"],
                [with_libgcrypt="no (symbol gcry_md_hash_buffer not found)"])
 -
 -      if test "$with_libgcrypt" != "no"; then
 -              m4_ifdef([AM_PATH_LIBGCRYPT],[AM_PATH_LIBGCRYPT(1:1.2.0,,with_libgcrypt="no (version 1.2.0+ required)")])
 -              GCRYPT_CPPFLAGS="$LIBGCRYPT_CPPFLAGS $LIBGCRYPT_CFLAGS"
 -              GCRYPT_LIBS="$LIBGCRYPT_LIBS"
 -      fi
  fi
  
  CPPFLAGS="$SAVE_CPPFLAGS"
@@@ -2311,6 -2234,9 +2311,6 @@@ 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=""
  JAVAC="$JAVAC"
  JAR="$JAR"
  AC_ARG_WITH(java, [AS_HELP_STRING([--with-java@<:@=PREFIX@:>@], [Path to Java home.])],
@@@ -2403,10 -2329,6 +2403,10 @@@ if test "x$JAVA_LDFLAGS" != "x
  then
        AC_MSG_NOTICE([Building with JAVA_LDFLAGS set to: $JAVA_LDFLAGS])
  fi
 +if test "x$JAVA_LIBS" != "x"
 +then
 +      AC_MSG_NOTICE([Building with JAVA_LIBS set to: $JAVA_LIBS])
 +fi
  if test "x$JAVAC" = "x"
  then
        with_javac_path="$PATH"
  SAVE_CPPFLAGS="$CPPFLAGS"
  SAVE_CFLAGS="$CFLAGS"
  SAVE_LDFLAGS="$LDFLAGS"
 +SAVE_LIBS="$LIBS"
  CPPFLAGS="$CPPFLAGS $JAVA_CPPFLAGS"
  CFLAGS="$CFLAGS $JAVA_CFLAGS"
  LDFLAGS="$LDFLAGS $JAVA_LDFLAGS"
 +LIBS="$LIBS $JAVA_LIBS"
  
  if test "x$with_java" = "xyes"
  then
@@@ -2461,8 -2381,8 +2461,8 @@@ if test "x$with_java" = "xyes
  then
        AC_CHECK_LIB(jvm, JNI_CreateJavaVM,
        [with_java="yes"],
 -      [with_java="no (libjvm not found)"],
 -      [$JAVA_LIBS])
 +      [with_java="no (Symbol 'JNI_CreateJavaVM' not found)"],
 +      [$JAVA_LIBS $PTHREAD_LIBS])
  fi
  if test "x$with_java" = "xyes"
  then
  CPPFLAGS="$SAVE_CPPFLAGS"
  CFLAGS="$SAVE_CFLAGS"
  LDFLAGS="$SAVE_LDFLAGS"
 +LIBS="$SAVE_LIBS"
  
  AC_SUBST(JAVA_CPPFLAGS)
  AC_SUBST(JAVA_CFLAGS)
@@@ -2545,25 -2464,17 +2545,25 @@@ with_liblvm2app_cppflags="
  with_liblvm2app_ldflags=""
  AC_ARG_WITH(liblvm2app, [AS_HELP_STRING([--with-liblvm2app@<:@=PREFIX@:>@], [Path to liblvm2app.])],
  [
 -        if test "x$withval" != "xno" && test "x$withval" != "xyes"
 -        then
 -                with_liblvm2app_cppflags="-I$withval/include"
 -                with_liblvm2app_ldflags="-L$withval/lib"
 -                with_liblvm2app="yes"
 -        else
 -                with_liblvm2app="$withval"
 +      if test "x$withval" = "xno"
 +      then
 +              with_liblvm2app="no"
 +      else
 +              with_liblvm2app="yes"
 +              if test "x$withval" != "xyes"
 +              then
 +                      with_liblvm2app_cppflags="-I$withval/include"
 +                      with_liblvm2app_ldflags="-L$withval/lib"
 +              fi
          fi
  ],
  [
 -        with_liblvm2app="yes"
 +      if test "x$ac_system" = "xLinux"
 +      then
 +              with_liblvm2app="yes"
 +      else
 +              with_liblvm2app="no (Linux only library)"
 +      fi
  ])
  if test "x$with_liblvm2app" = "xyes"
  then
  AM_CONDITIONAL(BUILD_WITH_LIBMONGOC, test "x$with_libmongoc" = "xyes")
  # }}}
  
 +# --with-libmosquitto {{{
 +with_libmosquitto_cppflags=""
 +with_libmosquitto_ldflags=""
 +AC_ARG_WITH(libmosquitto, [AS_HELP_STRING([--with-libmosquitto@<:@=PREFIX@:>@], [Path to libmosquitto.])],
 +[
 +      if test "x$withval" != "xno" && test "x$withval" != "xyes"
 +      then
 +              with_libmosquitto_cppflags="-I$withval/include"
 +              with_libmosquitto_ldflags="-L$withval/lib"
 +              with_libmosquitto="yes"
 +      else
 +              with_libmosquitto="$withval"
 +      fi
 +],
 +[
 +      with_libmosquitto="yes"
 +])
 +if test "x$with_libmosquitto" = "xyes"
 +then
 +      SAVE_CPPFLAGS="$CPPFLAGS"
 +      CPPFLAGS="$CPPFLAGS $with_libmosquitto_cppflags"
 +
 +      AC_CHECK_HEADERS(mosquitto.h, [with_libmosquitto="yes"], [with_libmosquitto="no (mosquitto.h not found)"])
 +
 +      CPPFLAGS="$SAVE_CPPFLAGS"
 +fi
 +if test "x$with_libmosquitto" = "xyes"
 +then
 +      SAVE_LDFLAGS="$LDFLAGS"
 +      SAVE_CPPFLAGS="$CPPFLAGS"
 +      LDFLAGS="$LDFLAGS $with_libmosquitto_ldflags"
 +      CPPFLAGS="$CPPFLAGS $with_libmosquitto_cppflags"
 +
 +      AC_CHECK_LIB(mosquitto, mosquitto_connect, [with_libmosquitto="yes"], [with_libmosquitto="no (libmosquitto not found)"])
 +
 +      LDFLAGS="$SAVE_LDFLAGS"
 +      CPPFLAGS="$SAVE_CPPFLAGS"
 +fi
 +if test "x$with_libmosquitto" = "xyes"
 +then
 +      BUILD_WITH_LIBMOSQUITTO_CPPFLAGS="$with_libmosquitto_cppflags"
 +      BUILD_WITH_LIBMOSQUITTO_LDFLAGS="$with_libmosquitto_ldflags"
 +      BUILD_WITH_LIBMOSQUITTO_LIBS="-lmosquitto"
 +      AC_SUBST(BUILD_WITH_LIBMOSQUITTO_CPPFLAGS)
 +      AC_SUBST(BUILD_WITH_LIBMOSQUITTO_LDFLAGS)
 +      AC_SUBST(BUILD_WITH_LIBMOSQUITTO_LIBS)
 +fi
 +# }}}
 +
  # --with-libmysql {{{
  with_mysql_config="mysql_config"
  with_mysql_cflags=""
@@@ -3107,7 -2969,7 +3107,7 @@@ the
  
        if test "x$LIBNETAPP_LIBS" = "x"
        then
 -              LIBNETAPP_LIBS="-lpthread -lxml -ladt -lssl -lm -lcrypto -lz"
 +              LIBNETAPP_LIBS="$PTHREAD_LIBS -lxml -ladt -lssl -lm -lcrypto -lz"
        fi
        AC_MSG_NOTICE([netapp LIBS: $LIBNETAPP_LIBS])
  
  
  # --with-libowcapi {{{
  with_libowcapi_cppflags=""
 -with_libowcapi_libs="-lowcapi"
 +with_libowcapi_ldflags=""
  AC_ARG_WITH(libowcapi, [AS_HELP_STRING([--with-libowcapi@<:@=PREFIX@:>@], [Path to libowcapi.])],
  [
        if test "x$withval" != "xno" && test "x$withval" != "xyes"
        then
                with_libowcapi_cppflags="-I$withval/include"
 -              with_libowcapi_libs="-L$withval/lib -lowcapi"
 +              with_libowcapi_ldflags="-L$withval/lib"
                with_libowcapi="yes"
        else
                with_libowcapi="$withval"
  if test "x$with_libowcapi" = "xyes"
  then
        SAVE_CPPFLAGS="$CPPFLAGS"
 -      CPPFLAGS="$with_libowcapi_cppflags"
 +      CPPFLAGS="$CPPFLAGS $with_libowcapi_cppflags"
  
        AC_CHECK_HEADERS(owcapi.h, [with_libowcapi="yes"], [with_libowcapi="no (owcapi.h not found)"])
  
@@@ -3403,7 -3265,7 +3403,7 @@@ if test "x$with_libowcapi" = "xyes
  then
        SAVE_LDFLAGS="$LDFLAGS"
        SAVE_CPPFLAGS="$CPPFLAGS"
 -      LDFLAGS="$with_libowcapi_libs"
 +      LDFLAGS="$LDFLAGS $with_libowcapi_ldflags"
        CPPFLAGS="$with_libowcapi_cppflags"
  
        AC_CHECK_LIB(owcapi, OW_get, [with_libowcapi="yes"], [with_libowcapi="no (libowcapi not found)"])
  if test "x$with_libowcapi" = "xyes"
  then
        BUILD_WITH_LIBOWCAPI_CPPFLAGS="$with_libowcapi_cppflags"
 -      BUILD_WITH_LIBOWCAPI_LIBS="$with_libowcapi_libs"
 +      BUILD_WITH_LIBOWCAPI_LDFLAGS="$with_libowcapi_ldflags"
 +      BUILD_WITH_LIBOWCAPI_LIBS="-lowcapi"
        AC_SUBST(BUILD_WITH_LIBOWCAPI_CPPFLAGS)
 +      AC_SUBST(BUILD_WITH_LIBOWCAPI_LDFLAGS)
        AC_SUBST(BUILD_WITH_LIBOWCAPI_LIBS)
  fi
  # }}}
  AM_CONDITIONAL(BUILD_WITH_LIBPQ, test "x$with_libpq" = "xyes")
  # }}}
  
 -# --with-libpthread {{{
 -AC_ARG_WITH(libpthread, [AS_HELP_STRING([--with-libpthread=@<:@=PREFIX@:>@], [Path to libpthread.])],
 -[     if test "x$withval" != "xno" \
 -              && test "x$withval" != "xyes"
 -      then
 -              LDFLAGS="$LDFLAGS -L$withval/lib"
 -              CPPFLAGS="$CPPFLAGS -I$withval/include"
 -              with_libpthread="yes"
 -      else
 -              if test "x$withval" = "xno"
 -              then
 -                      with_libpthread="no (disabled)"
 -              fi
 -      fi
 -], [with_libpthread="yes"])
 -if test "x$with_libpthread" = "xyes"
 -then
 -      AC_CHECK_LIB(pthread, pthread_create, [with_libpthread="yes"], [with_libpthread="no (libpthread not found)"], [])
 -fi
 -
 -if test "x$with_libpthread" = "xyes"
 -then
 -      AC_CHECK_HEADERS(pthread.h,, [with_libpthread="no (pthread.h not found)"])
 -fi
 -if test "x$with_libpthread" = "xyes"
 -then
 -      collect_pthread=1
 -else
 -      collect_pthread=0
 -fi
 -AC_DEFINE_UNQUOTED(HAVE_LIBPTHREAD, [$collect_pthread],
 -      [Wether or not to use pthread (POSIX threads) library])
 -AM_CONDITIONAL(BUILD_WITH_LIBPTHREAD, test "x$with_libpthread" = "xyes")
 -# }}}
 -
  # --with-python {{{
  with_python_prog=""
  with_python_path="$PATH"
@@@ -4218,6 -4113,11 +4218,6 @@@ the
        SAVE_CPPFLAGS="$CPPFLAGS"
        CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
  
 -#     AC_CHECK_HEADERS(sensors/sensors.h,
 -#     [
 -#             AC_DEFINE(HAVE_SENSORS_SENSORS_H, 1, [Define to 1 if you have the <sensors/sensors.h> header file.])
 -#     ],
 -#     [with_libsensors="no (sensors/sensors.h not found)"])
        AC_CHECK_HEADERS(sensors/sensors.h, [], [with_libsensors="no (sensors/sensors.h not found)"])
  
        CPPFLAGS="$SAVE_CPPFLAGS"
  if test "x$with_libstatgrab" = "xyes"
  then
    SAVE_CFLAGS="$CFLAGS"
 +  SAVE_LDFLAGS="$LDFLAGS"
    SAVE_LIBS="$LIBS"
  
    CFLAGS="$CFLAGS $with_libstatgrab_cflags"
@@@ -4596,8 -4495,10 +4596,10 @@@ if test "x$with_libudev" = "xyes
  then
        BUILD_WITH_LIBUDEV_CFLAGS="$with_libudev_cflags"
        BUILD_WITH_LIBUDEV_LDFLAGS="$with_libudev_ldflags"
+       BUILD_WITH_LIBUDEV_LIBS="-ludev"
        AC_SUBST(BUILD_WITH_LIBUDEV_CFLAGS)
        AC_SUBST(BUILD_WITH_LIBUDEV_LDFLAGS)
+       AC_SUBST(BUILD_WITH_LIBUDEV_LIBS)
  fi
  AM_CONDITIONAL(BUILD_WITH_LIBUDEV, test "x$with_libudev" = "xyes")
  # }}}
  fi
  # }}}
  
 +# --with-libxenctrl {{{
 +with_libxenctrl_cppflags=""
 +with_libxenctrl_ldflags=""
 +AC_ARG_WITH(libxenctrl, [AS_HELP_STRING([--with-libxenctrl@<:@=PREFIX@:>@], [Path to libxenctrl.])],
 +[
 +      if test "x$withval" != "xno" && test "x$withval" != "xyes"
 +      then
 +              with_libxenctrl_cppflags="-I$withval/include"
 +              with_libxenctrl_ldflags="-L$withval/lib"
 +              with_libxenctrl="yes"
 +      else
 +              with_libxenctrl="$withval"
 +      fi
 +],
 +[
 +      with_libxenctrl="yes"
 +])
 +if test "x$with_libxenctrl" = "xyes"
 +then
 +      SAVE_CPPFLAGS="$CPPFLAGS"
 +      CPPFLAGS="$CPPFLAGS $with_libxenctrl_cppflags"
 +
 +      AC_CHECK_HEADERS(xenctrl.h, [with_libxenctrl="yes"], [with_libxenctrl="no (xenctrl.h not found)"])
 +
 +      CPPFLAGS="$SAVE_CPPFLAGS"
 +fi
 +if test "x$with_libxenctrl" = "xyes"
 +then
 +      SAVE_CPPFLAGS="$CPPFLAGS"
 +      SAVE_LDFLAGS="$LDFLAGS"
 +      CPPFLAGS="$CPPFLAGS $with_libxenctrl_cppflags"
 +      LDFLAGS="$LDFLAGS $with_libxenctrl_ldflags"
 +
 +      #Xen versions older than 3.4 has no xc_getcpuinfo()
 +      AC_CHECK_LIB(xenctrl, xc_getcpuinfo, [with_libxenctrl="yes"], [with_libxenctrl="no (symbol 'xc_getcpuinfo' not found)"], [])
 +
 +      CPPFLAGS="$SAVE_CPPFLAGS"
 +      LDFLAGS="$SAVE_LDFLAGS"
 +fi
 +
  # --with-libxmms {{{
  with_xmms_config="xmms-config"
  with_xmms_cflags=""
@@@ -4914,7 -4775,7 +4916,7 @@@ AC_ARG_WITH(mic,[AS_HELP_STRING([--with
                AC_MSG_NOTICE([Not checking for Intel Mic: Manually configured])
                with_mic_cflags="-I$withval/include"
                with_mic_ldpath="-L$withval/lib/Linux"
 -              with_mic_libs="-lMicAccessSDK -lscif -lpthread"
 +              with_mic_libs="$PTHREAD_LIBS -lMicAccessSDK -lscif"
                with_mic="yes"
        fi; fi; fi
  ],
@@@ -4936,8 -4797,8 +4938,8 @@@ the
  
        AC_CHECK_LIB(MicAccessSDK, MicInitAPI,
                        [with_mic_ldpath="$with_mic_ldpath"
 -                      with_mic_libs="-lMicAccessSDK -lscif -lpthread"],
 -                      [with_mic="no (symbol MicInitAPI not found)"],[-lscif -lpthread])
 +                      with_mic_libs="$PTHREAD_LIBS -lMicAccessSDK -lscif"],
 +                      [with_mic="no (symbol MicInitAPI not found)"],[$PTHREAD_LIBS -lscif])
  
        CPPFLAGS="$SAVE_CPPFLAGS"
        LDFLAGS="$SAVE_LDFLAGS"
@@@ -5294,12 -5155,11 +5296,12 @@@ AM_CONDITIONAL(BUILD_WITH_LIBATASMART, 
  
  PKG_CHECK_MODULES([LIBNOTIFY], [libnotify],
                [with_libnotify="yes"],
 -              [if test "x$LIBNOTIFY_PKG_ERRORS" = "x"; then
 -                       with_libnotify="no"
 -               else
 -                       with_libnotify="no ($LIBNOTIFY_PKG_ERRORS)"
 -               fi])
 +              [with_libnotify="no (pkg-config doesn't know libnotify)"]
 +)
 +
 +PKG_CHECK_MODULES([LIBRIEMANN_CLIENT], [riemann-client >= 1.8.0],
 + [with_libriemann_client="yes"],
 + [with_libriemann_client="no (pkg-config doesn't know libriemann-client)"])
  
  # Check for enabled/disabled features
  #
@@@ -5423,7 -5283,6 +5425,7 @@@ collectd features:]
  AC_COLLECTD([debug],     [enable],  [feature], [debugging])
  AC_COLLECTD([daemon],    [disable], [feature], [daemon mode])
  AC_COLLECTD([getifaddrs],[enable],  [feature], [getifaddrs under Linux])
 +AC_COLLECTD([werror],    [disable], [feature], [building with -Werror])
  
  dependency_warning="no"
  dependency_error="no"
@@@ -5461,6 -5320,7 +5463,7 @@@ plugin_perl="no
  plugin_processes="no"
  plugin_protocols="no"
  plugin_serial="no"
+ plugin_smart="no"
  plugin_swap="no"
  plugin_tape="no"
  plugin_tcpconns="no"
@@@ -5473,18 -5333,16 +5476,18 @@@ plugin_virt="no
  plugin_vmem="no"
  plugin_vserver="no"
  plugin_wireless="no"
 +plugin_xencpu="no"
  plugin_zfs_arc="no"
 +plugin_zone="no"
  plugin_zookeeper="no"
  
  # Linux
  if test "x$ac_system" = "xLinux"
  then
        plugin_battery="yes"
 +      plugin_cgroups="yes"
        plugin_conntrack="yes"
        plugin_contextswitch="yes"
 -      plugin_cgroups="yes"
        plugin_cpu="yes"
        plugin_cpufreq="yes"
        plugin_disk="yes"
        plugin_tcpconns="yes"
  fi
  
 +if test "x$ac_system" = "xNetBSD"
 +then
 +      plugin_disk="yes"
 +      plugin_entropy="yes"
 +      plugin_irq="yes"
 +      plugin_processes="yes"
 +fi
 +
  # Mac OS X devices
  if test "x$with_libiokit" = "xyes"
  then
  
  if test "x$ac_system" = "xAIX"
  then
 -      plugin_tcpconns="yes"
        plugin_ipc="yes"
 +      plugin_tcpconns="yes"
  fi
  
  # FreeBSD
  
  if test "x$ac_system" = "xFreeBSD"
  then
 +      plugin_disk="yes"
        plugin_zfs_arc="yes"
  fi
  
  
  if test "x$with_perfstat" = "xyes"
  then
 -      plugin_cpu="yes"
        plugin_contextswitch="yes"
 +      plugin_cpu="yes"
        plugin_disk="yes"
 -      plugin_memory="yes"
 -      plugin_swap="yes"
        plugin_interface="yes"
        plugin_load="yes"
 +      plugin_memory="yes"
 +      plugin_swap="yes"
        plugin_uptime="yes"
  fi
  
@@@ -5583,7 -5432,6 +5586,7 @@@ the
        plugin_processes="yes"
        plugin_uptime="yes"
        plugin_zfs_arc="yes"
 +      plugin_zone="yes"
  fi
  
  if test "x$with_devinfo$with_kstat" = "xyesyes"
@@@ -5596,6 -5444,7 +5599,6 @@@ the
  fi
  
  # libi2c-dev
 -with_libi2c="no"
  if test "x$ac_system" = "xLinux"
  then
  AC_CHECK_DECL(i2c_smbus_read_i2c_block_data,
        [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>]])
 +else
 +      with_libi2c="no (Linux only)"
  fi
  
  if test "x$with_libi2c" = "xyes"
        plugin_processes="yes"
  fi
  
+ if test "x$with_libatasmart" = "xyes" && test "x$with_libudev" = "xyes"
+ then
+       plugin_smart="yes"
+ fi
  if test "x$with_kvm_getswapinfo" = "xyes"
  then
        plugin_swap="yes"
        plugin_swap="yes"
  fi
  
 +if test "x$have_swapctl" = "xyes" && test "x$c_cv_have_swapctl_three_args" = "xyes"
 +then
 +      plugin_swap="yes"
 +fi
 +
  if test "x$with_kvm_openfiles$with_kvm_nlist" = "xyesyes"
  then
        plugin_tcpconns="yes"
        plugin_virt="yes"
  fi
  
 +if test "x$with_libxenctrl" = "xyes"
 +then
 +  plugin_xencpu="yes"
 +fi
  
  m4_divert_once([HELP_ENABLE], [
  collectd plugins:])
@@@ -5830,145 -5673,141 +5838,145 @@@ AC_ARG_ENABLE([all-plugins]
  
  m4_divert_once([HELP_ENABLE], [])
  
 -AC_PLUGIN([aggregation], [yes],                [Aggregation plugin])
 -AC_PLUGIN([amqp],        [$with_librabbitmq],  [AMQP output plugin])
 -AC_PLUGIN([apache],      [$with_libcurl],      [Apache httpd statistics])
 -AC_PLUGIN([apcups],      [yes],                [Statistics of UPSes by APC])
 -AC_PLUGIN([apple_sensors], [$with_libiokit],   [Apple's hardware sensors])
 -AC_PLUGIN([aquaero],     [$with_libaquaero5],  [Aquaero's hardware sensors])
 -AC_PLUGIN([ascent],      [$plugin_ascent],     [AscentEmu player statistics])
 -AC_PLUGIN([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])
 -AC_PLUGIN([cpu],         [$plugin_cpu],        [CPU usage statistics])
 -AC_PLUGIN([csv],         [yes],                [CSV output plugin])
 -AC_PLUGIN([curl],        [$with_libcurl],      [CURL generic web statistics])
 -AC_PLUGIN([curl_json],   [$plugin_curl_json],    [CouchDB statistics])
 -AC_PLUGIN([curl_xml],   [$plugin_curl_xml],    [CURL generic xml statistics])
 -AC_PLUGIN([cgroups],     [$plugin_cgroups],    [CGroups CPU usage accounting])
 -AC_PLUGIN([dbi],         [$with_libdbi],       [General database statistics])
 -AC_PLUGIN([df],          [$plugin_df],         [Filesystem usage statistics])
 -AC_PLUGIN([disk],        [$plugin_disk],       [Disk usage statistics])
 -AC_PLUGIN([drbd],        [$plugin_drbd],       [DRBD statistics])
 -AC_PLUGIN([dns],         [$with_libpcap],      [DNS traffic analysis])
 -AC_PLUGIN([email],       [yes],                [EMail statistics])
 -AC_PLUGIN([entropy],     [$plugin_entropy],    [Entropy statistics])
 -AC_PLUGIN([ethstat],     [$plugin_ethstat],    [Stats from NIC driver])
 -AC_PLUGIN([exec],        [yes],                [Execution of external programs])
 -AC_PLUGIN([fhcount],     [$plugin_fhcount],    [File handles statistics])
 -AC_PLUGIN([filecount],   [yes],                [Count files in directories])
 -AC_PLUGIN([fscache],     [$plugin_fscache],    [fscache statistics])
 -AC_PLUGIN([gmond],       [$with_libganglia],   [Ganglia plugin])
 -AC_PLUGIN([hddtemp],     [yes],                [Query hddtempd])
 -AC_PLUGIN([interface],   [$plugin_interface],  [Interface traffic statistics])
 -AC_PLUGIN([ipc],         [$plugin_ipc],        [IPC statistics])
 -AC_PLUGIN([ipmi],        [$plugin_ipmi],       [IPMI sensor statistics])
 -AC_PLUGIN([iptables],    [$with_libiptc],      [IPTables rule counters])
 -AC_PLUGIN([ipvs],        [$plugin_ipvs],       [IPVS connection statistics])
 -AC_PLUGIN([irq],         [$plugin_irq],        [IRQ statistics])
 -AC_PLUGIN([java],        [$with_java],         [Embed the Java Virtual Machine])
 -AC_PLUGIN([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])
 -AC_PLUGIN([match_empty_counter], [yes],        [The empty counter match])
 -AC_PLUGIN([match_hashed], [yes],               [The hashed match])
 -AC_PLUGIN([match_regex], [yes],                [The regex match])
 -AC_PLUGIN([match_timediff], [yes],             [The timediff match])
 -AC_PLUGIN([match_value], [yes],                [The value match])
 -AC_PLUGIN([mbmon],       [yes],                [Query mbmond])
 -AC_PLUGIN([md],          [$have_linux_raid_md_u_h], [md (Linux software RAID) devices])
 -AC_PLUGIN([memcachec],   [$with_libmemcached], [memcachec statistics])
 -AC_PLUGIN([memcached],   [yes],                [memcached statistics])
 -AC_PLUGIN([memory],      [$plugin_memory],     [Memory usage])
 -AC_PLUGIN([mic],         [$with_mic],          [Intel Many Integrated Core stats])
 -AC_PLUGIN([modbus],      [$with_libmodbus],    [Modbus plugin])
 -AC_PLUGIN([multimeter],  [$plugin_multimeter], [Read multimeter values])
 -AC_PLUGIN([mysql],       [$with_libmysql],     [MySQL statistics])
 -AC_PLUGIN([netapp],      [$with_libnetapp],    [NetApp plugin])
 -AC_PLUGIN([netlink],     [$with_libmnl],       [Enhanced Linux network statistics])
 -AC_PLUGIN([network],     [yes],                [Network communication plugin])
 -AC_PLUGIN([nfs],         [$plugin_nfs],        [NFS statistics])
 -AC_PLUGIN([nginx],       [$with_libcurl],      [nginx statistics])
 -AC_PLUGIN([notify_desktop], [$with_libnotify], [Desktop notifications])
 -AC_PLUGIN([notify_email], [$with_libesmtp],    [Email notifier])
 -AC_PLUGIN([ntpd],        [yes],                [NTPd statistics])
 -AC_PLUGIN([numa],        [$plugin_numa],       [NUMA virtual memory statistics])
 -AC_PLUGIN([nut],         [$with_libupsclient], [Network UPS tools statistics])
 -AC_PLUGIN([olsrd],       [yes],                [olsrd statistics])
 -AC_PLUGIN([onewire],     [$with_libowcapi],    [OneWire sensor statistics])
 -AC_PLUGIN([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])
 -AC_PLUGIN([pf],          [$have_net_pfvar_h],  [BSD packet filter (PF) statistics])
 +AC_PLUGIN([aggregation],         [yes],                     [Aggregation plugin])
 +AC_PLUGIN([amqp],                [$with_librabbitmq],       [AMQP output plugin])
 +AC_PLUGIN([apache],              [$with_libcurl],           [Apache httpd statistics])
 +AC_PLUGIN([apcups],              [yes],                     [Statistics of UPSes by APC])
 +AC_PLUGIN([apple_sensors],       [$with_libiokit],          [Apple hardware sensors])
 +AC_PLUGIN([aquaero],             [$with_libaquaero5],       [Aquaero 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([cgroups],             [$plugin_cgroups],         [CGroups CPU usage accounting])
 +AC_PLUGIN([conntrack],           [$plugin_conntrack],       [nf_conntrack statistics])
 +AC_PLUGIN([contextswitch],       [$plugin_contextswitch],   [context switch statistics])
 +AC_PLUGIN([cpu],                 [$plugin_cpu],             [CPU usage statistics])
 +AC_PLUGIN([cpufreq],             [$plugin_cpufreq],         [CPU frequency statistics])
 +AC_PLUGIN([csv],                 [yes],                     [CSV output plugin])
 +AC_PLUGIN([curl],                [$with_libcurl],           [CURL generic web statistics])
 +AC_PLUGIN([curl_json],           [$plugin_curl_json],       [CouchDB statistics])
 +AC_PLUGIN([curl_xml],            [$plugin_curl_xml],        [CURL generic xml statistics])
 +AC_PLUGIN([dbi],                 [$with_libdbi],            [General database statistics])
 +AC_PLUGIN([df],                  [$plugin_df],              [Filesystem usage statistics])
 +AC_PLUGIN([disk],                [$plugin_disk],            [Disk usage statistics])
 +AC_PLUGIN([dns],                 [$with_libpcap],           [DNS traffic analysis])
 +AC_PLUGIN([drbd],                [$plugin_drbd],            [DRBD statistics])
 +AC_PLUGIN([email],               [yes],                     [EMail statistics])
 +AC_PLUGIN([entropy],             [$plugin_entropy],         [Entropy statistics])
 +AC_PLUGIN([ethstat],             [$plugin_ethstat],         [Stats from NIC driver])
 +AC_PLUGIN([exec],                [yes],                     [Execution of external programs])
 +AC_PLUGIN([fhcount],             [$plugin_fhcount],         [File handles statistics])
 +AC_PLUGIN([filecount],           [yes],                     [Count files in directories])
 +AC_PLUGIN([fscache],             [$plugin_fscache],         [fscache statistics])
 +AC_PLUGIN([gmond],               [$with_libganglia],        [Ganglia plugin])
 +AC_PLUGIN([hddtemp],             [yes],                     [Query hddtempd])
 +AC_PLUGIN([interface],           [$plugin_interface],       [Interface traffic statistics])
 +AC_PLUGIN([ipc],                 [$plugin_ipc],             [IPC statistics])
 +AC_PLUGIN([ipmi],                [$plugin_ipmi],            [IPMI sensor statistics])
 +AC_PLUGIN([iptables],            [$with_libiptc],           [IPTables rule counters])
 +AC_PLUGIN([ipvs],                [$plugin_ipvs],            [IPVS connection statistics])
 +AC_PLUGIN([irq],                 [$plugin_irq],             [IRQ statistics])
 +AC_PLUGIN([java],                [$with_java],              [Embed the Java Virtual Machine])
 +AC_PLUGIN([load],                [$plugin_load],            [System load])
 +AC_PLUGIN([log_logstash],        [$plugin_log_logstash],    [Logstash json_event compatible logging])
 +AC_PLUGIN([logfile],             [yes],                     [File logging plugin])
 +AC_PLUGIN([lpar],                [$with_perfstat],          [AIX logical partitions statistics])
 +AC_PLUGIN([lvm],                 [$with_liblvm2app],        [LVM statistics])
 +AC_PLUGIN([madwifi],             [$have_linux_wireless_h],  [Madwifi wireless statistics])
 +AC_PLUGIN([match_empty_counter], [yes],                     [The empty counter match])
 +AC_PLUGIN([match_hashed],        [yes],                     [The hashed match])
 +AC_PLUGIN([match_regex],         [yes],                     [The regex match])
 +AC_PLUGIN([match_timediff],      [yes],                     [The timediff match])
 +AC_PLUGIN([match_value],         [yes],                     [The value match])
 +AC_PLUGIN([mbmon],               [yes],                     [Query mbmond])
 +AC_PLUGIN([md],                  [$have_linux_raid_md_u_h], [md (Linux software RAID) devices])
 +AC_PLUGIN([memcachec],           [$with_libmemcached],      [memcachec statistics])
 +AC_PLUGIN([memcached],           [yes],                     [memcached statistics])
 +AC_PLUGIN([memory],              [$plugin_memory],          [Memory usage])
 +AC_PLUGIN([mic],                 [$with_mic],               [Intel Many Integrated Core stats])
 +AC_PLUGIN([modbus],              [$with_libmodbus],         [Modbus plugin])
 +AC_PLUGIN([mqtt],                [$with_libmosquitto],      [MQTT output plugin])
 +AC_PLUGIN([multimeter],          [$plugin_multimeter],      [Read multimeter values])
 +AC_PLUGIN([mysql],               [$with_libmysql],          [MySQL statistics])
 +AC_PLUGIN([netapp],              [$with_libnetapp],         [NetApp plugin])
 +AC_PLUGIN([netlink],             [$with_libmnl],            [Enhanced Linux network statistics])
 +AC_PLUGIN([network],             [yes],                     [Network communication plugin])
 +AC_PLUGIN([nfs],                 [$plugin_nfs],             [NFS statistics])
 +AC_PLUGIN([nginx],               [$with_libcurl],           [nginx statistics])
 +AC_PLUGIN([notify_desktop],      [$with_libnotify],         [Desktop notifications])
 +AC_PLUGIN([notify_email],        [$with_libesmtp],          [Email notifier])
 +AC_PLUGIN([notify_nagios],       [yes],                     [Nagios notification plugin])
 +AC_PLUGIN([ntpd],                [yes],                     [NTPd statistics])
 +AC_PLUGIN([numa],                [$plugin_numa],            [NUMA virtual memory statistics])
 +AC_PLUGIN([nut],                 [$with_libupsclient],      [Network UPS tools statistics])
 +AC_PLUGIN([olsrd],               [yes],                     [olsrd statistics])
 +AC_PLUGIN([onewire],             [$with_libowcapi],         [OneWire sensor statistics])
 +AC_PLUGIN([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])
 +AC_PLUGIN([pf],                  [$have_net_pfvar_h],       [BSD packet filter (PF) statistics])
  # FIXME: Check for libevent, too.
 -AC_PLUGIN([pinba],       [$have_protoc_c],     [Pinba statistics])
 -AC_PLUGIN([ping],        [$with_liboping],     [Network latency statistics])
 -AC_PLUGIN([postgresql],  [$with_libpq],        [PostgreSQL database statistics])
 -AC_PLUGIN([powerdns],    [yes],                [PowerDNS statistics])
 -AC_PLUGIN([processes],   [$plugin_processes],  [Process statistics])
 -AC_PLUGIN([protocols],   [$plugin_protocols],  [Protocol (IP, TCP, ...) statistics])
 -AC_PLUGIN([python],      [$with_python],       [Embed a Python interpreter])
 -AC_PLUGIN([redis],       [$with_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],       [$plugin_smart],      [SMART statistics])
 -AC_PLUGIN([snmp],        [$with_libnetsnmp],   [SNMP querying plugin])
 -AC_PLUGIN([statsd],      [yes],                [StatsD plugin])
 -AC_PLUGIN([swap],        [$plugin_swap],       [Swap usage statistics])
 -AC_PLUGIN([syslog],      [$have_syslog],       [Syslog logging plugin])
 -AC_PLUGIN([table],       [yes],                [Parsing of tabular data])
 -AC_PLUGIN([tail],        [yes],                [Parsing of logfiles])
 -AC_PLUGIN([tail_csv],    [yes],                [Parsing of CSV files])
 -AC_PLUGIN([tape],        [$plugin_tape],       [Tape drive statistics])
 -AC_PLUGIN([target_notification], [yes],        [The notification target])
 -AC_PLUGIN([target_replace], [yes],             [The replace target])
 -AC_PLUGIN([target_scale],[yes],                [The scale target])
 -AC_PLUGIN([target_set],  [yes],                [The set target])
 -AC_PLUGIN([target_v5upgrade], [yes],           [The v5upgrade target])
 -AC_PLUGIN([tcpconns],    [$plugin_tcpconns],   [TCP connection statistics])
 -AC_PLUGIN([teamspeak2],  [yes],                [TeamSpeak2 server statistics])
 -AC_PLUGIN([ted],         [$plugin_ted],        [Read The Energy Detective values])
 -AC_PLUGIN([thermal],     [$plugin_thermal],    [Linux ACPI thermal zone statistics])
 -AC_PLUGIN([threshold],   [yes],                [Threshold checking plugin])
 -AC_PLUGIN([tokyotyrant], [$with_libtokyotyrant],  [TokyoTyrant database statistics])
 -AC_PLUGIN([turbostat],   [$plugin_turbostat],  [Advanced statistic on Intel cpu states])
 -AC_PLUGIN([unixsock],    [yes],                [Unixsock communication plugin])
 -AC_PLUGIN([uptime],      [$plugin_uptime],     [Uptime statistics])
 -AC_PLUGIN([users],       [$plugin_users],      [User statistics])
 -AC_PLUGIN([uuid],        [yes],                [UUID as hostname plugin])
 -AC_PLUGIN([varnish],     [$with_libvarnish],   [Varnish cache statistics])
 -AC_PLUGIN([virt],        [$plugin_virt],       [Virtual machine statistics])
 -AC_PLUGIN([vmem],        [$plugin_vmem],       [Virtual memory statistics])
 -AC_PLUGIN([vserver],     [$plugin_vserver],    [Linux VServer statistics])
 -AC_PLUGIN([wireless],    [$plugin_wireless],   [Wireless statistics])
 -AC_PLUGIN([write_graphite], [yes],             [Graphite / Carbon output plugin])
 -AC_PLUGIN([write_http],  [$with_libcurl],      [HTTP output plugin])
 -AC_PLUGIN([write_kafka],  [$with_librdkafka],  [Kafka output plugin])
 -AC_PLUGIN([write_log], [yes],                  [Log output plugin])
 -AC_PLUGIN([write_mongodb], [$with_libmongoc],  [MongoDB output plugin])
 -AC_PLUGIN([write_redis], [$with_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])
 +AC_PLUGIN([pinba],               [$have_protoc_c],          [Pinba statistics])
 +AC_PLUGIN([ping],                [$with_liboping],          [Network latency statistics])
 +AC_PLUGIN([postgresql],          [$with_libpq],             [PostgreSQL database statistics])
 +AC_PLUGIN([powerdns],            [yes],                     [PowerDNS statistics])
 +AC_PLUGIN([processes],           [$plugin_processes],       [Process statistics])
 +AC_PLUGIN([protocols],           [$plugin_protocols],       [Protocol (IP, TCP, ...) statistics])
 +AC_PLUGIN([python],              [$with_python],            [Embed a Python interpreter])
 +AC_PLUGIN([redis],               [$with_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([smart],               [$plugin_smart],           [SMART statistics])
 +AC_PLUGIN([snmp],                [$with_libnetsnmp],        [SNMP querying plugin])
 +AC_PLUGIN([statsd],              [yes],                     [StatsD plugin])
 +AC_PLUGIN([swap],                [$plugin_swap],            [Swap usage statistics])
 +AC_PLUGIN([syslog],              [$have_syslog],            [Syslog logging plugin])
 +AC_PLUGIN([table],               [yes],                     [Parsing of tabular data])
 +AC_PLUGIN([tail],                [yes],                     [Parsing of logfiles])
 +AC_PLUGIN([tail_csv],            [yes],                     [Parsing of CSV files])
 +AC_PLUGIN([tape],                [$plugin_tape],            [Tape drive statistics])
 +AC_PLUGIN([target_notification], [yes],                     [The notification target])
 +AC_PLUGIN([target_replace],      [yes],                     [The replace target])
 +AC_PLUGIN([target_scale],        [yes],                     [The scale target])
 +AC_PLUGIN([target_set],          [yes],                     [The set target])
 +AC_PLUGIN([target_v5upgrade],    [yes],                     [The v5upgrade target])
 +AC_PLUGIN([tcpconns],            [$plugin_tcpconns],        [TCP connection statistics])
 +AC_PLUGIN([teamspeak2],          [yes],                     [TeamSpeak2 server statistics])
 +AC_PLUGIN([ted],                 [$plugin_ted],             [Read The Energy Detective values])
 +AC_PLUGIN([thermal],             [$plugin_thermal],         [Linux ACPI thermal zone statistics])
 +AC_PLUGIN([threshold],           [yes],                     [Threshold checking plugin])
 +AC_PLUGIN([tokyotyrant],         [$with_libtokyotyrant],    [TokyoTyrant database statistics])
 +AC_PLUGIN([turbostat],           [$plugin_turbostat],       [Advanced statistic on Intel cpu states])
 +AC_PLUGIN([unixsock],            [yes],                     [Unixsock communication plugin])
 +AC_PLUGIN([uptime],              [$plugin_uptime],          [Uptime statistics])
 +AC_PLUGIN([users],               [$plugin_users],           [User statistics])
 +AC_PLUGIN([uuid],                [yes],                     [UUID as hostname plugin])
 +AC_PLUGIN([varnish],             [$with_libvarnish],        [Varnish cache statistics])
 +AC_PLUGIN([virt],                [$plugin_virt],            [Virtual machine statistics])
 +AC_PLUGIN([vmem],                [$plugin_vmem],            [Virtual memory statistics])
 +AC_PLUGIN([vserver],             [$plugin_vserver],         [Linux VServer statistics])
 +AC_PLUGIN([wireless],            [$plugin_wireless],        [Wireless statistics])
 +AC_PLUGIN([write_graphite],      [yes],                     [Graphite / Carbon output plugin])
 +AC_PLUGIN([write_http],          [$with_libcurl],           [HTTP output plugin])
 +AC_PLUGIN([write_kafka],         [$with_librdkafka],        [Kafka output plugin])
 +AC_PLUGIN([write_log],           [yes],                     [Log output plugin])
 +AC_PLUGIN([write_mongodb],       [$with_libmongoc],         [MongoDB output plugin])
 +AC_PLUGIN([write_redis],         [$with_libhiredis],        [Redis output plugin])
 +AC_PLUGIN([write_riemann],       [$with_libriemann_client], [Riemann output plugin])
 +AC_PLUGIN([write_sensu],         [yes],                     [Sensu output plugin])
 +AC_PLUGIN([write_tsdb],          [yes],                     [TSDB output plugin])
 +AC_PLUGIN([xencpu],              [$plugin_xencpu],          [Xen Host CPU usage])
 +AC_PLUGIN([xmms],                [$with_libxmms],           [XMMS statistics])
 +AC_PLUGIN([zfs_arc],             [$plugin_zfs_arc],         [ZFS ARC statistics])
 +AC_PLUGIN([zone],                [$plugin_zone],            [Solaris container statistics])
 +AC_PLUGIN([zookeeper],           [yes],                     [Zookeeper statistics])
  
  dnl Default configuration file
  # Load either syslog or logfile
@@@ -6119,13 -5958,6 +6127,13 @@@ AC_SUBST(LCC_VERSION_STRING
  
  AC_CONFIG_FILES(src/libcollectdclient/collectd/lcc_features.h)
  
 +AM_CFLAGS="-Wall"
 +if test "x$enable_werror" != "xno"
 +then
 +        AM_CFLAGS="$AM_CFLAGS -Werror"
 +fi
 +AC_SUBST([AM_CFLAGS])
 +
  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
  
  cat <<EOF;
  
  Configuration:
 +  Build:
 +    Platform  . . . . . . $ac_system
 +    CC  . . . . . . . . . $CC
 +    CFLAGS  . . . . . . . $AM_CFLAGS $CFLAGS
 +    CPP . . . . . . . . . $CPP
 +    CPPFLAGS  . . . . . . $CPPFLAGS
 +    LD  . . . . . . . . . $LD
 +    LDFLAGS . . . . . . . $LDFLAGS
 +    YACC  . . . . . . . . $YACC
 +    YFLAGS  . . . . . . . $YFLAGS
 +
    Libraries:
      intel mic . . . . . . $with_mic
      libaquaero5 . . . . . $with_libaquaero5
      libmnl  . . . . . . . $with_libmnl
      libmodbus . . . . . . $with_libmodbus
      libmongoc . . . . . . $with_libmongoc
 +    libmosquitto  . . . . $with_libmosquitto
      libmysql  . . . . . . $with_libmysql
      libnetapp . . . . . . $with_libnetapp
      libnetsnmp  . . . . . $with_libnetsnmp
      libpq . . . . . . . . $with_libpq
      libpthread  . . . . . $with_libpthread
      librabbitmq . . . . . $with_librabbitmq
 +    libriemann-client . . $with_libriemann_client
      librdkafka  . . . . . $with_librdkafka
      librouteros . . . . . $with_librouteros
      librrd  . . . . . . . $with_librrd
      libupsclient  . . . . $with_libupsclient
      libvarnish  . . . . . $with_libvarnish
      libvirt . . . . . . . $with_libvirt
 +    libxenctrl  . . . . . $with_libxenctrl
      libxml2 . . . . . . . $with_libxml2
      libxmms . . . . . . . $with_libxmms
      libyajl . . . . . . . $with_libyajl
      memory  . . . . . . . $enable_memory
      mic . . . . . . . . . $enable_mic
      modbus  . . . . . . . $enable_modbus
 +    mqtt  . . . . . . . . $enable_mqtt
      multimeter  . . . . . $enable_multimeter
      mysql . . . . . . . . $enable_mysql
      netapp  . . . . . . . $enable_netapp
      nginx . . . . . . . . $enable_nginx
      notify_desktop  . . . $enable_notify_desktop
      notify_email  . . . . $enable_notify_email
 +    notify_nagios . . . . $enable_notify_nagios
      ntpd  . . . . . . . . $enable_ntpd
      numa  . . . . . . . . $enable_numa
      nut . . . . . . . . . $enable_nut
      write_riemann . . . . $enable_write_riemann
      write_sensu . . . . . $enable_write_sensu
      write_tsdb  . . . . . $enable_write_tsdb
 +    xencpu  . . . . . . . $enable_xencpu
      xmms  . . . . . . . . $enable_xmms
      zfs_arc . . . . . . . $enable_zfs_arc
 +    zone  . . . . . . . . $enable_zone
      zookeeper . . . . . . $enable_zookeeper
  
  EOF
diff --combined src/Makefile.am
@@@ -6,6 -6,10 +6,6 @@@ SUBDIRS += daemo
  
  PLUGIN_LDFLAGS = -module -avoid-version -export-symbols-regex '\<module_register\>'
  
 -if COMPILER_IS_GCC
 -AM_CFLAGS = -Wall -Werror
 -endif
 -
  AM_CPPFLAGS = -I$(srcdir)/daemon
  AM_CPPFLAGS += -DPREFIX='"${prefix}"'
  AM_CPPFLAGS += -DCONFIGFILE='"${sysconfdir}/${PACKAGE_NAME}.conf"'
@@@ -19,37 -23,13 +19,37 @@@ AM_CPPFLAGS += -DPKGDATADIR='"${pkgdata
  
  AUTOMAKE_OPTIONS = subdir-objects
  
 -noinst_LTLIBRARIES = libmount.la liblookup.la
 +noinst_LTLIBRARIES =
 +check_PROGRAMS =
 +TESTS =
  
 -libmount_la_SOURCES = utils_mount.c utils_mount.h
 -libmount_la_LIBADD = daemon/libcommon.la
 +noinst_LTLIBRARIES += liblatency.la
 +liblatency_la_SOURCES = utils_latency.c utils_latency.h
 +check_PROGRAMS += test_utils_latency
 +TESTS += test_utils_latency
 +test_utils_latency_SOURCES = utils_latency_test.c testing.h
 +test_utils_latency_LDADD = liblatency.la daemon/libplugin_mock.la -lm
  
 +noinst_LTLIBRARIES += liblookup.la
  liblookup_la_SOURCES = utils_vl_lookup.c utils_vl_lookup.h
 -liblookup_la_LIBADD = daemon/libavltree.la daemon/libcommon.la
 +liblookup_la_LIBADD = daemon/libavltree.la
 +check_PROGRAMS += test_utils_vl_lookup
 +TESTS += test_utils_vl_lookup
 +test_utils_vl_lookup_SOURCES = utils_vl_lookup_test.c testing.h
 +test_utils_vl_lookup_LDADD = liblookup.la daemon/libplugin_mock.la
 +if BUILD_WITH_LIBKSTAT
 +test_utils_vl_lookup_LDADD += -lkstat
 +endif
 +
 +noinst_LTLIBRARIES += libmount.la
 +libmount_la_SOURCES = utils_mount.c utils_mount.h
 +check_PROGRAMS += test_utils_mount
 +TESTS += test_utils_mount
 +test_utils_mount_SOURCES = utils_mount_test.c testing.h
 +test_utils_mount_LDADD = libmount.la daemon/libplugin_mock.la
 +if BUILD_WITH_LIBKSTAT
 +test_utils_mount_LDADD += -lkstat
 +endif
  
  sbin_PROGRAMS = collectdmon
  bin_PROGRAMS = collectd-nagios collectdctl collectd-tg
@@@ -97,7 -77,7 +97,7 @@@ if BUILD_AI
  collectd_tg_LDADD += -lm
  endif
  if BUILD_WITH_LIBPTHREAD
 -collectd_tg_LDADD += -lpthread
 +collectd_tg_LDADD += $(PTHREAD_LIBS)
  endif
  collectd_tg_LDADD += libcollectdclient/libcollectdclient.la
  collectd_tg_DEPENDENCIES = libcollectdclient/libcollectdclient.la
@@@ -120,7 -100,7 +120,7 @@@ if BUILD_PLUGIN_AMQ
  pkglib_LTLIBRARIES += amqp.la
  amqp_la_SOURCES = amqp.c \
                  utils_cmd_putval.c utils_cmd_putval.h \
 -                utils_parse_option.c utils_parse_option.h \
 +                utils_parse_option.c utils_parse_option.h \
                  utils_format_graphite.c utils_format_graphite.h \
                  utils_format_json.c utils_format_json.h
  amqp_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBRABBITMQ_LDFLAGS)
@@@ -335,11 -315,10 +335,13 @@@ disk_la_CFLAGS += $(BUILD_WITH_LIBSTATG
  disk_la_LIBADD += $(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
  endif
  if BUILD_WITH_LIBUDEV
- disk_la_LIBADD += -ludev
+ disk_la_CFLAGS += $(BUILD_WITH_LIBUDEV_CFLAGS)
+ disk_la_LDFLAGS += $(BUILD_WITH_LIBUDEV_LDFLAGS)
+ disk_la_LIBADD += $(BULD_WITH_LIBUDEV_LIBS)
  endif
 +if BUILD_FREEBSD
 +disk_la_LIBADD += -ldevstat -lgeom
 +endif
  if BUILD_WITH_PERFSTAT
  disk_la_LIBADD += -lperfstat
  endif
@@@ -349,20 -328,21 +351,20 @@@ if BUILD_PLUGIN_DN
  pkglib_LTLIBRARIES += dns.la
  dns_la_SOURCES = dns.c utils_dns.c utils_dns.h
  dns_la_LDFLAGS = $(PLUGIN_LDFLAGS)
 -dns_la_LIBADD = -lpcap -lpthread
 +dns_la_LIBADD = $(PTHREAD_LIBS) -lpcap
  endif
  
  if BUILD_PLUGIN_DRBD
  pkglib_LTLIBRARIES += drbd.la
  drbd_la_SOURCES = drbd.c
  drbd_la_LDFLAGS = $(PLUGIN_LDFLAGS)
 -drbd_la_LIBADD = -lpthread
  endif
  
  if BUILD_PLUGIN_EMAIL
  pkglib_LTLIBRARIES += email.la
  email_la_SOURCES = email.c
  email_la_LDFLAGS = $(PLUGIN_LDFLAGS)
 -email_la_LIBADD = -lpthread
 +email_la_LIBADD = $(PTHREAD_LIBS)
  endif
  
  if BUILD_PLUGIN_ENTROPY
@@@ -378,7 -358,7 +380,7 @@@ exec_la_SOURCES = exec.c 
                  utils_cmd_putval.c utils_cmd_putval.h \
                  utils_parse_option.h utils_parse_option.c
  exec_la_LDFLAGS = $(PLUGIN_LDFLAGS)
 -exec_la_LIBADD = -lpthread
 +exec_la_LIBADD = $(PTHREAD_LIBS)
  endif
  
  if BUILD_PLUGIN_ETHSTAT
@@@ -467,8 -447,6 +469,8 @@@ pkglib_LTLIBRARIES += ipvs.l
  ipvs_la_SOURCES = ipvs.c
  if IP_VS_H_NEEDS_KERNEL_CFLAGS
  ipvs_la_CFLAGS = $(AM_CFLAGS) $(KERNEL_CFLAGS)
 +else
 +ipvs_la_CFLAGS = $(AM_CFLAGS)
  endif
  ipvs_la_LDFLAGS = $(PLUGIN_LDFLAGS)
  endif
@@@ -485,7 -463,7 +487,7 @@@ java_la_SOURCES = java.
  java_la_CPPFLAGS = $(AM_CPPFLAGS) $(JAVA_CPPFLAGS)
  java_la_CFLAGS = $(AM_CFLAGS) $(JAVA_CFLAGS)
  java_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(JAVA_LDFLAGS)
 -java_la_LIBADD = $(JAVA_LIBS)
 +java_la_LIBADD = $(PTHREAD_LIBS) $(JAVA_LIBS)
  endif
  
  if BUILD_PLUGIN_LOAD
@@@ -639,14 -617,6 +641,14 @@@ modbus_la_CFLAGS = $(AM_CFLAGS) $(BUILD
  modbus_la_LIBADD = $(BUILD_WITH_LIBMODBUS_LIBS)
  endif
  
 +if BUILD_PLUGIN_MQTT
 +pkglib_LTLIBRARIES += mqtt.la
 +mqtt_la_SOURCES = mqtt.c
 +mqtt_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBMOSQUITTO_CPPFLAGS)
 +mqtt_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBMOSQUITTO_LDFLAGS)
 +mqtt_la_LIBADD = $(BUILD_WITH_LIBMOSQUITTO_LIBS)
 +endif
 +
  if BUILD_PLUGIN_MULTIMETER
  pkglib_LTLIBRARIES += multimeter.la
  multimeter_la_SOURCES = multimeter.c
@@@ -687,7 -657,7 +689,7 @@@ network_la_SOURCES = network.c network.
                     utils_fbhash.c utils_fbhash.h
  network_la_CPPFLAGS = $(AM_CPPFLAGS)
  network_la_LDFLAGS = $(PLUGIN_LDFLAGS)
 -network_la_LIBADD = -lpthread
 +network_la_LIBADD = $(PTHREAD_LIBS)
  if BUILD_WITH_LIBSOCKET
  network_la_LIBADD += -lsocket
  endif
@@@ -734,13 -704,7 +736,13 @@@ if BUILD_PLUGIN_NOTIFY_EMAI
  pkglib_LTLIBRARIES += notify_email.la
  notify_email_la_SOURCES = notify_email.c
  notify_email_la_LDFLAGS = $(PLUGIN_LDFLAGS)
 -notify_email_la_LIBADD = -lesmtp -lssl -lcrypto -lpthread
 +notify_email_la_LIBADD = $(PTHREAD_LIBS) -lesmtp -lssl -lcrypto
 +endif
 +
 +if BUILD_PLUGIN_NOTIFY_NAGIOS
 +pkglib_LTLIBRARIES += notify_nagios.la
 +notify_nagios_la_SOURCES = notify_nagios.c
 +notify_nagios_la_LDFLAGS = $(PLUGIN_LDFLAGS)
  endif
  
  if BUILD_PLUGIN_NTPD
@@@ -764,7 -728,7 +766,7 @@@ pkglib_LTLIBRARIES += nut.l
  nut_la_SOURCES = nut.c
  nut_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBUPSCLIENT_CFLAGS)
  nut_la_LDFLAGS = $(PLUGIN_LDFLAGS)
 -nut_la_LIBADD = -lpthread $(BUILD_WITH_LIBUPSCLIENT_LIBS)
 +nut_la_LIBADD = $(PTHREAD_LIBS) $(BUILD_WITH_LIBUPSCLIENT_LIBS)
  endif
  
  if BUILD_PLUGIN_OLSRD
@@@ -783,7 -747,7 +785,7 @@@ onewire_la_SOURCES = onewire.
  onewire_la_CFLAGS = $(AM_CFLAGS)
  onewire_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBOWCAPI_CPPFLAGS)
  onewire_la_LIBADD = $(BUILD_WITH_LIBOWCAPI_LIBS)
 -onewire_la_LDFLAGS = $(PLUGIN_LDFLAGS)
 +onewire_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBOWCAPI_LDFLAGS)
  endif
  
  if BUILD_PLUGIN_OPENLDAP
@@@ -954,9 -918,9 +956,9 @@@ if BUILD_PLUGIN_SMAR
  if BUILD_WITH_LIBUDEV
  pkglib_LTLIBRARIES += smart.la
  smart_la_SOURCES = smart.c
- smart_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBATASMART_CPPFLAGS)
- smart_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBATASMART_LDFLAGS)
- smart_la_LIBADD = $(BUILD_WITH_LIBATASMART_LIBS) -ludev
+ smart_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBATASMART_CPPFLAGS) $(BUILD_WITH_LIBUDEV_CFLAGS)
+ smart_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBATASMART_LDFLAGS) $(BUILD_WITH_LIBUDEV_LDFLAGS)
+ smart_la_LIBADD = $(BUILD_WITH_LIBATASMART_LIBS) $(BUILD_WITH_LIBUDEV_LIBS)
  endif
  endif
  
@@@ -971,15 -935,16 +973,15 @@@ snmp_la_CFLAGS += $(BUILD_WITH_LIBSNMP_
  snmp_la_LIBADD += $(BUILD_WITH_LIBSNMP_LIBS)
  endif
  if BUILD_WITH_LIBPTHREAD
 -snmp_la_LIBADD += -lpthread
 +snmp_la_LIBADD += $(PTHREAD_LIBS)
  endif
  endif
  
  if BUILD_PLUGIN_STATSD
  pkglib_LTLIBRARIES += statsd.la
 -statsd_la_SOURCES = statsd.c \
 -                    utils_latency.h utils_latency.c
 +statsd_la_SOURCES = statsd.c
  statsd_la_LDFLAGS = $(PLUGIN_LDFLAGS)
 -statsd_la_LIBADD = -lpthread -lm
 +statsd_la_LIBADD = $(PTHREAD_LIBS) liblatency.la -lm
  endif
  
  if BUILD_PLUGIN_SWAP
@@@ -1130,7 -1095,7 +1132,7 @@@ unixsock_la_SOURCES = unixsock.c 
                      utils_cmd_putnotif.h utils_cmd_putnotif.c \
                      utils_parse_option.h utils_parse_option.c
  unixsock_la_LDFLAGS = $(PLUGIN_LDFLAGS)
 -unixsock_la_LIBADD = -lpthread
 +unixsock_la_LIBADD = $(PTHREAD_LIBS)
  endif
  
  if BUILD_PLUGIN_UPTIME
@@@ -1261,8 -1226,9 +1263,8 @@@ endi
  if BUILD_PLUGIN_WRITE_RIEMANN
  pkglib_LTLIBRARIES += write_riemann.la
  write_riemann_la_SOURCES = write_riemann.c write_riemann_threshold.c write_riemann_threshold.h
 -nodist_write_riemann_la_SOURCES = riemann.pb-c.c riemann.pb-c.h
 -write_riemann_la_LDFLAGS = $(PLUGIN_LDFLAGS)
 -write_riemann_la_LIBADD = -lprotobuf-c
 +write_riemann_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(LIBRIEMANN_CLIENT_LIBS)
 +write_riemann_la_CFLAGS = $(AM_CFLAGS) $(LIBRIEMANN_CLIENT_CFLAGS)
  endif
  
  if BUILD_PLUGIN_WRITE_SENSU
@@@ -1277,13 -1243,6 +1279,13 @@@ write_tsdb_la_SOURCES = write_tsdb.
  write_tsdb_la_LDFLAGS = $(PLUGIN_LDFLAGS)
  endif
  
 +if BUILD_PLUGIN_XENCPU
 +pkglib_LTLIBRARIES += xencpu.la
 +xencpu_la_SOURCES = xencpu.c
 +xencpu_la_LDFLAGS = $(PLUGIN_LDFLAGS)
 +xencpu_la_LIBADD = -lxenctrl
 +endif
 +
  if BUILD_PLUGIN_XMMS
  pkglib_LTLIBRARIES += xmms.la
  xmms_la_SOURCES = xmms.c
@@@ -1317,13 -1276,6 +1319,13 @@@ endi
  
  BUILT_SOURCES += $(dist_man_MANS)
  
 +if BUILD_PLUGIN_ZONE
 +pkglib_LTLIBRARIES += zone.la
 +zone_la_SOURCES = zone.c
 +zone_la_CFLAGS = $(AM_CFLAGS)
 +zone_la_LDFLAGS = $(PLUGIN_LDFLAGS)
 +endif
 +
  dist_man_MANS = collectd.1 \
                collectd.conf.5 \
                collectd-email.5 \
@@@ -1392,6 -1344,17 +1394,6 @@@ pinba.pb-c.c pinba.pb-c.h: pinba.prot
        $(AM_V_PROTOC_C)protoc-c -I$(srcdir) --c_out . $(srcdir)/pinba.proto
  endif
  
 -# Protocol buffer for the "write_riemann" plugin.
 -EXTRA_DIST += riemann.proto
 -if BUILD_PLUGIN_WRITE_RIEMANN
 -CLEANFILES += riemann.pb-c.c riemann.pb-c.h
 -
 -BUILT_SOURCES += riemann.pb-c.c riemann.pb-c.h
 -
 -riemann.pb-c.c riemann.pb-c.h: riemann.proto
 -      $(AM_V_PROTOC_C)protoc-c -I$(srcdir) --c_out . $(srcdir)/riemann.proto
 -endif
 -
  install-exec-hook:
        $(mkinstalldirs) $(DESTDIR)$(sysconfdir)
        if test -e $(DESTDIR)$(sysconfdir)/collectd.conf; \
@@@ -1410,6 -1373,22 +1412,6 @@@ uninstall-hook
        rm -f $(DESTDIR)$(sysconfdir)/collectd.conf
        rm -f $(DESTDIR)$(pkgdatadir)/postgresql_default.conf;
  
 -check_PROGRAMS = test_utils_mount test_utils_vl_lookup
 -
 -test_utils_mount_SOURCES = utils_mount_test.c testing.h
 -test_utils_mount_LDADD = libmount.la daemon/libplugin_mock.la
 -if BUILD_WITH_LIBKSTAT
 -test_utils_mount_LDADD += -lkstat
 -endif
 -
 -test_utils_vl_lookup_SOURCES = utils_vl_lookup_test.c testing.h
 -test_utils_vl_lookup_LDADD = liblookup.la daemon/libplugin_mock.la
 -if BUILD_WITH_LIBKSTAT
 -test_utils_vl_lookup_LDADD += -lkstat
 -endif
 -
 -TESTS = test_utils_mount test_utils_vl_lookup
 -
  if BUILD_PLUGIN_CEPH
  test_plugin_ceph_SOURCES = ceph_test.c
  test_plugin_ceph_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBYAJL_CPPFLAGS)
diff --combined src/collectd.conf.in
  #@BUILD_PLUGIN_GMOND_TRUE@LoadPlugin gmond
  #@BUILD_PLUGIN_HDDTEMP_TRUE@LoadPlugin hddtemp
  @BUILD_PLUGIN_INTERFACE_TRUE@@BUILD_PLUGIN_INTERFACE_TRUE@LoadPlugin interface
- #@BUILD_PLUGIN_IPC_TRUE@@BUILD_PLUGIN_IPC_TRUE@LoadPlugin ipc
+ #@BUILD_PLUGIN_IPC_TRUE@LoadPlugin ipc
  #@BUILD_PLUGIN_IPMI_TRUE@LoadPlugin ipmi
  #@BUILD_PLUGIN_IPTABLES_TRUE@LoadPlugin iptables
  #@BUILD_PLUGIN_IPVS_TRUE@LoadPlugin ipvs
  @BUILD_PLUGIN_MEMORY_TRUE@@BUILD_PLUGIN_MEMORY_TRUE@LoadPlugin memory
  #@BUILD_PLUGIN_MIC_TRUE@LoadPlugin mic
  #@BUILD_PLUGIN_MODBUS_TRUE@LoadPlugin modbus
 +#@BUILD_PLUGIN_MQTT_TRUE@LoadPlugin mqtt
  #@BUILD_PLUGIN_MULTIMETER_TRUE@LoadPlugin multimeter
  #@BUILD_PLUGIN_MYSQL_TRUE@LoadPlugin mysql
  #@BUILD_PLUGIN_NETAPP_TRUE@LoadPlugin netapp
  #@BUILD_PLUGIN_NGINX_TRUE@LoadPlugin nginx
  #@BUILD_PLUGIN_NOTIFY_DESKTOP_TRUE@LoadPlugin notify_desktop
  #@BUILD_PLUGIN_NOTIFY_EMAIL_TRUE@LoadPlugin notify_email
 +#@BUILD_PLUGIN_NOTIFY_NAGIOS_TRUE@LoadPlugin notify_nagios
  #@BUILD_PLUGIN_NTPD_TRUE@LoadPlugin ntpd
  #@BUILD_PLUGIN_NUMA_TRUE@LoadPlugin numa
  #@BUILD_PLUGIN_NUT_TRUE@LoadPlugin nut
  #@BUILD_PLUGIN_WRITE_RIEMANN_TRUE@LoadPlugin write_riemann
  #@BUILD_PLUGIN_WRITE_SENSU_TRUE@LoadPlugin write_sensu
  #@BUILD_PLUGIN_WRITE_TSDB_TRUE@LoadPlugin write_tsdb
 +#@BUILD_PLUGIN_XENCPU_TRUE@LoadPlugin xencpu
  #@BUILD_PLUGIN_XMMS_TRUE@LoadPlugin xmms
  #@BUILD_PLUGIN_ZFS_ARC_TRUE@LoadPlugin zfs_arc
 +#@BUILD_PLUGIN_ZONE_TRUE@LoadPlugin zone
  #@BUILD_PLUGIN_ZOOKEEPER_TRUE@LoadPlugin zookeeper
  
  ##############################################################################
  #     Host "localhost"
  #     Port "3551"
  #     ReportSeconds true
 +#     PersistentConnection true
  #</Plugin>
  
  #<Plugin aquaero>
  #<Plugin interface>
  #     Interface "eth0"
  #     IgnoreSelected false
 +#     UniqueName false
  #</Plugin>
  
  #<Plugin ipmi>
  #     </Host>
  #</Plugin>
  
 +#<Plugin mqtt>
 +#     <Publish "name">
 +#             Host "localhost"
 +#             Port 1883
 +#             ClientId "localhost"
 +#             User "user"
 +#             Password "secret"
 +#             QoS 0
 +#             Prefix "collectd"
 +#             StoreRates true
 +#             Retain false
 +#             CACert "/etc/ssl/ca.crt"
 +#             CertificateFile "/etc/ssl/client.crt"
 +#             CertificateKeyFile "/etc/ssl/client.pem"
 +#             TLSProtocol "tlsv1.2"
 +#             CipherSuite "ciphers"
 +#     </Publish>
 +#     <Subscribe "name">
 +#             Host "localhost"
 +#             Port 1883
 +#             ClientId "localhost"
 +#             User "user"
 +#             Password "secret"
 +#             QoS 2
 +#             Topic "collectd/#"
 +#             CleanSession true
 +#     </Subscribe>
 +#</Plugin>
 +
  #<Plugin mysql>
  #     <Database db_name>
  #             Host "database.serv.er"
  #     Recipient "email2@domain2.com"
  #</Plugin>
  
 +#<Plugin notify_nagios>
 +#     CommandFile "/usr/local/nagios/var/rw/nagios.cmd"
 +#</Plugin>
 +
  #<Plugin ntpd>
  #     Host "localhost"
  #     Port 123
  #  DeleteTimers   false
  #  DeleteGauges   false
  #  DeleteSets     false
 +#  CounterSum     false
  #  TimerPercentile 90.0
  #  TimerPercentile 95.0
  #  TimerPercentile 99.0
  ##    None of the following option should be set manually
  ##    This plugin automatically detect most optimal options
  ##    Only set values here if:
 -##    - The module ask you to
 +##    - The module asks you to
  ##    - You want to disable the collection of some data
 -##    - Your (intel) CPU is not supported (yet) by the module
 -##    - The module generate a lot of errors 'MSR offset 0x... read failed'
 +##    - Your (Intel) CPU is not supported (yet) by the module
 +##    - The module generates a lot of errors 'MSR offset 0x... read failed'
  ##    In the last two cases, please open a bug request
  #
  #     TCCActivationTemp "100"
  #    Host "localhost"
  #    Port "2003"
  #    Protocol "tcp"
 +#    ReconnectInterval 0
  #    LogSendErrors true
  #    Prefix "collectd"
  #    Postfix "collectd"
  #             ClientKey "/etc/ssl/client.pem"
  #             ClientCert "/etc/ssl/client.crt"
  #             ClientKeyPass "secret"
 +#             Header "X-Custom-Header: custom_value"
  #             SSLVersion "TLSv1"
  #             Format "Command"
  #             StoreRates false
  #             Host "localhost"
  #             Port "6379"
  #             Timeout 1000
 +#             Prefix "collectd/"
  #     </Node>
  #</Plugin>
  
diff --combined src/processes.c
  
  # include <sys/user.h>
  # include <dirent.h>
+ #ifndef MAXCOMLEN
+ #  define MAXCOMLEN 16
+ #endif
  /* #endif KERNEL_SOLARIS */
  
  #else
@@@ -181,9 -186,6 +186,9 @@@ typedef struct procstat_entry_
        derive_t io_syscr;
        derive_t io_syscw;
  
 +      derive_t cswitch_vol;
 +      derive_t cswitch_invol;
 +
        struct procstat_entry_s *next;
  } procstat_entry_t;
  
@@@ -215,17 -217,12 +220,17 @@@ typedef struct procsta
        derive_t io_syscr;
        derive_t io_syscw;
  
 +      derive_t cswitch_vol;
 +      derive_t cswitch_invol;
 +
        struct procstat   *next;
        struct procstat_entry_s *instances;
  } procstat_t;
  
  static procstat_t *list_head_g = NULL;
  
 +static _Bool report_ctx_switch = 0;
 +
  #if HAVE_THREAD_INFO
  static mach_port_t port_host_self;
  static mach_port_t port_task_self;
@@@ -263,19 -260,20 +268,19 @@@ static void ps_list_register (const cha
        procstat_t *ptr;
        int status;
  
 -      new = (procstat_t *) malloc (sizeof (procstat_t));
 +      new = calloc (1, sizeof (*new));
        if (new == NULL)
        {
 -              ERROR ("processes plugin: ps_list_register: malloc failed.");
 +              ERROR ("processes plugin: ps_list_register: calloc failed.");
                return;
        }
 -      memset (new, 0, sizeof (procstat_t));
        sstrncpy (new->name, name, sizeof (new->name));
  
  #if HAVE_REGEX_H
        if (regexp != NULL)
        {
                DEBUG ("ProcessMatch: adding \"%s\" as criteria to process %s.", regexp, name);
 -              new->re = (regex_t *) malloc (sizeof (regex_t));
 +              new->re = malloc (sizeof (*new->re));
                if (new->re == NULL)
                {
                        ERROR ("processes plugin: ps_list_register: malloc failed.");
                if (status != 0)
                {
                        DEBUG ("ProcessMatch: compiling the regular expression \"%s\" failed.", regexp);
 -                      sfree(new->re);
 -                      sfree(new);
 +                      sfree (new->re);
 +                      sfree (new);
                        return;
                }
        }
@@@ -361,31 -359,6 +366,31 @@@ static int ps_list_match (const char *n
        return (0);
  } /* int ps_list_match */
  
 +static void ps_update_counter (
 +        _Bool init,
 +        derive_t *group_counter,
 +        derive_t *curr_counter, unsigned long *curr_value,
 +        derive_t new_counter, unsigned long new_value) {
 +    if (init)
 +    {
 +        *curr_value = new_value;
 +        *curr_counter += new_value;
 +        *group_counter += new_value;
 +        return;
 +    }
 +
 +    if (new_counter < *curr_counter)
 +    {
 +        *curr_value = new_counter + (ULONG_MAX - *curr_counter);
 +    }
 +    else
 +    {
 +        *curr_value = new_counter - *curr_counter;
 +    }
 +    *curr_counter = new_counter;
 +    *group_counter += *curr_value;
 +}
 +
  /* add process entry to 'instances' of process 'name' (or refresh it) */
  static void ps_list_add (const char *name, const char *cmdline, procstat_entry_t *entry)
  {
  
        for (ps = list_head_g; ps != NULL; ps = ps->next)
        {
 +        _Bool want_init;
 +
                if ((ps_list_match (name, cmdline, ps)) == 0)
                        continue;
  
                {
                        procstat_entry_t *new;
  
 -                      new = (procstat_entry_t *) malloc (sizeof (procstat_entry_t));
 +                      new = calloc (1, sizeof (*new));
                        if (new == NULL)
                                return;
 -                      memset (new, 0, sizeof (procstat_entry_t));
                        new->id = entry->id;
  
                        if (pse == NULL)
                pse->io_wchar   = entry->io_wchar;
                pse->io_syscr   = entry->io_syscr;
                pse->io_syscw   = entry->io_syscw;
 +              pse->cswitch_vol   = entry->cswitch_vol;
 +              pse->cswitch_invol = entry->cswitch_invol;
  
                ps->num_proc   += pse->num_proc;
                ps->num_lwp    += pse->num_lwp;
                ps->io_syscr   += ((pse->io_syscr == -1)?0:pse->io_syscr);
                ps->io_syscw   += ((pse->io_syscw == -1)?0:pse->io_syscw);
  
 -              if ((entry->vmem_minflt_counter == 0)
 -                              && (entry->vmem_majflt_counter == 0))
 -              {
 -                      pse->vmem_minflt_counter += entry->vmem_minflt;
 -                      pse->vmem_minflt = entry->vmem_minflt;
 -
 -                      pse->vmem_majflt_counter += entry->vmem_majflt;
 -                      pse->vmem_majflt = entry->vmem_majflt;
 -              }
 -              else
 -              {
 -                      if (entry->vmem_minflt_counter < pse->vmem_minflt_counter)
 -                      {
 -                              pse->vmem_minflt = entry->vmem_minflt_counter
 -                                      + (ULONG_MAX - pse->vmem_minflt_counter);
 -                      }
 -                      else
 -                      {
 -                              pse->vmem_minflt = entry->vmem_minflt_counter - pse->vmem_minflt_counter;
 -                      }
 -                      pse->vmem_minflt_counter = entry->vmem_minflt_counter;
 -
 -                      if (entry->vmem_majflt_counter < pse->vmem_majflt_counter)
 -                      {
 -                              pse->vmem_majflt = entry->vmem_majflt_counter
 -                                      + (ULONG_MAX - pse->vmem_majflt_counter);
 -                      }
 -                      else
 -                      {
 -                              pse->vmem_majflt = entry->vmem_majflt_counter - pse->vmem_majflt_counter;
 -                      }
 -                      pse->vmem_majflt_counter = entry->vmem_majflt_counter;
 -              }
 -
 -              ps->vmem_minflt_counter += pse->vmem_minflt;
 -              ps->vmem_majflt_counter += pse->vmem_majflt;
 -
 -              if ((entry->cpu_user_counter == 0)
 -                              && (entry->cpu_system_counter == 0))
 -              {
 -                      pse->cpu_user_counter += entry->cpu_user;
 -                      pse->cpu_user = entry->cpu_user;
 -
 -                      pse->cpu_system_counter += entry->cpu_system;
 -                      pse->cpu_system = entry->cpu_system;
 -              }
 -              else
 -              {
 -                      if (entry->cpu_user_counter < pse->cpu_user_counter)
 -                      {
 -                              pse->cpu_user = entry->cpu_user_counter
 -                                      + (ULONG_MAX - pse->cpu_user_counter);
 -                      }
 -                      else
 -                      {
 -                              pse->cpu_user = entry->cpu_user_counter - pse->cpu_user_counter;
 -                      }
 -                      pse->cpu_user_counter = entry->cpu_user_counter;
 -
 -                      if (entry->cpu_system_counter < pse->cpu_system_counter)
 -                      {
 -                              pse->cpu_system = entry->cpu_system_counter
 -                                      + (ULONG_MAX - pse->cpu_system_counter);
 -                      }
 -                      else
 -                      {
 -                              pse->cpu_system = entry->cpu_system_counter - pse->cpu_system_counter;
 -                      }
 -                      pse->cpu_system_counter = entry->cpu_system_counter;
 -              }
 -
 -              ps->cpu_user_counter   += pse->cpu_user;
 -              ps->cpu_system_counter += pse->cpu_system;
 +              ps->cswitch_vol   += ((pse->cswitch_vol == -1)?0:pse->cswitch_vol);
 +              ps->cswitch_invol += ((pse->cswitch_invol == -1)?0:pse->cswitch_invol);
 +
 +              want_init = (entry->vmem_minflt_counter == 0)
 +                              && (entry->vmem_majflt_counter == 0);
 +              ps_update_counter (want_init,
 +                              &ps->vmem_minflt_counter,
 +                              &pse->vmem_minflt_counter, &pse->vmem_minflt,
 +                              entry->vmem_minflt_counter, entry->vmem_minflt);
 +              ps_update_counter (want_init,
 +                              &ps->vmem_majflt_counter,
 +                              &pse->vmem_majflt_counter, &pse->vmem_majflt,
 +                              entry->vmem_majflt_counter, entry->vmem_majflt);
 +
 +              want_init = (entry->cpu_user_counter == 0)
 +                              && (entry->cpu_system_counter == 0);
 +              ps_update_counter (want_init,
 +                              &ps->cpu_user_counter,
 +                              &pse->cpu_user_counter, &pse->cpu_user,
 +                              entry->cpu_user_counter, entry->cpu_user);
 +              ps_update_counter (want_init,
 +                              &ps->cpu_system_counter,
 +                              &pse->cpu_system_counter, &pse->cpu_system,
 +                              entry->cpu_system_counter, entry->cpu_system);
        }
  }
  
@@@ -498,8 -517,6 +503,8 @@@ static void ps_list_reset (void
                ps->io_wchar = -1;
                ps->io_syscr = -1;
                ps->io_syscw = -1;
 +              ps->cswitch_vol   = -1;
 +              ps->cswitch_invol = -1;
  
                pse_prev = NULL;
                pse = ps->instances;
@@@ -599,10 -616,6 +604,10 @@@ static int ps_config (oconfig_item_t *c
                        ps_list_register (c->values[0].value.string,
                                        c->values[1].value.string);
                }
 +              else if (strcasecmp (c->key, "CollectContextSwitch") == 0)
 +              {
 +                      cf_util_get_boolean (c, &report_ctx_switch);
 +              }
                else
                {
                        ERROR ("processes plugin: The `%s' configuration option is not "
@@@ -752,36 -765,19 +757,36 @@@ static void ps_submit_proc_list (procst
                plugin_dispatch_values (&vl);
        }
  
 +      if ( report_ctx_switch )
 +      {
 +              sstrncpy (vl.type, "contextswitch", sizeof (vl.type));
 +              sstrncpy (vl.type_instance, "voluntary", sizeof (vl.type_instance));
 +              vl.values[0].derive = ps->cswitch_vol;
 +              vl.values_len = 1;
 +              plugin_dispatch_values (&vl);
 +
 +              sstrncpy (vl.type, "contextswitch", sizeof (vl.type));
 +              sstrncpy (vl.type_instance, "involuntary", sizeof (vl.type_instance));
 +              vl.values[0].derive = ps->cswitch_invol;
 +              vl.values_len = 1;
 +              plugin_dispatch_values (&vl);
 +      }
 +
        DEBUG ("name = %s; num_proc = %lu; num_lwp = %lu; "
                        "vmem_size = %lu; vmem_rss = %lu; vmem_data = %lu; "
                        "vmem_code = %lu; "
                        "vmem_minflt_counter = %"PRIi64"; vmem_majflt_counter = %"PRIi64"; "
                        "cpu_user_counter = %"PRIi64"; cpu_system_counter = %"PRIi64"; "
                        "io_rchar = %"PRIi64"; io_wchar = %"PRIi64"; "
 -                      "io_syscr = %"PRIi64"; io_syscw = %"PRIi64";",
 +                      "io_syscr = %"PRIi64"; io_syscw = %"PRIi64"; "
 +                      "cswitch_vol = %"PRIi64"; cswitch_invol = %"PRIi64";",
                        ps->name, ps->num_proc, ps->num_lwp,
                        ps->vmem_size, ps->vmem_rss,
                        ps->vmem_data, ps->vmem_code,
                        ps->vmem_minflt_counter, ps->vmem_majflt_counter,
                        ps->cpu_user_counter, ps->cpu_system_counter,
 -                      ps->io_rchar, ps->io_wchar, ps->io_syscr, ps->io_syscw);
 +                      ps->io_rchar, ps->io_wchar, ps->io_syscr, ps->io_syscw,
 +                      ps->cswitch_vol, ps->cswitch_invol);
  } /* void ps_submit_proc_list */
  
  #if KERNEL_LINUX || KERNEL_SOLARIS
@@@ -806,99 -802,42 +811,99 @@@ static void ps_submit_fork_rate (derive
  
  /* ------- additional functions for KERNEL_LINUX/HAVE_THREAD_INFO ------- */
  #if KERNEL_LINUX
 -static int ps_read_tasks (long pid)
 +static procstat_t *ps_read_tasks_status (long pid, procstat_t *ps)
  {
        char           dirname[64];
        DIR           *dh;
 +      char           filename[64];
 +      FILE          *fh;
        struct dirent *ent;
 -      int count = 0;
 +      derive_t cswitch_vol = 0;
 +      derive_t cswitch_invol = 0;
 +      char buffer[1024];
 +      char *fields[8];
 +      int numfields;
  
        ssnprintf (dirname, sizeof (dirname), "/proc/%li/task", pid);
  
        if ((dh = opendir (dirname)) == NULL)
        {
                DEBUG ("Failed to open directory `%s'", dirname);
 -              return (-1);
 +              return (NULL);
        }
  
        while ((ent = readdir (dh)) != NULL)
        {
 +              char *tpid;
 +
                if (!isdigit ((int) ent->d_name[0]))
                        continue;
 -              else
 -                      count++;
 +
 +              tpid = ent->d_name;
 +
 +              ssnprintf (filename, sizeof (filename), "/proc/%li/task/%s/status", pid, tpid);
 +              if ((fh = fopen (filename, "r")) == NULL)
 +              {
 +                      DEBUG ("Failed to open file `%s'", filename);
 +                      continue;
 +              }
 +
 +              while (fgets (buffer, sizeof(buffer), fh) != NULL)
 +              {
 +                      derive_t tmp;
 +                      char *endptr;
 +
 +                      if (strncmp (buffer, "voluntary_ctxt_switches", 23) != 0
 +                              && strncmp (buffer, "nonvoluntary_ctxt_switches", 26) != 0)
 +                              continue;
 +
 +                      numfields = strsplit (buffer, fields,
 +                              STATIC_ARRAY_SIZE (fields));
 +
 +                      if (numfields < 2)
 +                              continue;
 +
 +                      errno = 0;
 +                      endptr = NULL;
 +                      tmp = (derive_t) strtoll (fields[1], &endptr, /* base = */ 10);
 +                      if ((errno == 0) && (endptr != fields[1]))
 +                      {
 +                              if (strncmp (buffer, "voluntary_ctxt_switches", 23) == 0)
 +                              {
 +                                      cswitch_vol += tmp;
 +                              }
 +                              else if (strncmp (buffer, "nonvoluntary_ctxt_switches", 26) == 0)
 +                              {
 +                                      cswitch_invol += tmp;
 +                              }
 +                      }
 +              } /* while (fgets) */
 +
 +              if (fclose (fh))
 +              {
 +                      char errbuf[1024];
 +                              WARNING ("processes: fclose: %s",
 +                                      sstrerror (errno, errbuf, sizeof (errbuf)));
 +              }
        }
        closedir (dh);
  
 -      return ((count >= 1) ? count : 1);
 -} /* int *ps_read_tasks */
 +      ps->cswitch_vol = cswitch_vol;
 +      ps->cswitch_invol = cswitch_invol;
  
 -/* Read advanced virtual memory data from /proc/pid/status */
 -static procstat_t *ps_read_vmem (long pid, procstat_t *ps)
 +      return (ps);
 +} /* int *ps_read_tasks_status */
 +
 +/* Read data from /proc/pid/status */
 +static procstat_t *ps_read_status (long pid, procstat_t *ps)
  {
        FILE *fh;
        char buffer[1024];
        char filename[64];
 -      unsigned long long lib = 0;
 -      unsigned long long exe = 0;
 -      unsigned long long data = 0;
 +      unsigned long lib = 0;
 +      unsigned long exe = 0;
 +      unsigned long data = 0;
 +      unsigned long threads = 0;
        char *fields[8];
        int numfields;
  
  
        while (fgets (buffer, sizeof(buffer), fh) != NULL)
        {
 -              long long tmp;
 +              unsigned long tmp;
                char *endptr;
  
 -              if (strncmp (buffer, "Vm", 2) != 0)
 +              if (strncmp (buffer, "Vm", 2) != 0
 +                              && strncmp (buffer, "Threads", 7) != 0)
                        continue;
  
                numfields = strsplit (buffer, fields,
  
                errno = 0;
                endptr = NULL;
 -              tmp = strtoll (fields[1], &endptr, /* base = */ 10);
 +              tmp = strtoul (fields[1], &endptr, /* base = */ 10);
                if ((errno == 0) && (endptr != fields[1]))
                {
                        if (strncmp (buffer, "VmData", 6) == 0)
                        {
                                exe = tmp;
                        }
 +                      else if  (strncmp(buffer, "Threads", 7) == 0)
 +                      {
 +                              threads = tmp;
 +                      }
                }
        } /* while (fgets) */
  
  
        ps->vmem_data = data * 1024;
        ps->vmem_code = (exe + lib) * 1024;
 +      if (threads != 0)
 +              ps->num_lwp = threads;
  
        return (ps);
  } /* procstat_t *ps_read_vmem */
@@@ -1023,9 -955,9 +1028,9 @@@ static int ps_read_process (long pid, p
        char *fields[64];
        char  fields_len;
  
 -      int   buffer_len;
 +      size_t buffer_len;
  
 -      char *buffer_ptr;
 +      char  *buffer_ptr;
        size_t name_start_pos;
        size_t name_end_pos;
        size_t name_len;
        long long unsigned vmem_rss;
        long long unsigned stack_size;
  
 +      ssize_t status;
 +
        memset (ps, 0, sizeof (procstat_t));
  
        ssnprintf (filename, sizeof (filename), "/proc/%li/stat", pid);
  
 -      buffer_len = read_file_contents (filename,
 -                      buffer, sizeof(buffer) - 1);
 -      if (buffer_len <= 0)
 +      status = read_file_contents (filename, buffer, sizeof(buffer) - 1);
 +      if (status <= 0)
                return (-1);
 +      buffer_len = (size_t) status;
        buffer[buffer_len] = 0;
  
        /* The name of the process is enclosed in parens. Since the name can
         * strchr(3) and strrchr(3) to avoid pointer arithmetic which would
         * otherwise be required to determine name_len. */
        name_start_pos = 0;
 -      while ((buffer[name_start_pos] != '(')
 -                      && (name_start_pos < buffer_len))
 +      while (name_start_pos < buffer_len && buffer[name_start_pos] != '(')
                name_start_pos++;
  
        name_end_pos = buffer_len;
 -      while ((buffer[name_end_pos] != ')')
 -                      && (name_end_pos > 0))
 +      while (name_end_pos > 0 && buffer[name_end_pos] != ')')
                name_end_pos--;
  
        /* Either '(' or ')' is not found or they are in the wrong order.
        }
        else
        {
 -              if ( (ps->num_lwp = ps_read_tasks (pid)) == -1 )
 +              ps->num_lwp = strtoul (fields[17], /* endptr = */ NULL, /* base = */ 10);
 +              if ((ps_read_status(pid, ps)) == NULL)
                {
 -                      /* returns -1 => kernel 2.4 */
 -                      ps->num_lwp = 1;
 +                      /* No VMem data */
 +                      ps->vmem_data = -1;
 +                      ps->vmem_code = -1;
 +                      DEBUG("ps_read_process: did not get vmem data for pid %li", pid);
                }
 +              if (ps->num_lwp == 0)
 +                      ps->num_lwp = 1;
                ps->num_proc = 1;
        }
  
        cpu_system_counter = cpu_system_counter * 1000000 / CONFIG_HZ;
        vmem_rss = vmem_rss * pagesize_g;
  
 -      if ( (ps_read_vmem(pid, ps)) == NULL)
 -      {
 -              /* No VMem data */
 -              ps->vmem_data = -1;
 -              ps->vmem_code = -1;
 -              DEBUG("ps_read_process: did not get vmem data for pid %li", pid);
 -      }
 -
        ps->cpu_user_counter = cpu_user_counter;
        ps->cpu_system_counter = cpu_system_counter;
        ps->vmem_size = (unsigned long) vmem_size;
                DEBUG("ps_read_process: not get io data for pid %li", pid);
        }
  
 +      if ( report_ctx_switch )
 +      {
 +              if ( (ps_read_tasks_status(pid, ps)) == NULL)
 +              {
 +                      ps->cswitch_vol = -1;
 +                      ps->cswitch_invol = -1;
 +
 +                      DEBUG("ps_read_tasks_status: not get context "
 +                                      "switch data for pid %li", pid);
 +              }
 +      }
 +
        /* success */
        return (0);
  } /* int ps_read_process (...) */
@@@ -1230,7 -1153,7 +1235,7 @@@ static char *ps_get_cmdline (long pid, 
                buf_ptr += status;
                len     -= status;
  
 -              if (len <= 0)
 +              if (len == 0)
                        break;
        }
  
@@@ -1319,16 -1242,16 +1324,16 @@@ static char *ps_get_cmdline (long pid, 
  {
        char path[PATH_MAX];
        psinfo_t info;
 -      int status;
 +      ssize_t status;
  
        snprintf(path, sizeof (path), "/proc/%li/psinfo", pid);
  
        status = read_file_contents (path, (void *) &info, sizeof (info));
 -      if (status != sizeof (info))
 +      if ((status < 0) || (((size_t) status) != sizeof (info)))
        {
                ERROR ("processes plugin: Unexpected return value "
                                "while reading \"%s\": "
 -                              "Returned %i but expected %zu.",
 +                              "Returned %zd but expected %zu.",
                                path, status, buffer_size);
                return (NULL);
        }
@@@ -1360,15 -1283,18 +1365,15 @@@ static int ps_read_process(long pid, pr
        snprintf(f_usage, sizeof (f_usage), "/proc/%li/usage", pid);
  
  
 -      buffer = malloc(sizeof (pstatus_t));
 -      memset(buffer, 0, sizeof (pstatus_t));
 +      buffer = calloc(1, sizeof (pstatus_t));
        read_file_contents(filename, buffer, sizeof (pstatus_t));
        myStatus = (pstatus_t *) buffer;
  
 -      buffer = malloc(sizeof (psinfo_t));
 -      memset(buffer, 0, sizeof(psinfo_t));
 +      buffer = calloc(1, sizeof (psinfo_t));
        read_file_contents(f_psinfo, buffer, sizeof (psinfo_t));
        myInfo = (psinfo_t *) buffer;
  
 -      buffer = malloc(sizeof (prusage_t));
 -      memset(buffer, 0, sizeof(prusage_t));
 +      buffer = calloc(1, sizeof (prusage_t));
        read_file_contents(f_usage, buffer, sizeof (prusage_t));
        myUsage = (prusage_t *) buffer;
  
        ps->io_syscr = myUsage->pr_sysc;
        ps->io_syscw = myUsage->pr_sysc;
  
 +      /*
 +       * TODO: context switch counters for Solaris
 +   */
 +      ps->cswitch_vol   = -1;
 +      ps->cswitch_invol = -1;
 +
  
        /*
         * TODO: Find way of setting BLOCKED and PAGING status
   * are retrieved from kstat (module cpu, name sys, class misc, stat nthreads).
   * The result is the sum for all the threads created on each cpu
   */
 -static int read_fork_rate()
 +static int read_fork_rate (void)
  {
        extern kstat_ctl_t *kc;
        kstat_t *ksp_chain = NULL;
@@@ -1669,10 -1589,6 +1674,10 @@@ static int ps_read (void
  
                                pse.cpu_user_counter = task_absolutetime_info.total_user;
                                pse.cpu_system_counter = task_absolutetime_info.total_system;
 +
 +                              /* context switch counters not implemented */
 +                              pse.cswitch_vol   = -1;
 +                              pse.cswitch_invol = -1;
                        }
  
                        status = task_threads (task_list[task], &thread_list,
                pse.io_syscr = ps.io_syscr;
                pse.io_syscw = ps.io_syscw;
  
 +              pse.cswitch_vol = ps.cswitch_vol;
 +              pse.cswitch_invol = ps.cswitch_invol;
 +
                switch (state)
                {
                        case 'R': running++;  break;
                        pse.io_syscr = -1;
                        pse.io_syscw = -1;
  
 +                      /* context switch counters not implemented */
 +                      pse.cswitch_vol   = -1;
 +                      pse.cswitch_invol = -1;
 +
                        ps_list_add (procs[i].ki_comm, have_cmdline ? cmdline : NULL, &pse);
  
                        switch (procs[i].ki_stat)
                        pse.io_syscr = -1;
                        pse.io_syscw = -1;
  
 +                      /* context switch counters not implemented */
 +                      pse.cswitch_vol   = -1;
 +                      pse.cswitch_invol = -1;
 +
                        ps_list_add (procs[i].p_comm, have_cmdline ? cmdline : NULL, &pse);
  
                        switch (procs[i].p_stat)
                        pse.io_syscr = -1;
                        pse.io_syscw = -1;
  
 +                      pse.cswitch_vol   = -1;
 +                      pse.cswitch_invol = -1;
 +
                        ps_list_add (cmdline, cargs, &pse);
                } /* for (i = 0 .. nprocs) */
  
                pse.io_syscr = ps.io_syscr;
                pse.io_syscw = ps.io_syscw;
  
 +              pse.cswitch_vol = -1;
 +              pse.cswitch_invol = -1;
 +
                switch (state)
                {
                        case 'R': running++;  break;