Merge branch 'collectd-4.5'
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Mon, 16 Feb 2009 11:48:22 +0000 (12:48 +0100)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Mon, 16 Feb 2009 11:48:22 +0000 (12:48 +0100)
Conflicts:

configure.in

1  2 
configure.in
src/collectd.conf.pod

diff --combined configure.in
@@@ -70,10 -70,6 +70,10 @@@ the
        CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS"
  fi
  
 +# Where to install .pc files.
 +pkgconfigdir="${libdir}/pkgconfig"
 +AC_SUBST(pkgconfigdir)
 +
  #
  # Checks for header files.
  #
@@@ -404,7 -400,7 +404,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)
 +AC_CHECK_FUNCS(gettimeofday select strdup strtol getaddrinfo getnameinfo strchr memcpy strstr strcmp strncmp strncpy strlen strncasecmp strcasecmp openlog closelog sysconf)
  
  AC_FUNC_STRERROR_R
  
@@@ -480,7 -476,6 +480,7 @@@ nanosleep_needs_rt="no
  AC_CHECK_FUNCS(nanosleep, [], AC_CHECK_LIB(rt, nanosleep, [nanosleep_needs_rt="yes"], AC_MSG_ERROR(cannot find nanosleep)))
  AM_CONDITIONAL(BUILD_WITH_LIBRT, test "x$nanosleep_needs_rt" = "xyes")
  
 +AC_CHECK_FUNCS(sysctl, [have_sysctl="yes"], [have_sysctl="no"])
  AC_CHECK_FUNCS(sysctlbyname, [have_sysctlbyname="yes"], [have_sysctlbyname="no"])
  AC_CHECK_FUNCS(host_statistics, [have_host_statistics="yes"], [have_host_statistics="no"])
  AC_CHECK_FUNCS(processor_info, [have_processor_info="yes"], [have_processor_info="no"])
@@@ -491,7 -486,6 +491,7 @@@ AC_CHECK_FUNCS(getifaddrs, [have_getifa
  AC_CHECK_FUNCS(syslog, [have_syslog="yes"], [have_syslog="no"])
  AC_CHECK_FUNCS(getutent, [have_getutent="yes"], [have_getutent="no"])
  AC_CHECK_FUNCS(getutxent, [have_getutxent="yes"], [have_getutxent="no"])
 +AC_CHECK_FUNCS(swapctl, [have_swapctl="yes"], [have_swapctl="no"])
  
  # For load module
  AC_CHECK_FUNCS(getloadavg, [have_getloadavg="yes"], [have_getloadavg="no"])
@@@ -627,13 -621,8 +627,13 @@@ if test "x$fp_layout_type" = "xunknown"
        [[[[
  #include <stdlib.h>
  #include <stdio.h>
 -#include <stdint.h>
  #include <string.h>
 +#if HAVE_STDINT_H
 +# include <stdint.h>
 +#endif
 +#if HAVE_STDBOOL_H
 +# include <stdbool.h>
 +#endif
        ]]]],
        [[[[
        uint64_t i0;
@@@ -671,13 -660,8 +671,13 @@@ if test "x$fp_layout_type" = "xunknown"
        [[[[
  #include <stdlib.h>
  #include <stdio.h>
 -#include <stdint.h>
  #include <string.h>
 +#if HAVE_STDINT_H
 +# include <stdint.h>
 +#endif
 +#if HAVE_STDBOOL_H
 +# include <stdbool.h>
 +#endif
  #define endianflip(A) ((((uint64_t)(A) & 0xff00000000000000LL) >> 56) | \
                         (((uint64_t)(A) & 0x00ff000000000000LL) >> 40) | \
                         (((uint64_t)(A) & 0x0000ff0000000000LL) >> 24) | \
@@@ -723,13 -707,8 +723,13 @@@ if test "x$fp_layout_type" = "xunknown"
        [[[[
  #include <stdlib.h>
  #include <stdio.h>
 -#include <stdint.h>
  #include <string.h>
 +#if HAVE_STDINT_H
 +# include <stdint.h>
 +#endif
 +#if HAVE_STDBOOL_H
 +# include <stdbool.h>
 +#endif
  #define intswap(A)    ((((uint64_t)(A) & 0xffffffff00000000LL) >> 32) | \
                         (((uint64_t)(A) & 0x00000000ffffffffLL) << 32))
        ]]]],
  m4_divert_once([HELP_WITH], [
  collectd additional packages:])
  
 -# AC_ARG_WITH (package, help-string, [action-if-given], [action-if-not-given])
 -librrd_cflags=""
 -librrd_ldflags=""
 -librrd_threadsafe="yes"
 -AC_ARG_WITH(rrdtool, [AS_HELP_STRING([--with-rrdtool@<:@=PREFIX@:>@], [Path to rrdtool.])],
 -[     if test "x$withval" != "xno" && test "x$withval" != "xyes"
 -      then
 -              librrd_cflags="-I$withval/include"
 -              librrd_ldflags="-L$withval/lib"
 -              with_rrdtool="yes"
 -      else
 -              with_rrdtool="$withval"
 -      fi
 -], [with_rrdtool="yes"])
 -if test "x$with_rrdtool" = "xyes"
 -then
 -      SAVE_CPPFLAGS="$CPPFLAGS"
 -      SAVE_LDFLAGS="$LDFLAGS"
 -
 -      CPPFLAGS="$CPPFLAGS $librrd_cflags"
 -      LDFLAGS="$LDFLAGS $librrd_ldflags"
 -
 -      AC_CHECK_HEADERS(rrd.h,, [with_rrdtool="no (rrd.h not found)"])
 -
 -      CPPFLAGS="$SAVE_CPPFLAGS"
 -      LDFLAGS="$SAVE_LDFLAGS"
 -fi
 -if test "x$with_rrdtool" = "xyes"
 -then
 -      SAVE_CPPFLAGS="$CPPFLAGS"
 -      SAVE_LDFLAGS="$LDFLAGS"
 -
 -      CPPFLAGS="$CPPFLAGS $librrd_cflags"
 -      LDFLAGS="$LDFLAGS $librrd_ldflags"
 -
 -      AC_CHECK_LIB(rrd_th, rrd_update_r,
 -      [with_rrdtool="yes"
 -       librrd_ldflags="$librrd_ldflags -lrrd_th -lm"
 -      ],
 -      [librrd_threadsafe="no"
 -       AC_CHECK_LIB(rrd, rrd_update,
 -       [with_rrdtool="yes"
 -        librrd_ldflags="$librrd_ldflags -lrrd -lm"
 -       ],
 -       [with_rrdtool="no (symbol 'rrd_update' not found)"],
 -       [-lm])
 -      ],
 -      [-lm])
 -
 -      CPPFLAGS="$SAVE_CPPFLAGS"
 -      LDFLAGS="$SAVE_LDFLAGS"
 -fi
 -if test "x$with_rrdtool" = "xyes"
 -then
 -      BUILD_WITH_LIBRRD_CFLAGS="$librrd_cflags"
 -      BUILD_WITH_LIBRRD_LDFLAGS="$librrd_ldflags"
 -      AC_SUBST(BUILD_WITH_LIBRRD_CFLAGS)
 -      AC_SUBST(BUILD_WITH_LIBRRD_LDFLAGS)
 -fi
 -if test "x$librrd_threadsafe" = "xyes"
 -then
 -      AC_DEFINE(HAVE_THREADSAFE_LIBRRD, 1, [Define to 1 if you have the threadsafe rrd library (-lrrd_th).])
 -fi
 -
 -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")
 -
  if test "x$ac_system" = "xSolaris"
  then
        with_kstat="yes"
  AM_CONDITIONAL(BUILD_WITH_LIBKSTAT, test "x$with_kstat" = "xyes")
  AM_CONDITIONAL(BUILD_WITH_LIBDEVINFO, test "x$with_devinfo" = "xyes")
  
 -### BEGIN of check for libcurl ###
 +with_libiokit="no"
 +AC_CHECK_LIB(IOKit, IOServiceGetMatchingServices,
 +[
 +      with_libiokit="yes"
 +], 
 +[
 +      with_libiokit="no"
 +])
 +AM_CONDITIONAL(BUILD_WITH_LIBIOKIT, test "x$with_libiokit" = "xyes")
 +
 +with_libkvm="no"
 +AC_CHECK_LIB(kvm, kvm_getprocs, [with_kvm_getprocs="yes"], [with_kvm_getprocs="no"])
 +if test "x$with_kvm_getprocs" = "xyes"
 +then
 +      AC_DEFINE(HAVE_LIBKVM_GETPROCS, 1,
 +                [Define to 1 if you have the 'kvm' library with the 'kvm_getprocs' symbol (-lkvm)])
 +      with_libkvm="yes"
 +fi
 +AM_CONDITIONAL(BUILD_WITH_LIBKVM_GETPROCS, test "x$with_kvm_getprocs" = "xyes")
 +
 +AC_CHECK_LIB(kvm, kvm_getswapinfo, [with_kvm_getswapinfo="yes"], [with_kvm_getswapinfo="no"])
 +if test "x$with_kvm_getswapinfo" = "xyes"
 +then
 +      AC_DEFINE(HAVE_LIBKVM_GETSWAPINFO, 1,
 +                [Define to 1 if you have the 'kvm' library with the 'kvm_getswapinfo' symbol (-lkvm)])
 +      with_libkvm="yes"
 +fi
 +AM_CONDITIONAL(BUILD_WITH_LIBKVM_GETSWAPINFO, test "x$with_kvm_getswapinfo" = "xyes")
 +
 +AC_CHECK_LIB(kvm, kvm_nlist, [with_kvm_nlist="yes"], [with_kvm_nlist="no"])
 +if test "x$with_kvm_nlist" = "xyes"
 +then
 +      AC_DEFINE(HAVE_LIBKVM_NLIST, 1,
 +                [Define to 1 if you have the 'kvm' library with the 'kvm_nlist' symbol (-lkvm)])
 +      with_libkvm="yes"
 +fi
 +AM_CONDITIONAL(BUILD_WITH_LIBKVM_NLIST, test "x$with_kvm_nlist" = "xyes")
 +
 +AC_CHECK_LIB(kvm, kvm_openfiles, [with_kvm_openfiles="yes"], [with_kvm_openfiles="no"])
 +if test "x$with_kvm_openfiles" = "xyes"
 +then
 +      AC_DEFINE(HAVE_LIBKVM_NLIST, 1,
 +                [Define to 1 if you have the 'kvm' library with the 'kvm_openfiles' symbol (-lkvm)])
 +      with_libkvm="yes"
 +fi
 +AM_CONDITIONAL(BUILD_WITH_LIBKVM_OPENFILES, test "x$with_kvm_openfiles" = "xyes")
 +
 +# --with-libcurl {{{
  with_curl_config="curl-config"
  with_curl_cflags=""
  with_curl_libs=""
        AC_SUBST(BUILD_WITH_LIBCURL_LIBS)
  fi
  AM_CONDITIONAL(BUILD_WITH_LIBCURL, test "x$with_libcurl" = "xyes")
 -### END of check for libcurl ###
 -
 -with_libiokit="no"
 -AC_CHECK_LIB(IOKit, IOServiceGetMatchingServices,
 -[
 -      with_libiokit="yes"
 -], 
 -[
 -      with_libiokit="no"
 -])
 -AM_CONDITIONAL(BUILD_WITH_LIBIOKIT, test "x$with_libiokit" = "xyes")
 +# }}}
  
 -with_libstatgrab_cflags=""
 -with_libstatgrab_ldflags=""
 -AC_ARG_WITH(libstatgrab, [AS_HELP_STRING([--with-libstatgrab@<:@=PREFIX@:>@], [Path to libstatgrab.])],
 +# --with-libdbi {{{
 +with_libdbi_cppflags=""
 +with_libdbi_ldflags=""
 +AC_ARG_WITH(libdbi, [AS_HELP_STRING([--with-libdbi@<:@=PREFIX@:>@], [Path to libdbi.])],
  [
 -      if test "x$withval" != "xno" \
 -              && test "x$withval" != "xyes"
 +      if test "x$withval" != "xno" && test "x$withval" != "xyes"
        then
 -              with_libstatgrab_cflags="-I$withval/include"
 -              with_libstatgrab_ldflags="-L$withval/lib"
 -              with_libstatgrab="yes"
 +              with_libdbi_cppflags="-I$withval/include"
 +              with_libdbi_ldflags="-L$withval/lib"
 +              with_libdbi="yes"
        else
 -              with_libstatgrab="$withval"
 +              with_libdbi="$withval"
        fi
  ],
  [
 -      if test "x$ac_system" = "xunknown"
 -      then
 -              with_libstatgrab="yes"
 -      else
 -              with_libstatgrab="no"
 -      fi
 +      with_libdbi="yes"
  ])
 -with_libstatgrab_pkg_config="yes"
 -if test "x$with_libstatgrab" = "xyes" \
 -  && test "x$PKG_CONFIG" != "x"
 -then
 -  AC_MSG_CHECKING([pkg-config for libstatgrab])
 -  temp_result="found"
 -  $PKG_CONFIG --exists libstatgrab 2>/dev/null
 -  if test "$?" != "0"
 -  then
 -    with_libstatgrab_pkg_config="no"
 -    temp_result="not found"
 -  fi
 -  AC_MSG_RESULT([$temp_result])
 -else
 -  AC_MSG_NOTICE([pkg-config not available, trying to guess flags for the statgrab library.])
 -  with_libstatgrab_pkg_config="no"
 -  with_libstatgrab_ldflags="$with_libstatgrab_ldflags -lstatgrab"
 -fi
 -
 -if test "x$with_libstatgrab" = "xyes" \
 -  && test "x$with_libstatgrab_pkg_config" = "xyes" \
 -  && test "x$with_libstatgrab_cflags" = "x"
 -then
 -  AC_MSG_CHECKING([for libstatgrab CFLAGS])
 -  temp_result="`$PKG_CONFIG --cflags libstatgrab`"
 -  if test "$?" = "0"
 -  then
 -    with_libstatgrab_cflags="$temp_result"
 -  else
 -    with_libstatgrab="no ($PKG_CONFIG --cflags libstatgrab failed)"
 -    temp_result="$PKG_CONFIG --cflags libstatgrab failed"
 -  fi
 -  AC_MSG_RESULT([$temp_result])
 -fi
 -
 -if test "x$with_libstatgrab" = "xyes" \
 -  && test "x$with_libstatgrab_pkg_config" = "xyes" \
 -  && test "x$with_libstatgrab_ldflags" = "x"
 -then
 -  AC_MSG_CHECKING([for libstatgrab LDFLAGS])
 -  temp_result="`$PKG_CONFIG --libs libstatgrab`"
 -  if test "$?" = "0"
 -  then
 -    with_libstatgrab_ldflags="$temp_result"
 -  else
 -    with_libstatgrab="no ($PKG_CONFIG --libs libstatgrab failed)"
 -    temp_result="$PKG_CONFIG --libs libstatgrab failed"
 -  fi
 -  AC_MSG_RESULT([$temp_result])
 -fi
 -
 -if test "x$with_libstatgrab" = "xyes"
 +if test "x$with_libdbi" = "xyes"
  then
 -  SAVE_CPPFLAGS="$CPPFLAGS"
 -  CPPFLAGS="$CPPFLAGS $with_libstatgrab_cflags"
 +      SAVE_CPPFLAGS="$CPPFLAGS"
 +      CPPFLAGS="$CPPFLAGS $with_libdbi_cppflags"
  
 -  AC_CHECK_HEADERS(statgrab.h,
 -                 [with_libstatgrab="yes"],
 -                 [with_libstatgrab="no (statgrab.h not found)"])
 +      AC_CHECK_HEADERS(dbi/dbi.h, [with_libdbi="yes"], [with_libdbi="no (dbi/dbi.h not found)"])
  
 -  CPPFLAGS="$SAVE_CPPFLAGS"
 +      CPPFLAGS="$SAVE_CPPFLAGS"
  fi
 -
 -if test "x$with_libstatgrab" = "xyes"
 +if test "x$with_libdbi" = "xyes"
  then
 -  SAVE_CFLAGS="$CFLAGS"
 -  SAVE_LDFLAGS="$LDFLAGS"
 -
 -  CFLAGS="$CFLAGS $with_libstatgrab_cflags"
 -  LDFLAGS="$LDFLAGS $with_libstatgrab_ldflags"
 +      SAVE_CPPFLAGS="$CPPFLAGS"
 +      SAVE_LDFLAGS="$LDFLAGS"
 +      CPPFLAGS="$CPPFLAGS $with_libdbi_cppflags"
 +      LDFLAGS="$LDFLAGS $with_libdbi_ldflags"
  
 -  AC_CHECK_LIB(statgrab, sg_init,
 -             [with_libstatgrab="yes"],
 -             [with_libstatgrab="no (symbol sg_init not found)"])
 +      AC_CHECK_LIB(dbi, dbi_initialize, [with_libdbi="yes"], [with_libdbi="no (Symbol 'dbi_initialize' not found)"])
  
 -  CFLAGS="$SAVE_CFLAGS"
 -  LDFLAGS="$SAVE_LDFLAGS"
 +      CPPFLAGS="$SAVE_CPPFLAGS"
 +      LDFLAGS="$SAVE_LDFLAGS"
  fi
 -
 -AM_CONDITIONAL(BUILD_WITH_LIBSTATGRAB, test "x$with_libstatgrab" = "xyes")
 -if test "x$with_libstatgrab" = "xyes"
 +if test "x$with_libdbi" = "xyes"
  then
 -  AC_DEFINE(HAVE_LIBSTATGRAB, 1, [Define to 1 if you have the 'statgrab' library (-lstatgrab)])
 -  BUILD_WITH_LIBSTATGRAB_CFLAGS="$with_libstatgrab_cflags"
 -  BUILD_WITH_LIBSTATGRAB_LDFLAGS="$with_libstatgrab_ldflags"
 -  AC_SUBST(BUILD_WITH_LIBSTATGRAB_CFLAGS)
 -  AC_SUBST(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
 +      BUILD_WITH_LIBDBI_CPPFLAGS="$with_libdbi_cppflags"
 +      BUILD_WITH_LIBDBI_LDFLAGS="$with_libdbi_ldflags"
 +      BUILD_WITH_LIBDBI_LIBS="-ldbi"
 +      AC_SUBST(BUILD_WITH_LIBDBI_CPPFLAGS)
 +      AC_SUBST(BUILD_WITH_LIBDBI_LDFLAGS)
 +      AC_SUBST(BUILD_WITH_LIBDBI_LIBS)
  fi
 +AM_CONDITIONAL(BUILD_WITH_LIBDBI, test "x$with_libdbi" = "xyes")
 +# }}}
  
 -with_libkvm="no"
 -AC_CHECK_LIB(kvm, kvm_getprocs, [with_kvm_getprocs="yes"], [with_kvm_getprocs="no"])
 -if test "x$with_kvm_getprocs" = "xyes"
 -then
 -      AC_DEFINE(HAVE_LIBKVM_GETPROCS, 1,
 -                [Define to 1 if you have the 'kvm' library with the 'kvm_getprocs' symbol (-lkvm)])
 -      with_libkvm="yes"
 -fi
 -AM_CONDITIONAL(BUILD_WITH_LIBKVM_GETPROCS, test "x$with_kvm_getprocs" = "xyes")
 -
 -AC_CHECK_LIB(kvm, kvm_getswapinfo, [with_kvm_getswapinfo="yes"], [with_kvm_getswapinfo="no"])
 -if test "x$with_kvm_getswapinfo" = "xyes"
 +# --with-libesmtp {{{
 +AC_ARG_WITH(libesmtp, [AS_HELP_STRING([--with-libesmtp@<:@=PREFIX@:>@], [Path to libesmtp.])],
 +[
 +      if test "x$withval" != "xno" && test "x$withval" != "xyes"
 +      then
 +              LDFLAGS="$LDFLAGS -L$withval/lib"
 +              CPPFLAGS="$CPPFLAGS -I$withval/include -D_THREAD_SAFE"
 +              with_libesmtp="yes"
 +      else
 +              with_libesmtp="$withval"
 +      fi
 +],
 +[
 +      with_libesmtp="yes"
 +])
 +if test "x$with_libesmtp" = "xyes"
  then
 -      AC_DEFINE(HAVE_LIBKVM_GETSWAPINFO, 1,
 -                [Define to 1 if you have the 'kvm' library with the 'kvm_getswapinfo' symbol (-lkvm)])
 -      with_libkvm="yes"
 +      AC_CHECK_LIB(esmtp, smtp_create_session,
 +      [
 +              AC_DEFINE(HAVE_LIBESMTP, 1, [Define to 1 if you have the esmtp library (-lesmtp).])
 +      ], [with_libesmtp="no (libesmtp not found)"])
  fi
 -AM_CONDITIONAL(BUILD_WITH_LIBKVM_GETSWAPINFO, test "x$with_kvm_getswapinfo" = "xyes")
 -
 -AC_CHECK_LIB(kvm, kvm_nlist, [with_kvm_nlist="yes"], [with_kvm_nlist="no"])
 -if test "x$with_kvm_nlist" = "xyes"
 +if test "x$with_libesmtp" = "xyes"
  then
 -      AC_DEFINE(HAVE_LIBKVM_NLIST, 1,
 -                [Define to 1 if you have the 'kvm' library with the 'kvm_nlist' symbol (-lkvm)])
 -      with_libkvm="yes"
 +      AC_CHECK_HEADERS(libesmtp.h,
 +      [
 +              AC_DEFINE(HAVE_LIBESMTP_H, 1, [Define to 1 if you have the <libesmtp.h> header file.])
 +      ], [with_libesmtp="no (libesmtp.h not found)"])
  fi
 -AM_CONDITIONAL(BUILD_WITH_LIBKVM_NLIST, test "x$with_kvm_nlist" = "xyes")
 -
 -AC_CHECK_LIB(kvm, kvm_openfiles, [with_kvm_openfiles="yes"], [with_kvm_openfiles="no"])
 -if test "x$with_kvm_openfiles" = "xyes"
 +if test "x$with_libesmtp" = "xyes"
  then
 -      AC_DEFINE(HAVE_LIBKVM_NLIST, 1,
 -                [Define to 1 if you have the 'kvm' library with the 'kvm_openfiles' symbol (-lkvm)])
 -      with_libkvm="yes"
 +      collect_libesmtp=1
 +else
 +      collect_libesmtp=0
  fi
 -AM_CONDITIONAL(BUILD_WITH_LIBKVM_OPENFILES, test "x$with_kvm_openfiles" = "xyes")
 +AC_DEFINE_UNQUOTED(COLLECT_LIBESMTP, [$collect_libesmtp],
 +      [Wether or not to use the esmtp library])
 +AM_CONDITIONAL(BUILD_WITH_LIBESMTP, test "x$with_libesmtp" = "xyes")
 +# }}}
  
 -with_sensors_cflags=""
 -with_sensors_ldflags=""
 -AC_ARG_WITH(lm-sensors, [AS_HELP_STRING([--with-lm-sensors@<:@=PREFIX@:>@], [Path to lm_sensors.])],
 +# --with-libiptc {{{
 +with_own_libiptc="no"
 +AC_ARG_WITH(libiptc, [AS_HELP_STRING([--with-libiptc@<:@=PREFIX@:>@], [Path to libiptc.])],
  [
 -      if test "x$withval" = "xno"
 +      if test "x$withval" != "xno" && test "x$withval" != "xyes"
        then
 -              with_lm_sensors="no"
 +              LDFLAGS="$LDFLAGS -L$withval/lib"
 +              CPPFLAGS="$CPPFLAGS -I$withval/include"
 +              with_libiptc="yes"
        else
 -              with_lm_sensors="yes"
 -              if test "x$withval" != "xyes"
 -              then
 -                      with_sensors_cflags="-I$withval/include"
 -                      with_sensors_ldflags="-L$withval/lib"
 -                      with_lm_sensors="yes"
 -              fi
 +              with_libiptc="$withval"
        fi
  ],
  [
        if test "x$ac_system" = "xLinux"
        then
 -              with_lm_sensors="yes"
 +              with_libiptc="yes"
        else
 -              with_lm_sensors="no (Linux only library)"
 +              with_libiptc="no (Linux only)"
        fi
  ])
 -if test "x$with_lm_sensors" = "xyes"
 +if test "x$with_libiptc" = "xyes"
  then
 -      SAVE_CPPFLAGS="$CPPFLAGS"
 -      CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
 -
 -#     AC_CHECK_HEADERS(sensors/sensors.h,
 -#     [
 -#             AC_DEFINE(HAVE_SENSORS_SENSORS_H, 1, [Define to 1 if you have the <sensors/sensors.h> header file.])
 -#     ],
 -#     [with_lm_sensors="no (sensors/sensors.h not found)"])
 -      AC_CHECK_HEADERS(sensors/sensors.h, [], [with_lm_sensors="no (sensors/sensors.h not found)"])
 -
 -      CPPFLAGS="$SAVE_CPPFLAGS"
 +      AC_CHECK_LIB(iptc, iptc_init,
 +      [
 +              AC_DEFINE(HAVE_LIBIPTC, 1, [Define to 1 if you have the iptc library (-liptc).])
 +      ],
 +      [
 +              with_libiptc="yes"
 +              with_own_libiptc="yes"
 +      ])
  fi
 -if test "x$with_lm_sensors" = "xyes"
 +if test "x$with_libiptc" = "xyes" -a "x$with_own_libiptc" != "xyes"
  then
 -      SAVE_CPPFLAGS="$CPPFLAGS"
 -      SAVE_LDFLAGS="$LDFLAGS"
 -      CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
 -      LDFLAGS="$LDFLAGS $with_sensors_ldflags"
 +      AC_CHECK_HEADERS(libiptc/libiptc.h,
 +      [
 +              AC_DEFINE(HAVE_LIBIPTC_LIBIPTC_H, 1, [Define to 1 if you have the <libiptc/libiptc.h> header file.])
 +      ],
 +      [
 +              with_libiptc="yes"
 +              with_own_libiptc="yes"
 +      ])
 +fi
 +if test "x$with_libiptc" = "xyes"
 +then
 +      SAVE_CFLAGS=$CFLAGS
 +      CFLAGS="$CFLAGS $KERNEL_CFLAGS"
  
 -      AC_CHECK_LIB(sensors, sensors_init,
 +      AC_CHECK_HEADERS(linux/netfilter_ipv4/ip_tables.h linux/netfilter_ipv6/ip6_tables.h, [],
        [
 -              AC_DEFINE(HAVE_LIBSENSORS, 1, [Define to 1 if you have the sensors library (-lsensors).])
 +              with_libiptc="no (Linux iptables headers not found - check KERNEL_DIR)"
 +              with_own_libiptc="no"
        ],
 -      [with_lm_sensors="no (libsensors not found)"])
 +      [
 +#include "$srcdir/src/libiptc/ipt_kernel_headers.h"
 +      ])
  
 -      CPPFLAGS="$SAVE_CPPFLAGS"
 -      LDFLAGS="$SAVE_LDFLAGS"
 +      CFLAGS=$SAVE_CFLAGS
  fi
 -if test "x$with_lm_sensors" = "xyes"
 +AM_CONDITIONAL(BUILD_WITH_LIBIPTC, test "x$with_libiptc" = "xyes")
 +AM_CONDITIONAL(BUILD_WITH_OWN_LIBIPTC, test "x$with_own_libiptc" = "xyes")
 +if test "x$with_own_libiptc" = "xyes"
  then
 -      BUILD_WITH_LIBSENSORS_CFLAGS="$with_sensors_cflags"
 -      BUILD_WITH_LIBSENSORS_LDFLAGS="$with_sensors_ldflags"
 -      AC_SUBST(BUILD_WITH_LIBSENSORS_CFLAGS)
 -      AC_SUBST(BUILD_WITH_LIBSENSORS_LDFLAGS)
 +      AC_DEFINE(OWN_LIBIPTC, 1, [Define to 1 if we use the shipped iptc library.])
  fi
 -AM_CONDITIONAL(BUILD_WITH_LM_SENSORS, test "x$with_lm_sensors" = "xyes")
 +# }}}
  
 +# --with-libmysql {{{
  with_mysql_config="mysql_config"
  with_mysql_cflags=""
  with_mysql_libs=""
        AC_SUBST(BUILD_WITH_LIBMYSQL_LIBS)
  fi
  AM_CONDITIONAL(BUILD_WITH_LIBMYSQL, test "x$with_libmysql" = "xyes")
 +# }}}
  
 -with_own_liboconfig="no"
 -liboconfig_LDFLAGS="$LDFLAGS"
 -liboconfig_CPPFLAGS="$CPPFLAGS"
 -AC_ARG_WITH(liboconfig, [AS_HELP_STRING([--with-liboconfig@<:@=PREFIX@:>@], [Path to liboconfig.])],
 -[
 -      if test "x$withval" != "xno" && test "x$withval" != "xyes"
 -      then
 -              if test -d "$withval/lib"
 -              then
 -                      liboconfig_LDFLAGS="$LDFLAGS -L$withval/lib"
 -              fi
 -              if test -d "$withval/include"
 -              then
 -                      liboconfig_CPPFLAGS="$CPPFLAGS -I$withval/include"
 -              fi
 -      fi
 -      if test "x$withval" = "xno"
 -      then
 -              AC_MSG_ERROR("liboconfig is required")
 -      fi
 -],
 -[
 -      with_liboconfig="yes"
 -])
 -
 -save_LDFLAGS="$LDFLAGS"
 -save_CPPFLAGS="$CPPFLAGS"
 -LDFLAGS="$liboconfig_LDFLAGS"
 -CPPFLAGS="$liboconfig_CPPFLAGS"
 -AC_CHECK_LIB(oconfig, oconfig_parse_fh,
 +# --with-libnetlink {{{
 +with_libnetlink_cflags=""
 +with_libnetlink_libs="-lnetlink"
 +AC_ARG_WITH(libnetlink, [AS_HELP_STRING([--with-libnetlink@<:@=PREFIX@:>@], [Path to libnetlink.])],
  [
 -      with_liboconfig="yes"
 -      with_own_liboconfig="no"
 + echo "libnetlink: withval = $withval"
 + if test "x$withval" = "xyes"
 + then
 +       with_libnetlink="yes"
 + else if test "x$withval" = "xno"
 + then
 +       with_libnetlink="no"
 + else
 +       if test -d "$withval/include"
 +       then
 +               with_libnetlink_cflags="-I$withval/include"
 +               with_libnetlink_libs="-L$withval/lib -lnetlink"
 +               with_libnetlink="yes"
 +       else
 +               AC_MSG_ERROR("no such directory: $withval/include")
 +       fi
 + fi; fi
  ],
  [
 -      with_liboconfig="yes"
 -      with_own_liboconfig="yes"
 -      LDFLAGS="$save_LDFLAGS"
 -      CPPFLAGS="$save_CPPFLAGS"
 + if test "x$ac_system" = "xLinux"
 + then
 +       with_libnetlink="yes"
 + else
 +       with_libnetlink="no (Linux only library)"
 + fi
  ])
 -
 -AM_CONDITIONAL(BUILD_WITH_OWN_LIBOCONFIG, test "x$with_own_liboconfig" = "xyes")
 -if test "x$with_own_liboconfig" = "xyes"
 +if test "x$with_libnetlink" = "xyes"
  then
 -      with_liboconfig="yes (shipped version)"
 -fi
 +      SAVE_CFLAGS=$CFLAGS
 +      CFLAGS="$CFLAGS $with_libnetlink_cflags"
  
 -#with_liboping="yes"
 -with_own_liboping="no"
 -liboping_LDFLAGS="$LDFLAGS"
 -liboping_CPPFLAGS="$CPPFLAGS"
 -AC_ARG_WITH(liboping, [AS_HELP_STRING([--with-liboping@<:@=PREFIX@:>@], [Path to liboping.])],
 -[
 -      if test "x$withval" != "xno" && test "x$withval" != "xyes"
 -      then
 -              if test -d "$withval/lib"
 -              then
 -                      liboping_LDFLAGS="$LDFLAGS -L$withval/lib"
 -              fi
 -              if test -d "$withval/include"
 -              then
 -                      liboping_CPPFLAGS="$CPPFLAGS -I$withval/include"
 -              fi
 -      fi
 -      if test "x$withval" = "xno"
 -      then
 -              with_liboping="no"
 -              with_own_liboping="no"
 -      else if test "x$withval" = "xyes"
 -      then
 -              with_liboping="yes"
 -      fi; fi
 -],
 -[
 -      with_liboping="yes"
 -])
 +      with_libnetlink="no (libnetlink.h not found)"
  
 -if test "x$with_liboping" = "xyes"
 -then
 -      save_LDFLAGS="$LDFLAGS"
 -      save_CPPFLAGS="$CPPFLAGS"
 -      LDFLAGS="$liboping_LDFLAGS"
 -      CPPFLAGS="$liboping_CPPFLAGS"
 -      AC_CHECK_LIB(oping, ping_construct,
 -      [
 -              with_liboping="yes"
 -              with_own_liboping="no"
 -      ],
 +      AC_CHECK_HEADERS(libnetlink.h iproute/libnetlink.h linux/libnetlink.h,
        [
 -              with_liboping="yes"
 -              with_own_liboping="yes"
 -              LDFLAGS="$save_LDFLAGS"
 -              CPPFLAGS="$save_CPPFLAGS"
 -      ])
 -fi
 -AM_CONDITIONAL(BUILD_WITH_LIBOPING, test "x$with_liboping" = "xyes")
 -AM_CONDITIONAL(BUILD_WITH_OWN_LIBOPING, test "x$with_own_liboping" = "xyes")
 -
 -with_libowcapi_cppflags=""
 -with_libowcapi_libs="-lowcapi"
 -AC_ARG_WITH(libowcapi, [AS_HELP_STRING([--with-libowcapi@<:@=PREFIX@:>@], [Path to libowcapi.])],
 -[
 -      if test "x$withval" != "xno" && test "x$withval" != "xyes"
 -      then
 -              with_libowcapi_cppflags="-I$withval/include"
 -              with_libowcapi_libs="-L$withval/lib -lowcapi"
 -              with_libowcapi="yes"
 -      else
 -              with_libowcapi="$withval"
 -      fi
 -],
 -[
 -      with_libowcapi="yes"
 -])
 -if test "x$with_libowcapi" = "xyes"
 -then
 -      SAVE_CPPFLAGS="$CPPFLAGS"
 -      CPPFLAGS="$with_libowcapi_cppflags"
 -      
 -      AC_CHECK_HEADERS(owcapi.h, [with_libowcapi="yes"], [with_libowcapi="no (owcapi.h not found)"])
 +       with_libnetlink="yes"
 +       break
 +      ], [],
 +[#include <stdio.h>
 +#include <sys/types.h>
 +#include <asm/types.h>
 +#include <sys/socket.h>
 +#include <linux/netlink.h>
 +#include <linux/rtnetlink.h>])
 +      AC_CHECK_HEADERS(linux/gen_stats.h linux/pkt_sched.h, [], [],
 +[#include <stdio.h>
 +#include <sys/types.h>
 +#include <asm/types.h>
 +#include <sys/socket.h>])
  
 -      CPPFLAGS="$SAVE_CPPFLAGS"
 +      AC_COMPILE_IFELSE(
 +[#include <stdio.h>
 +#include <sys/types.h>
 +#include <asm/types.h>
 +#include <sys/socket.h>
 +#include <linux/netlink.h>
 +#include <linux/rtnetlink.h>
 +
 +int main (void)
 +{
 +      int retval = TCA_STATS2;
 +      return (retval);
 +}],
 +      [AC_DEFINE([HAVE_TCA_STATS2], 1, [True if the enum-member TCA_STATS2 exists])]
 +      []);
 +
 +      AC_COMPILE_IFELSE(
 +[#include <stdio.h>
 +#include <sys/types.h>
 +#include <asm/types.h>
 +#include <sys/socket.h>
 +#include <linux/netlink.h>
 +#include <linux/rtnetlink.h>
 +
 +int main (void)
 +{
 +      int retval = TCA_STATS;
 +      return (retval);
 +}],
 +      [AC_DEFINE([HAVE_TCA_STATS], 1, [True if the enum-member TCA_STATS exists])]
 +      []);
 +
 +      CFLAGS="$SAVE_CFLAGS"
  fi
 -if test "x$with_libowcapi" = "xyes"
 +if test "x$with_libnetlink" = "xyes"
  then
 -      SAVE_LDFLAGS="$LDFLAGS"
 -      SAVE_CPPFLAGS="$CPPFLAGS"
 -      LDFLAGS="$with_libowcapi_libs"
 -      CPPFLAGS="$with_libowcapi_cppflags"
 -      
 -      AC_CHECK_LIB(owcapi, OW_get, [with_libowcapi="yes"], [with_libowcapi="no (libowcapi not found)"])
 -
 -      LDFLAGS="$SAVE_LDFLAGS"
 -      CPPFLAGS="$SAVE_CPPFLAGS"
 +      AC_CHECK_LIB(netlink, rtnl_open,
 +                   [with_libnetlink="yes"],
 +                   [with_libnetlink="no (symbol 'rtnl_open' not found)"],
 +                   [$with_libnetlink_libs])
  fi
 -if test "x$with_libowcapi" = "xyes"
 +if test "x$with_libnetlink" = "xyes"
  then
 -      BUILD_WITH_LIBOWCAPI_CPPFLAGS="$with_libowcapi_cppflags"
 -      BUILD_WITH_LIBOWCAPI_LIBS="$with_libowcapi_libs"
 -      AC_SUBST(BUILD_WITH_LIBOWCAPI_CPPFLAGS)
 -      AC_SUBST(BUILD_WITH_LIBOWCAPI_LIBS)
 +      BUILD_WITH_LIBNETLINK_CFLAGS="$with_libnetlink_cflags"
 +      BUILD_WITH_LIBNETLINK_LIBS="$with_libnetlink_libs"
 +      AC_SUBST(BUILD_WITH_LIBNETLINK_CFLAGS)
 +      AC_SUBST(BUILD_WITH_LIBNETLINK_LIBS)
  fi
 +AM_CONDITIONAL(BUILD_WITH_LIBNETLINK, test "x$with_libnetlink" = "xyes")
 +# }}}
  
 -
 -AC_ARG_WITH(libpcap, [AS_HELP_STRING([--with-libpcap@<:@=PREFIX@:>@], [Path to libpcap.])],
 +# --with-libnetsnmp {{{
 +with_snmp_config="net-snmp-config"
 +with_snmp_cflags=""
 +with_snmp_libs=""
 +AC_ARG_WITH(libnetsnmp, [AS_HELP_STRING([--with-libnetsnmp@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
  [
 -      if test "x$withval" != "xno" && test "x$withval" != "xyes"
 +      if test "x$withval" = "xno"
        then
 -              LDFLAGS="$LDFLAGS -L$withval/lib"
 -              CPPFLAGS="$CPPFLAGS -I$withval/include"
 -              with_libpcap="yes"
 +              with_libnetsnmp="no"
 +      else if test "x$withval" = "xyes"
 +      then
 +              with_libnetsnmp="yes"
        else
 -              with_libpcap="$withval"
 -      fi
 +              if test -x "$withval"
 +              then
 +                      with_snmp_config="$withval"
 +                      with_libnetsnmp="yes"
 +              else
 +                      with_snmp_config="$withval/bin/net-snmp-config"
 +                      with_libnetsnmp="yes"
 +              fi
 +      fi; fi
  ],
 -[
 -      with_libpcap="yes"
 -])
 -if test "x$with_libpcap" = "xyes"
 +[with_libnetsnmp="yes"])
 +if test "x$with_libnetsnmp" = "xyes"
  then
 -      AC_CHECK_LIB(pcap, pcap_open_live,
 -      [
 -              AC_DEFINE(HAVE_LIBPCAP, 1, [Define to 1 if you have the pcap library (-lpcap).])
 -      ], [with_libpcap="no (libpcap not found)"])
 +      with_snmp_cflags=`$with_snmp_config --cflags 2>/dev/null`
 +      snmp_config_status=$?
 +
 +      if test $snmp_config_status -ne 0
 +      then
 +              with_libnetsnmp="no ($with_snmp_config failed)"
 +      else
 +              SAVE_CPPFLAGS="$CPPFLAGS"
 +              CPPFLAGS="$CPPFLAGS $with_snmp_cflags"
 +              
 +              AC_CHECK_HEADERS(net-snmp/net-snmp-config.h, [], [with_libnetsnmp="no (net-snmp/net-snmp-config.h not found)"])
 +
 +              CPPFLAGS="$SAVE_CPPFLAGS"
 +      fi
  fi
 -if test "x$with_libpcap" = "xyes"
 +if test "x$with_libnetsnmp" = "xyes"
  then
 -      AC_CHECK_HEADERS(pcap.h,
 -      [
 -              AC_DEFINE(HAVE_PCAP_H, 1, [Define to 1 if you have the <pcap.h> header file.])
 -      ], [with_libpcap="no (pcap.h not found)"])
 +      with_snmp_libs=`$with_snmp_config --libs 2>/dev/null`
 +      snmp_config_status=$?
 +
 +      if test $snmp_config_status -ne 0
 +      then
 +              with_libnetsnmp="no ($with_snmp_config failed)"
 +      else
 +              AC_CHECK_LIB(netsnmp, init_snmp,
 +              [with_libnetsnmp="yes"],
 +              [with_libnetsnmp="no (libnetsnmp not found)"],
 +              [$with_snmp_libs])
 +      fi
  fi
 -if test "x$with_libpcap" = "xyes"
 +if test "x$with_libnetsnmp" = "xyes"
  then
 -      collect_libpcap=1
 -else
 -      collect_libpcap=0
 +      BUILD_WITH_LIBSNMP_CFLAGS="$with_snmp_cflags"
 +      BUILD_WITH_LIBSNMP_LIBS="$with_snmp_libs"
 +      AC_SUBST(BUILD_WITH_LIBSNMP_CFLAGS)
 +      AC_SUBST(BUILD_WITH_LIBSNMP_LIBS)
  fi
 -AC_DEFINE_UNQUOTED(COLLECT_LIBPCAP, [$collect_libpcap],
 -      [Wether or not to use the pcap library])
 -AM_CONDITIONAL(BUILD_WITH_LIBPCAP, test "x$with_libpcap" = "xyes")
 +AM_CONDITIONAL(BUILD_WITH_LIBNETSNMP, test "x$with_libnetsnmp" = "xyes")
 +# }}}
  
 -AC_ARG_WITH(libesmtp, [AS_HELP_STRING([--with-libesmtp@<:@=PREFIX@:>@], [Path to libesmtp.])],
 +# --with-liboconfig {{{
 +with_own_liboconfig="no"
 +liboconfig_LDFLAGS="$LDFLAGS"
 +liboconfig_CPPFLAGS="$CPPFLAGS"
 +AC_ARG_WITH(liboconfig, [AS_HELP_STRING([--with-liboconfig@<:@=PREFIX@:>@], [Path to liboconfig.])],
  [
        if test "x$withval" != "xno" && test "x$withval" != "xyes"
        then
 -              LDFLAGS="$LDFLAGS -L$withval/lib"
 -              CPPFLAGS="$CPPFLAGS -I$withval/include -D_THREAD_SAFE"
 -              with_libesmtp="yes"
 -      else
 -              with_libesmtp="$withval"
 +              if test -d "$withval/lib"
 +              then
 +                      liboconfig_LDFLAGS="$LDFLAGS -L$withval/lib"
 +              fi
 +              if test -d "$withval/include"
 +              then
 +                      liboconfig_CPPFLAGS="$CPPFLAGS -I$withval/include"
 +              fi
 +      fi
 +      if test "x$withval" = "xno"
 +      then
 +              AC_MSG_ERROR("liboconfig is required")
        fi
  ],
  [
 -      with_libesmtp="yes"
 +      with_liboconfig="yes"
  ])
 -if test "x$with_libesmtp" = "xyes"
 -then
 -      AC_CHECK_LIB(esmtp, smtp_create_session,
 -      [
 -              AC_DEFINE(HAVE_LIBESMTP, 1, [Define to 1 if you have the esmtp library (-lesmtp).])
 -      ], [with_libesmtp="no (libesmtp not found)"])
 -fi
 -if test "x$with_libesmtp" = "xyes"
 -then
 -      AC_CHECK_HEADERS(libesmtp.h,
 -      [
 -              AC_DEFINE(HAVE_LIBESMTP_H, 1, [Define to 1 if you have the <libesmtp.h> header file.])
 -      ], [with_libesmtp="no (libesmtp.h not found)"])
 -fi
 -if test "x$with_libesmtp" = "xyes"
 -then
 -      collect_libesmtp=1
 -else
 -      collect_libesmtp=0
 -fi
 -AC_DEFINE_UNQUOTED(COLLECT_LIBESMTP, [$collect_libesmtp],
 -      [Wether or not to use the esmtp library])
 -AM_CONDITIONAL(BUILD_WITH_LIBESMTP, test "x$with_libesmtp" = "xyes")
  
 -perl_interpreter="perl"
 -AC_ARG_WITH(libperl, [AS_HELP_STRING([--with-libperl@<:@=PREFIX@:>@], [Path to libperl.])],
 +save_LDFLAGS="$LDFLAGS"
 +save_CPPFLAGS="$CPPFLAGS"
 +LDFLAGS="$liboconfig_LDFLAGS"
 +CPPFLAGS="$liboconfig_CPPFLAGS"
 +AC_CHECK_LIB(oconfig, oconfig_parse_fh,
  [
 -      if test -x "$withval"
 -      then
 -              perl_interpreter="$withval"
 -              with_libperl="yes"
 -      else if test "x$withval" != "xno" && test "x$withval" != "xyes"
 -      then
 -              LDFLAGS="$LDFLAGS -L$withval/lib"
 -              CPPFLAGS="$CPPFLAGS -I$withval/include"
 -              perl_interpreter="$withval/bin/perl"
 -              with_libperl="yes"
 -      else
 -              with_libperl="$withval"
 -      fi; fi
 +      with_liboconfig="yes"
 +      with_own_liboconfig="no"
  ],
  [
 -      with_libperl="yes"
 +      with_liboconfig="yes"
 +      with_own_liboconfig="yes"
 +      LDFLAGS="$save_LDFLAGS"
 +      CPPFLAGS="$save_CPPFLAGS"
  ])
  
 -AC_MSG_CHECKING([for perl])
 -perl_interpreter=`which "$perl_interpreter" 2> /dev/null`
 -if test -x "$perl_interpreter"
 +AM_CONDITIONAL(BUILD_WITH_OWN_LIBOCONFIG, test "x$with_own_liboconfig" = "xyes")
 +if test "x$with_own_liboconfig" = "xyes"
  then
 -      AC_MSG_RESULT([yes ($perl_interpreter)])
 -else
 -      perl_interpreter=""
 -      AC_MSG_RESULT([no])
 +      with_liboconfig="yes (shipped version)"
  fi
 +# }}}
 +
 +# --with-liboping {{{
 +with_own_liboping="no"
 +liboping_LDFLAGS="$LDFLAGS"
 +liboping_CPPFLAGS="$CPPFLAGS"
 +AC_ARG_WITH(liboping, [AS_HELP_STRING([--with-liboping@<:@=PREFIX@:>@], [Path to liboping.])],
 +[
 +      if test "x$withval" != "xno" && test "x$withval" != "xyes"
 +      then
 +              if test -d "$withval/lib"
 +              then
 +                      liboping_LDFLAGS="$LDFLAGS -L$withval/lib"
 +              fi
 +              if test -d "$withval/include"
 +              then
 +                      liboping_CPPFLAGS="$CPPFLAGS -I$withval/include"
 +              fi
 +      fi
 +      if test "x$withval" = "xno"
 +      then
 +              with_liboping="no"
 +              with_own_liboping="no"
 +      else if test "x$withval" = "xyes"
 +      then
 +              with_liboping="yes"
 +      fi; fi
 +],
 +[
 +      with_liboping="yes"
 +])
 +
 +if test "x$with_liboping" = "xyes"
 +then
 +      save_LDFLAGS="$LDFLAGS"
 +      save_CPPFLAGS="$CPPFLAGS"
 +      LDFLAGS="$liboping_LDFLAGS"
 +      CPPFLAGS="$liboping_CPPFLAGS"
 +      AC_CHECK_LIB(oping, ping_construct,
 +      [
 +              with_liboping="yes"
 +              with_own_liboping="no"
 +      ],
 +      [
 +              with_liboping="yes"
 +              with_own_liboping="yes"
 +              LDFLAGS="$save_LDFLAGS"
 +              CPPFLAGS="$save_CPPFLAGS"
 +      ])
 +fi
 +AM_CONDITIONAL(BUILD_WITH_LIBOPING, test "x$with_liboping" = "xyes")
 +AM_CONDITIONAL(BUILD_WITH_OWN_LIBOPING, test "x$with_own_liboping" = "xyes")
 +# }}}
 +
 +# --with-oracle {{{
 +with_oracle_cppflags=""
 +with_oracle_libs=""
 +AC_ARG_WITH(oracle, [AS_HELP_STRING([--with-oracle@<:@=ORACLE_HOME@:>@], [Path to Oracle.])],
 +[
 +      if test "x$withval" = "xyes"
 +      then
 +              if test "x$ORACLE_HOME" = "x"
 +              then
 +                      AC_MSG_WARN([Use of the Oracle library has been forced, but the environment variable ORACLE_HOME is not set.])
 +              fi
 +              with_oracle="yes"
 +      else if test "x$withval" = "xno"
 +      then
 +              with_oracle="no"
 +      else
 +              with_oracle="yes"
 +              ORACLE_HOME="$withval"
 +      fi; fi
 +],
 +[
 +      if test "x$ORACLE_HOME" = "x"
 +      then
 +              with_oracle="no (ORACLE_HOME is not set)"
 +      else
 +              with_oracle="yes"
 +      fi
 +])
 +if test "x$ORACLE_HOME" != "x"
 +then
 +      with_oracle_cppflags="-I$ORACLE_HOME/rdbms/public"
 +
 +      if test -e "$ORACLE_HOME/lib/ldflags"
 +      then
 +              with_oracle_libs=`cat "$ORACLE_HOME/lib/ldflags"`
 +      fi
 +      #with_oracle_libs="-L$ORACLE_HOME/lib $with_oracle_libs -lclntsh"
 +      with_oracle_libs="-L$ORACLE_HOME/lib -lclntsh"
 +fi
 +if test "x$with_oracle" = "xyes"
 +then
 +      SAVE_CPPFLAGS="$CPPFLAGS"
 +      CPPFLAGS="$CPPFLAGS $with_oracle_cppflags"
 +
 +      AC_CHECK_HEADERS(oci.h, [with_oracle="yes"], [with_oracle="no (oci.h not found)"])
 +
 +      CPPFLAGS="$SAVE_CPPFLAGS"
 +fi
 +if test "x$with_oracle" = "xyes"
 +then
 +      SAVE_CPPFLAGS="$CPPFLAGS"
 +      SAVE_LDFLAGS="$LDFLAGS"
 +      CPPFLAGS="$CPPFLAGS $with_oracle_cppflags"
 +      LDFLAGS="$LDFLAGS $with_oracle_libs"
 +
 +      AC_CHECK_FUNC(OCIEnvCreate, [with_oracle="yes"], [with_oracle="no (Symbol 'OCIEnvCreate' not found)"])
 +
 +      CPPFLAGS="$SAVE_CPPFLAGS"
 +      LDFLAGS="$SAVE_LDFLAGS"
 +fi
 +if test "x$with_oracle" = "xyes"
 +then
 +      BUILD_WITH_ORACLE_CFLAGS="$with_oracle_cppflags"
 +      BUILD_WITH_ORACLE_LIBS="$with_oracle_libs"
 +      AC_SUBST(BUILD_WITH_ORACLE_CFLAGS)
 +      AC_SUBST(BUILD_WITH_ORACLE_LIBS)
 +fi
 +# }}}
 +
 +# --with-libowcapi {{{
 +with_libowcapi_cppflags=""
 +with_libowcapi_libs="-lowcapi"
 +AC_ARG_WITH(libowcapi, [AS_HELP_STRING([--with-libowcapi@<:@=PREFIX@:>@], [Path to libowcapi.])],
 +[
 +      if test "x$withval" != "xno" && test "x$withval" != "xyes"
 +      then
 +              with_libowcapi_cppflags="-I$withval/include"
 +              with_libowcapi_libs="-L$withval/lib -lowcapi"
 +              with_libowcapi="yes"
 +      else
 +              with_libowcapi="$withval"
 +      fi
 +],
 +[
 +      with_libowcapi="yes"
 +])
 +if test "x$with_libowcapi" = "xyes"
 +then
 +      SAVE_CPPFLAGS="$CPPFLAGS"
 +      CPPFLAGS="$with_libowcapi_cppflags"
 +      
 +      AC_CHECK_HEADERS(owcapi.h, [with_libowcapi="yes"], [with_libowcapi="no (owcapi.h not found)"])
 +
 +      CPPFLAGS="$SAVE_CPPFLAGS"
 +fi
 +if test "x$with_libowcapi" = "xyes"
 +then
 +      SAVE_LDFLAGS="$LDFLAGS"
 +      SAVE_CPPFLAGS="$CPPFLAGS"
 +      LDFLAGS="$with_libowcapi_libs"
 +      CPPFLAGS="$with_libowcapi_cppflags"
 +      
 +      AC_CHECK_LIB(owcapi, OW_get, [with_libowcapi="yes"], [with_libowcapi="no (libowcapi not found)"])
 +
 +      LDFLAGS="$SAVE_LDFLAGS"
 +      CPPFLAGS="$SAVE_CPPFLAGS"
 +fi
 +if test "x$with_libowcapi" = "xyes"
 +then
 +      BUILD_WITH_LIBOWCAPI_CPPFLAGS="$with_libowcapi_cppflags"
 +      BUILD_WITH_LIBOWCAPI_LIBS="$with_libowcapi_libs"
 +      AC_SUBST(BUILD_WITH_LIBOWCAPI_CPPFLAGS)
 +      AC_SUBST(BUILD_WITH_LIBOWCAPI_LIBS)
 +fi
 +# }}}
 +
 +# --with-libpcap {{{
 +AC_ARG_WITH(libpcap, [AS_HELP_STRING([--with-libpcap@<:@=PREFIX@:>@], [Path to libpcap.])],
 +[
 +      if test "x$withval" != "xno" && test "x$withval" != "xyes"
 +      then
 +              LDFLAGS="$LDFLAGS -L$withval/lib"
 +              CPPFLAGS="$CPPFLAGS -I$withval/include"
 +              with_libpcap="yes"
 +      else
 +              with_libpcap="$withval"
 +      fi
 +],
 +[
 +      with_libpcap="yes"
 +])
 +if test "x$with_libpcap" = "xyes"
 +then
 +      AC_CHECK_LIB(pcap, pcap_open_live,
 +      [
 +              AC_DEFINE(HAVE_LIBPCAP, 1, [Define to 1 if you have the pcap library (-lpcap).])
 +      ], [with_libpcap="no (libpcap not found)"])
 +fi
 +if test "x$with_libpcap" = "xyes"
 +then
 +      AC_CHECK_HEADERS(pcap.h,
 +      [
 +              AC_DEFINE(HAVE_PCAP_H, 1, [Define to 1 if you have the <pcap.h> header file.])
 +      ], [with_libpcap="no (pcap.h not found)"])
 +fi
 +if test "x$with_libpcap" = "xyes"
 +then
 +      collect_libpcap=1
 +else
 +      collect_libpcap=0
 +fi
 +AC_DEFINE_UNQUOTED(COLLECT_LIBPCAP, [$collect_libpcap],
 +      [Wether or not to use the pcap library])
 +AM_CONDITIONAL(BUILD_WITH_LIBPCAP, test "x$with_libpcap" = "xyes")
 +# }}}
 +
 +# --with-libpcre {{{
 +with_pcre_config="pcre-config"
 +with_pcre_cflags=""
 +with_pcre_libs=""
 +AC_ARG_WITH(libpcre, [AS_HELP_STRING([--with-libpcre@<:@=PREFIX@:>@],
 +      [Path to libpcre.])],
 +      [
 +              if test "x$withval" = "xno"
 +              then
 +                      with_libpcre="no"
 +              else if test "x$withval" = "xyes"
 +              then
 +                      with_libpcre="yes"
 +              else
 +                      if test -f "$withval" && test -x "$withval"
 +                      then
 +                              with_pcre_config="$withval"
 +                      else if test -x "$withval/bin/pcre-config"
 +                      then
 +                              with_pcre_config="$withval/bin/pcre-config"
 +                      fi; fi
 +                      with_libpcre="yes"
 +              fi; fi
 +      ],
 +      [
 +              with_libpcre="yes"
 +      ])
 +
 +if test "x$with_libpcre" = "xyes"
 +then
 +      with_pcre_cflags=`$with_pcre_config --cflags 2>/dev/null`
 +      pcre_config_status=$?
 +
 +      if test $pcre_config_status -ne 0
 +      then
 +              with_libpcre="no ($with_pcre_config failed)"
 +      else
 +              SAVE_CPPFLAGS="$CPPFLAGS"
 +              CPPFLAGS="$CPPFLAGS $with_pcre_cflags"
 +
 +              AC_CHECK_HEADERS(pcre.h, [], [with_libpcre="no (pcre.h not found)"], [])
 +
 +              CPPFLAGS="$SAVE_CPPFLAGS"
 +      fi
 +fi
 +
 +if test "x$with_libpcre" = "xyes"
 +then
 +      with_pcre_libs=`$with_pcre_config --libs 2>/dev/null`
 +      pcre_config_status=$?
 +
 +      if test $pcre_config_status -ne 0
 +      then
 +              with_libpcre="no ($with_pcre_config failed)"
 +      else
 +              AC_CHECK_LIB(pcre, pcre_compile,
 +                      [with_libpcre="yes"],
 +                      [with_libpcre="no (symbol 'pcre_compile' not found)"],
 +                      [$with_pcre_libs])
 +      fi
 +fi
 +
 +if test "x$with_libpcre" = "xyes"
 +then
 +      BUILD_WITH_LIBPCRE_CFLAGS="$with_pcre_cflags"
 +      BUILD_WITH_LIBPCRE_LIBS="$with_pcre_libs"
 +      AC_SUBST(BUILD_WITH_LIBPCRE_CFLAGS)
 +      AC_SUBST(BUILD_WITH_LIBPCRE_LIBS)
 +fi
 +AM_CONDITIONAL(BUILD_WITH_LIBPCRE, test "x$with_libpcre" = "xyes")
 +# }}}
 +
 +# --with-libperl {{{
 +perl_interpreter="perl"
 +AC_ARG_WITH(libperl, [AS_HELP_STRING([--with-libperl@<:@=PREFIX@:>@], [Path to libperl.])],
 +[
 +      if test -x "$withval"
 +      then
 +              perl_interpreter="$withval"
 +              with_libperl="yes"
 +      else if test "x$withval" != "xno" && test "x$withval" != "xyes"
 +      then
 +              LDFLAGS="$LDFLAGS -L$withval/lib"
 +              CPPFLAGS="$CPPFLAGS -I$withval/include"
 +              perl_interpreter="$withval/bin/perl"
 +              with_libperl="yes"
 +      else
 +              with_libperl="$withval"
 +      fi; fi
 +],
 +[
 +      with_libperl="yes"
 +])
 +
 +AC_MSG_CHECKING([for perl])
 +perl_interpreter=`which "$perl_interpreter" 2> /dev/null`
 +if test -x "$perl_interpreter"
 +then
 +      AC_MSG_RESULT([yes ($perl_interpreter)])
 +else
 +      perl_interpreter=""
 +      AC_MSG_RESULT([no])
 +fi
 +
 +AC_SUBST(PERL, "$perl_interpreter")
  
 -AC_SUBST(PERL, "$perl_interpreter")
 -
  if test "x$with_libperl" = "xyes" \
        && test -n "$perl_interpreter"
  then
        LDFLAGS=$SAVE_LDFLAGS
  fi
  
 -with_own_libiptc="no"
 -AC_ARG_WITH(libiptc, [AS_HELP_STRING([--with-libiptc@<:@=PREFIX@:>@], [Path to libiptc.])],
 -[
 -      if test "x$withval" != "xno" && test "x$withval" != "xyes"
 -      then
 -              LDFLAGS="$LDFLAGS -L$withval/lib"
 -              CPPFLAGS="$CPPFLAGS -I$withval/include"
 -              with_libiptc="yes"
 -      else
 -              with_libiptc="$withval"
 -      fi
 -],
 -[
 -      if test "x$ac_system" = "xLinux"
 -      then
 -              with_libiptc="yes"
 -      else
 -              with_libiptc="no (Linux only)"
 -      fi
 -])
 -if test "x$with_libiptc" = "xyes"
 -then
 -      AC_CHECK_LIB(iptc, iptc_init,
 -      [
 -              AC_DEFINE(HAVE_LIBIPTC, 1, [Define to 1 if you have the iptc library (-liptc).])
 -      ],
 -      [
 -              with_libiptc="yes"
 -              with_own_libiptc="yes"
 -      ])
 -fi
 -if test "x$with_libiptc" = "xyes" -a "x$with_own_libiptc" != "xyes"
 -then
 -      AC_CHECK_HEADERS(libiptc/libiptc.h,
 -      [
 -              AC_DEFINE(HAVE_LIBIPTC_LIBIPTC_H, 1, [Define to 1 if you have the <libiptc/libiptc.h> header file.])
 -      ],
 -      [
 -              with_libiptc="yes"
 -              with_own_libiptc="yes"
 -      ])
 -fi
 -if test "x$with_libiptc" = "xyes"
 +have_broken_perl_load_module="no"
 +if test "x$with_libperl" = "xyes"
  then
        SAVE_CFLAGS=$CFLAGS
 -      CFLAGS="$CFLAGS $KERNEL_CFLAGS"
 +      SAVE_LDFLAGS=$LDFLAGS
 +      # trigger an error if Perl_load_module*() uses __attribute__nonnull__(3)
 +      # (see issues #41 and #42)
 +      CFLAGS="$CFLAGS $PERL_CFLAGS -Wall -Werror"
 +      LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
  
 -      AC_CHECK_HEADERS(linux/netfilter_ipv4/ip_tables.h linux/netfilter_ipv6/ip6_tables.h, [],
 -      [
 -              with_libiptc="no (Linux iptables headers not found - check KERNEL_DIR)"
 -              with_own_libiptc="no"
 -      ],
 -      [
 -#include "$srcdir/src/libiptc/ipt_kernel_headers.h"
 -      ])
 +      AC_CACHE_CHECK([for broken Perl_load_module()],
 +              [have_broken_perl_load_module],
 +              AC_LINK_IFELSE(
 +                      AC_LANG_PROGRAM(
 +                      [[
 +#define PERL_NO_GET_CONTEXT
 +#include <EXTERN.h>
 +#include <perl.h>
 +#include <XSUB.h>
 +                      ]],
 +                      [[
 +                       dTHX;
 +                       load_module (PERL_LOADMOD_NOIMPORT,
 +                           newSVpv ("Collectd::Plugin::FooBar", 24),
 +                           Nullsv);
 +                      ]]),
 +                      [have_broken_perl_load_module="no"],
 +                      [have_broken_perl_load_module="yes"]
 +              )
 +      )
  
        CFLAGS=$SAVE_CFLAGS
 +      LDFLAGS=$SAVE_LDFLAGS
  fi
 -AM_CONDITIONAL(BUILD_WITH_LIBIPTC, test "x$with_libiptc" = "xyes")
 -AM_CONDITIONAL(BUILD_WITH_OWN_LIBIPTC, test "x$with_own_libiptc" = "xyes")
 -if test "x$with_own_libiptc" = "xyes"
 +AM_CONDITIONAL(HAVE_BROKEN_PERL_LOAD_MODULE,
 +              test "x$have_broken_perl_load_module" = "xyes")
 +
 +if test "x$with_libperl" = "xyes"
  then
 -      AC_DEFINE(OWN_LIBIPTC, 1, [Define to 1 if we use the shipped iptc library.])
 +      SAVE_CFLAGS=$CFLAGS
 +      SAVE_LDFLAGS=$LDFLAGS
 +      CFLAGS="$CFLAGS $PERL_CFLAGS"
 +      LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
 +
 +      AC_CHECK_MEMBER(
 +              [struct mgvtbl.svt_local],
 +              [have_struct_mgvtbl_svt_local="yes"],
 +              [have_struct_mgvtbl_svt_local="no"],
 +              [
 +#include <EXTERN.h>
 +#include <perl.h>
 +#include <XSUB.h>
 +              ])
 +
 +      if test "x$have_struct_mgvtbl_svt_local" = "xyes"
 +      then
 +              AC_DEFINE(HAVE_PERL_STRUCT_MGVTBL_SVT_LOCAL, 1,
 +                                [Define if Perl's struct mgvtbl has member svt_local.])
 +      fi
 +
 +      CFLAGS=$SAVE_CFLAGS
 +      LDFLAGS=$SAVE_LDFLAGS
  fi
 +# }}}
  
 -with_snmp_config="net-snmp-config"
 -with_snmp_cflags=""
 -with_snmp_libs=""
 -AC_ARG_WITH(libnetsnmp, [AS_HELP_STRING([--with-libnetsnmp@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
 +# --with-libpq {{{
 +with_pg_config="pg_config"
 +with_libpq_includedir=""
 +with_libpq_libdir=""
 +with_libpq_cppflags=""
 +with_libpq_ldflags=""
 +AC_ARG_WITH(libpq, [AS_HELP_STRING([--with-libpq@<:@=PREFIX@:>@],
 +      [Path to libpq.])],
  [
        if test "x$withval" = "xno"
        then
 -              with_libnetsnmp="no"
 +              with_libpq="no"
        else if test "x$withval" = "xyes"
        then
 -              with_libnetsnmp="yes"
 +              with_libpq="yes"
        else
 -              if test -x "$withval"
 +              if test -f "$withval" && test -x "$withval";
                then
 -                      with_snmp_config="$withval"
 -                      with_libnetsnmp="yes"
 -              else
 -                      with_snmp_config="$withval/bin/net-snmp-config"
 -                      with_libnetsnmp="yes"
 -              fi
 +                      with_pg_config="$withval"
 +              else if test -x "$withval/bin/pg_config"
 +              then
 +                      with_pg_config="$withval/bin/pg_config"
 +              fi; fi
 +              with_libpq="yes"
        fi; fi
  ],
 -[with_libnetsnmp="yes"])
 -if test "x$with_libnetsnmp" = "xyes"
 +[
 +      with_libpq="yes"
 +])
 +if test "x$with_libpq" = "xyes"
  then
 -      with_snmp_cflags=`$with_snmp_config --cflags 2>/dev/null`
 -      snmp_config_status=$?
 +      with_libpq_includedir=`$with_pg_config --includedir 2> /dev/null`
 +      pg_config_status=$?
  
 -      if test $snmp_config_status -ne 0
 +      if test $pg_config_status -eq 0
        then
 -              with_libnetsnmp="no ($with_snmp_config failed)"
 +              if test -n "$with_libpq_includedir"; then
 +                      for dir in $with_libpq_includedir; do
 +                              with_libpq_cppflags="$with_libpq_cppflags -I$dir"
 +                      done
 +              fi
        else
 -              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"
 +              AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
        fi
 +
 +      SAVE_CPPFLAGS="$CPPFLAGS"
 +      CPPFLAGS="$CPPFLAGS $with_libpq_cppflags"
 +
 +      AC_CHECK_HEADERS(libpq-fe.h, [],
 +              [with_libpq="no (libpq-fe.h not found)"], [])
 +
 +      CPPFLAGS="$SAVE_CPPFLAGS"
  fi
 -if test "x$with_libnetsnmp" = "xyes"
 +if test "x$with_libpq" = "xyes"
  then
 -      with_snmp_libs=`$with_snmp_config --libs 2>/dev/null`
 -      snmp_config_status=$?
 +      with_libpq_libdir=`$with_pg_config --libdir 2> /dev/null`
 +      pg_config_status=$?
  
 -      if test $snmp_config_status -ne 0
 +      if test $pg_config_status -eq 0
        then
 -              with_libnetsnmp="no ($with_snmp_config failed)"
 +              if test -n "$with_libpq_libdir"; then
 +                      for dir in $with_libpq_libdir; do
 +                              with_libpq_ldflags="$with_libpq_ldflags -L$dir"
 +                      done
 +              fi
        else
 -              AC_CHECK_LIB(netsnmp, init_snmp,
 -              [with_libnetsnmp="yes"],
 -              [with_libnetsnmp="no (libnetsnmp not found)"],
 -              [$with_snmp_libs])
 +              AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
        fi
 +
 +      SAVE_LDFLAGS="$LDFLAGS"
 +      LDFLAGS="$LDFLAGS $with_libpq_ldflags"
 +
 +      AC_CHECK_LIB(pq, PQconnectdb,
 +              [with_libpq="yes"],
 +              [with_libpq="no (symbol 'PQconnectdb' not found)"])
 +
 +      LDFLAGS="$SAVE_LDFLAGS"
  fi
 -if test "x$with_libnetsnmp" = "xyes"
 +if test "x$with_libpq" = "xyes"
  then
 -      BUILD_WITH_LIBSNMP_CFLAGS="$with_snmp_cflags"
 -      BUILD_WITH_LIBSNMP_LIBS="$with_snmp_libs"
 -      AC_SUBST(BUILD_WITH_LIBSNMP_CFLAGS)
 -      AC_SUBST(BUILD_WITH_LIBSNMP_LIBS)
 +      BUILD_WITH_LIBPQ_CPPFLAGS="$with_libpq_cppflags"
 +      BUILD_WITH_LIBPQ_LDFLAGS="$with_libpq_ldflags"
 +      AC_SUBST(BUILD_WITH_LIBPQ_CPPFLAGS)
 +      AC_SUBST(BUILD_WITH_LIBPQ_LDFLAGS)
  fi
 -AM_CONDITIONAL(BUILD_WITH_LIBNETSNMP, test "x$with_libnetsnmp" = "xyes")
 -
 -PKG_CHECK_MODULES([LIBNOTIFY], [libnotify],
 -              [with_libnotify="yes"],
 -              [with_libnotify="no ($LIBNOTIFY_PKG_ERRORS)"])
 +AM_CONDITIONAL(BUILD_WITH_LIBPQ, test "x$with_libpq" = "xyes")
 +# }}}
  
 -with_libupsclient_config=""
 -with_libupsclient_cflags=""
 -with_libupsclient_libs=""
 -AC_ARG_WITH(libupsclient, [AS_HELP_STRING([--with-libupsclient@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
 -[
 -      if test "x$withval" = "xno"
 -      then
 -              with_libupsclient="no"
 -      else if test "x$withval" = "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
 -              with_libupsclient="use_pkgconfig"
 +              LDFLAGS="$LDFLAGS -L$withval/lib"
 +              CPPFLAGS="$CPPFLAGS -I$withval/include"
 +              with_libpthread="yes"
        else
 -              if test -x "$withval"
 -              then
 -                      with_libupsclient_config="$withval"
 -                      with_libupsclient="use_libupsclient_config"
 -              else if test -x "$withval/bin/libupsclient-config"
 +              if test "x$withval" = "xno"
                then
 -                      with_libupsclient_config="$withval/bin/net-snmp-config"
 -                      with_libupsclient="use_libupsclient_config"
 -              else
 -                      AC_MSG_NOTICE([Not checking for libupsclient: Manually configured])
 -                      with_libupsclient_cflags="-I$withval/include"
 -                      with_libupsclient_libs="-L$withval/lib -lupsclient"
 -                      with_libupsclient="yes"
 -              fi; fi
 -      fi; fi
 -],
 -[with_libupsclient="use_pkgconfig"])
 -
 -# configure using libupsclient-config
 -if test "x$with_libupsclient" = "xuse_libupsclient_config"
 -then
 -      AC_MSG_NOTICE([Checking for libupsclient using $with_libupsclient_config])
 -      with_libupsclient_cflags="`$with_libupsclient_config --cflags`"
 -      if test $? -ne 0
 -      then
 -              with_libupsclient="no ($with_libupsclient_config failed)"
 -      fi
 -      with_libupsclient_libs="`$with_libupsclient_config --libs`"
 -      if test $? -ne 0
 -      then
 -              with_libupsclient="no ($with_libupsclient_config failed)"
 +                      with_libpthread="no (disabled)"
 +              fi
        fi
 -fi
 -if test "x$with_libupsclient" = "xuse_libupsclient_config"
 +], [with_libpthread="yes"])
 +if test "x$with_libpthread" = "xyes"
  then
 -      with_libupsclient="yes"
 +      AC_CHECK_LIB(pthread, pthread_create, [with_libpthread="yes"], [with_libpthread="no (libpthread not found)"], [])
  fi
 -# configure using pkg-config
 -if test "x$with_libupsclient" = "xuse_pkgconfig"
 +if test "x$with_libpthread" = "xyes"
  then
 -      if test "x$PKG_CONFIG" = "x"
 -      then
 -              with_libupsclient="no (Don't have pkg-config)"
 -      fi
 +      AC_CHECK_HEADERS(pthread.h,, [with_libpthread="no (pthread.h not found)"])
  fi
 -if test "x$with_libupsclient" = "xuse_pkgconfig"
 +if test "x$with_libpthread" = "xyes"
  then
 -      AC_MSG_NOTICE([Checking for libupsclient using $PKG_CONFIG])
 -      $PKG_CONFIG --exists 'libupsclient' 2>/dev/null
 -      if test $? -ne 0
 +      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-librrd {{{
 +# AC_ARG_WITH (package, help-string, [action-if-given], [action-if-not-given])
 +librrd_cflags=""
 +librrd_ldflags=""
 +librrd_threadsafe="yes"
 +librrd_rrdc_update="no"
 +AC_ARG_WITH(librrd, [AS_HELP_STRING([--with-librrd@<:@=PREFIX@:>@], [Path to rrdtool.])],
 +[     if test "x$withval" != "xno" && test "x$withval" != "xyes"
        then
 -              with_libupsclient="no (pkg-config doesn't know library)"
 +              librrd_cflags="-I$withval/include"
 +              librrd_ldflags="-L$withval/lib"
 +              with_librrd="yes"
 +      else
 +              with_librrd="$withval"
        fi
 -fi
 -if test "x$with_libupsclient" = "xuse_pkgconfig"
 -then
 -      with_libupsclient_cflags="`$PKG_CONFIG --cflags 'libupsclient'`"
 -      if test $? -ne 0
 -      then
 -              with_libupsclient="no ($PKG_CONFIG failed)"
 -      fi
 -      with_libupsclient_libs="`$PKG_CONFIG --libs 'libupsclient'`"
 -      if test $? -ne 0
 -      then
 -              with_libupsclient="no ($PKG_CONFIG failed)"
 -      fi
 -fi
 -if test "x$with_libupsclient" = "xuse_pkgconfig"
 -then
 -      with_libupsclient="yes"
 -fi
 -
 -# with_libupsclient_cflags and with_libupsclient_libs are set up now, let's do
 -# the actual checks.
 -if test "x$with_libupsclient" = "xyes"
 +], [with_librrd="yes"])
 +if test "x$with_librrd" = "xyes"
  then
        SAVE_CPPFLAGS="$CPPFLAGS"
 -      CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
 +      SAVE_LDFLAGS="$LDFLAGS"
  
 -      AC_CHECK_HEADERS(upsclient.h, [], [with_libupsclient="no (upsclient.h not found)"])
 +      CPPFLAGS="$CPPFLAGS $librrd_cflags"
 +      LDFLAGS="$LDFLAGS $librrd_ldflags"
 +
 +      AC_CHECK_HEADERS(rrd.h,, [with_librrd="no (rrd.h not found)"])
  
        CPPFLAGS="$SAVE_CPPFLAGS"
 +      LDFLAGS="$SAVE_LDFLAGS"
  fi
 -if test "x$with_libupsclient" = "xyes"
 +if test "x$with_librrd" = "xyes"
  then
        SAVE_CPPFLAGS="$CPPFLAGS"
        SAVE_LDFLAGS="$LDFLAGS"
  
 -      CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
 -      LDFLAGS="$LDFLAGS $with_libupsclient_libs"
 +      CPPFLAGS="$CPPFLAGS $librrd_cflags"
 +      LDFLAGS="$LDFLAGS $librrd_ldflags"
  
 -      AC_CHECK_LIB(upsclient, upscli_connect,
 -                   [with_libupsclient="yes"],
 -                   [with_libupsclient="no (symbol upscli_connect not found)"])
 +      AC_CHECK_LIB(rrd_th, rrd_update_r,
 +      [with_librrd="yes"
 +       librrd_ldflags="$librrd_ldflags -lrrd_th -lm"
 +      ],
 +      [librrd_threadsafe="no"
 +       AC_CHECK_LIB(rrd, rrd_update,
 +       [with_librrd="yes"
 +        librrd_ldflags="$librrd_ldflags -lrrd -lm"
 +       ],
 +       [with_librrd="no (symbol 'rrd_update' not found)"],
 +       [-lm])
 +      ],
 +      [-lm])
 +
 +      if test "x$librrd_threadsafe" = "xyes"
 +      then
 +              AC_CHECK_LIB(rrd_th, rrdc_update, [librrd_rrdc_update="yes"], [librrd_rrdc_update="no"])
 +      else
 +              AC_CHECK_LIB(rrd, rrdc_update, [librrd_rrdc_update="yes"], [librrd_rrdc_update="no"])
 +      fi
  
        CPPFLAGS="$SAVE_CPPFLAGS"
        LDFLAGS="$SAVE_LDFLAGS"
  fi
 -if test "x$with_libupsclient" = "xyes"
 +if test "x$with_librrd" = "xyes"
  then
 -      SAVE_CPPFLAGS="$CPPFLAGS"
 -      CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
 -
 -      AC_CHECK_TYPES([UPSCONN_t, UPSCONN], [], [],
 -[#include <stdlib.h>
 -#include <stdio.h>
 -#include <upsclient.h>])
 -
 -      CPPFLAGS="$SAVE_CPPFLAGS"
 +      BUILD_WITH_LIBRRD_CFLAGS="$librrd_cflags"
 +      BUILD_WITH_LIBRRD_LDFLAGS="$librrd_ldflags"
 +      AC_SUBST(BUILD_WITH_LIBRRD_CFLAGS)
 +      AC_SUBST(BUILD_WITH_LIBRRD_LDFLAGS)
  fi
 -if test "x$with_libupsclient" = "xyes"
 +if test "x$librrd_threadsafe" = "xyes"
  then
 -      BUILD_WITH_LIBUPSCLIENT_CFLAGS="$with_libupsclient_cflags"
 -      BUILD_WITH_LIBUPSCLIENT_LIBS="$with_libupsclient_libs"
 -      AC_SUBST(BUILD_WITH_LIBUPSCLIENT_CFLAGS)
 -      AC_SUBST(BUILD_WITH_LIBUPSCLIENT_LIBS)
 +      AC_DEFINE(HAVE_THREADSAFE_LIBRRD, 1, [Define to 1 if you have the threadsafe rrd library (-lrrd_th).])
  fi
 +# }}}
  
 -### BEGIN of check for libxmms ###
 -with_xmms_config="xmms-config"
 -with_xmms_cflags=""
 -with_xmms_libs=""
 -AC_ARG_WITH(libxmms, [AS_HELP_STRING([--with-libxmms@<:@=PREFIX@:>@], [Path to libxmms.])],
 +# --with-libsensors {{{
 +with_sensors_cflags=""
 +with_sensors_ldflags=""
 +AC_ARG_WITH(libsensors, [AS_HELP_STRING([--with-libsensors@<:@=PREFIX@:>@], [Path to lm_sensors.])],
  [
 -      if test "x$withval" != "xno" \
 -              && test "x$withval" != "xyes"
 -      then
 -              if test -f "$withval" && test -x "$withval";
 -              then
 -                      with_xmms_config="$withval"
 -              else if test -x "$withval/bin/xmms-config"
 -              then
 -                      with_xmms_config="$withval/bin/xmms-config"
 -              fi; fi
 -              with_libxmms="yes"
 -      else if test "x$withval" = "xno"
 +      if test "x$withval" = "xno"
        then
 -              with_libxmms="no"
 +              with_libsensors="no"
        else
 -              with_libxmms="yes"
 -      fi; fi
 +              with_libsensors="yes"
 +              if test "x$withval" != "xyes"
 +              then
 +                      with_sensors_cflags="-I$withval/include"
 +                      with_sensors_ldflags="-L$withval/lib"
 +                      with_libsensors="yes"
 +              fi
 +      fi
  ],
  [
 -      with_libxmms="yes"
 -])
 -if test "x$with_libxmms" = "xyes"
 -then
 -      with_xmms_cflags=`$with_xmms_config --cflags 2>/dev/null`
 -      xmms_config_status=$?
 -
 -      if test $xmms_config_status -ne 0
 +      if test "x$ac_system" = "xLinux"
        then
 -              with_libxmms="no"
 +              with_libsensors="yes"
 +      else
 +              with_libsensors="no (Linux only library)"
        fi
 -fi
 -if test "x$with_libxmms" = "xyes"
 +])
 +if test "x$with_libsensors" = "xyes"
  then
 -      with_xmms_libs=`$with_xmms_config --libs 2>/dev/null`
 -      xmms_config_status=$?
 +      SAVE_CPPFLAGS="$CPPFLAGS"
 +      CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
  
 -      if test $xmms_config_status -ne 0
 -      then
 -              with_libxmms="no"
 -      fi
 +#     AC_CHECK_HEADERS(sensors/sensors.h,
 +#     [
 +#             AC_DEFINE(HAVE_SENSORS_SENSORS_H, 1, [Define to 1 if you have the <sensors/sensors.h> header file.])
 +#     ],
 +#     [with_libsensors="no (sensors/sensors.h not found)"])
 +      AC_CHECK_HEADERS(sensors/sensors.h, [], [with_libsensors="no (sensors/sensors.h not found)"])
 +
 +      CPPFLAGS="$SAVE_CPPFLAGS"
  fi
 -if test "x$with_libxmms" = "xyes"
 +if test "x$with_libsensors" = "xyes"
  then
 -      AC_CHECK_LIB(xmms, xmms_remote_get_info,
 -      [
 -              BUILD_WITH_LIBXMMS_CFLAGS="$with_xmms_cflags"
 -              BUILD_WITH_LIBXMMS_LIBS="$with_xmms_libs"
 -              AC_SUBST(BUILD_WITH_LIBXMMS_CFLAGS)
 -              AC_SUBST(BUILD_WITH_LIBXMMS_LIBS)
 -      ],
 +      SAVE_CPPFLAGS="$CPPFLAGS"
 +      SAVE_LDFLAGS="$LDFLAGS"
 +      CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
 +      LDFLAGS="$LDFLAGS $with_sensors_ldflags"
 +
 +      AC_CHECK_LIB(sensors, sensors_init,
        [
 -              with_libxmms="no"
 +              AC_DEFINE(HAVE_LIBSENSORS, 1, [Define to 1 if you have the sensors library (-lsensors).])
        ],
 -      [$with_xmms_libs])
 +      [with_libsensors="no (libsensors not found)"])
 +
 +      CPPFLAGS="$SAVE_CPPFLAGS"
 +      LDFLAGS="$SAVE_LDFLAGS"
  fi
 -with_libxmms_numeric=0
 -if test "x$with_libxmms" = "xyes"
 +if test "x$with_libsensors" = "xyes"
  then
 -      with_libxmms_numeric=1
 +      BUILD_WITH_LIBSENSORS_CFLAGS="$with_sensors_cflags"
 +      BUILD_WITH_LIBSENSORS_LDFLAGS="$with_sensors_ldflags"
 +      AC_SUBST(BUILD_WITH_LIBSENSORS_CFLAGS)
 +      AC_SUBST(BUILD_WITH_LIBSENSORS_LDFLAGS)
  fi
 -AC_DEFINE_UNQUOTED(HAVE_LIBXMMS, [$with_libxmms_numeric], [Define to 1 if you have the 'xmms' library (-lxmms).])
 -AM_CONDITIONAL(BUILD_WITH_LIBXMMS, test "x$with_libxmms" = "xyes")
 -### END of check for libxmms ###
 +AM_CONDITIONAL(BUILD_WITH_LM_SENSORS, test "x$with_libsensors" = "xyes")
 +# }}}
  
 -with_libnetlink_cflags=""
 -with_libnetlink_libs="-lnetlink"
 -AC_ARG_WITH(libnetlink, [AS_HELP_STRING([--with-libnetlink@<:@=PREFIX@:>@], [Path to libnetlink.])],
 +# --with-libstatgrab {{{
 +with_libstatgrab_cflags=""
 +with_libstatgrab_ldflags=""
 +AC_ARG_WITH(libstatgrab, [AS_HELP_STRING([--with-libstatgrab@<:@=PREFIX@:>@], [Path to libstatgrab.])],
  [
 - echo "libnetlink: withval = $withval"
 - if test "x$withval" = "xyes"
 - then
 -       with_libnetlink="yes"
 - else if test "x$withval" = "xno"
 - then
 -       with_libnetlink="no"
 - else
 -       if test -d "$withval/include"
 -       then
 -               with_libnetlink_cflags="-I$withval/include"
 -               with_libnetlink_libs="-L$withval/lib -lnetlink"
 -               with_libnetlink="yes"
 -       else
 -               AC_MSG_ERROR("no such directory: $withval/include")
 -       fi
 - fi; fi
 +      if test "x$withval" != "xno" \
 +              && test "x$withval" != "xyes"
 +      then
 +              with_libstatgrab_cflags="-I$withval/include"
 +              with_libstatgrab_ldflags="-L$withval/lib"
 +              with_libstatgrab="yes"
 +      else
 +              with_libstatgrab="$withval"
 +      fi
  ],
  [
 - if test "x$ac_system" = "xLinux"
 - then
 -       with_libnetlink="yes"
 - else
 -       with_libnetlink="no (Linux only library)"
 - fi
 +      if test "x$ac_system" = "xunknown"
 +      then
 +              with_libstatgrab="yes"
 +      else
 +              with_libstatgrab="no"
 +      fi
  ])
 -if test "x$with_libnetlink" = "xyes"
 +with_libstatgrab_pkg_config="yes"
 +if test "x$with_libstatgrab" = "xyes" \
 +  && test "x$PKG_CONFIG" != "x"
  then
 -      SAVE_CFLAGS=$CFLAGS
 -      CFLAGS="$CFLAGS $with_libnetlink_cflags"
 -
 -      with_libnetlink="no (libnetlink.h not found)"
 -
 -      AC_CHECK_HEADERS(libnetlink.h iproute/libnetlink.h linux/libnetlink.h,
 -      [
 -       with_libnetlink="yes"
 -       break
 -      ], [],
 -[#include <stdio.h>
 -#include <sys/types.h>
 -#include <asm/types.h>
 -#include <sys/socket.h>
 -#include <linux/netlink.h>
 -#include <linux/rtnetlink.h>])
 -      AC_CHECK_HEADERS(linux/gen_stats.h linux/pkt_sched.h, [], [],
 -[#include <stdio.h>
 -#include <sys/types.h>
 -#include <asm/types.h>
 -#include <sys/socket.h>])
 +  AC_MSG_CHECKING([pkg-config for libstatgrab])
 +  temp_result="found"
 +  $PKG_CONFIG --exists libstatgrab 2>/dev/null
 +  if test "$?" != "0"
 +  then
 +    with_libstatgrab_pkg_config="no"
 +    temp_result="not found"
 +  fi
 +  AC_MSG_RESULT([$temp_result])
 +else
 +  AC_MSG_NOTICE([pkg-config not available, trying to guess flags for the statgrab library.])
 +  with_libstatgrab_pkg_config="no"
 +  with_libstatgrab_ldflags="$with_libstatgrab_ldflags -lstatgrab"
 +fi
  
 -      AC_COMPILE_IFELSE(
 -[#include <stdio.h>
 -#include <sys/types.h>
 -#include <asm/types.h>
 -#include <sys/socket.h>
 -#include <linux/netlink.h>
 -#include <linux/rtnetlink.h>
 +if test "x$with_libstatgrab" = "xyes" \
 +  && test "x$with_libstatgrab_pkg_config" = "xyes" \
 +  && test "x$with_libstatgrab_cflags" = "x"
 +then
 +  AC_MSG_CHECKING([for libstatgrab CFLAGS])
 +  temp_result="`$PKG_CONFIG --cflags libstatgrab`"
 +  if test "$?" = "0"
 +  then
 +    with_libstatgrab_cflags="$temp_result"
 +  else
 +    with_libstatgrab="no ($PKG_CONFIG --cflags libstatgrab failed)"
 +    temp_result="$PKG_CONFIG --cflags libstatgrab failed"
 +  fi
 +  AC_MSG_RESULT([$temp_result])
 +fi
  
 -int main (void)
 -{
 -      int retval = TCA_STATS2;
 -      return (retval);
 -}],
 -      [AC_DEFINE([HAVE_TCA_STATS2], 1, [True if the enum-member TCA_STATS2 exists])]
 -      []);
 +if test "x$with_libstatgrab" = "xyes" \
 +  && test "x$with_libstatgrab_pkg_config" = "xyes" \
 +  && test "x$with_libstatgrab_ldflags" = "x"
 +then
 +  AC_MSG_CHECKING([for libstatgrab LDFLAGS])
 +  temp_result="`$PKG_CONFIG --libs libstatgrab`"
 +  if test "$?" = "0"
 +  then
 +    with_libstatgrab_ldflags="$temp_result"
 +  else
 +    with_libstatgrab="no ($PKG_CONFIG --libs libstatgrab failed)"
 +    temp_result="$PKG_CONFIG --libs libstatgrab failed"
 +  fi
 +  AC_MSG_RESULT([$temp_result])
 +fi
  
 -      AC_COMPILE_IFELSE(
 -[#include <stdio.h>
 -#include <sys/types.h>
 -#include <asm/types.h>
 -#include <sys/socket.h>
 -#include <linux/netlink.h>
 -#include <linux/rtnetlink.h>
 +if test "x$with_libstatgrab" = "xyes"
 +then
 +  SAVE_CPPFLAGS="$CPPFLAGS"
 +  CPPFLAGS="$CPPFLAGS $with_libstatgrab_cflags"
  
 -int main (void)
 -{
 -      int retval = TCA_STATS;
 -      return (retval);
 -}],
 -      [AC_DEFINE([HAVE_TCA_STATS], 1, [True if the enum-member TCA_STATS exists])]
 -      []);
 +  AC_CHECK_HEADERS(statgrab.h,
 +                 [with_libstatgrab="yes"],
 +                 [with_libstatgrab="no (statgrab.h not found)"])
  
 -      CFLAGS="$SAVE_CFLAGS"
 +  CPPFLAGS="$SAVE_CPPFLAGS"
  fi
 -if test "x$with_libnetlink" = "xyes"
 +
 +if test "x$with_libstatgrab" = "xyes"
  then
 -      AC_CHECK_LIB(netlink, rtnl_open,
 -                   [with_libnetlink="yes"],
 -                   [with_libnetlink="no (symbol 'rtnl_open' not found)"],
 -                   [$with_libnetlink_libs])
 +  SAVE_CFLAGS="$CFLAGS"
 +  SAVE_LDFLAGS="$LDFLAGS"
 +
 +  CFLAGS="$CFLAGS $with_libstatgrab_cflags"
 +  LDFLAGS="$LDFLAGS $with_libstatgrab_ldflags"
 +
 +  AC_CHECK_LIB(statgrab, sg_init,
 +             [with_libstatgrab="yes"],
 +             [with_libstatgrab="no (symbol sg_init not found)"])
 +
 +  CFLAGS="$SAVE_CFLAGS"
 +  LDFLAGS="$SAVE_LDFLAGS"
  fi
 -if test "x$with_libnetlink" = "xyes"
 +
 +AM_CONDITIONAL(BUILD_WITH_LIBSTATGRAB, test "x$with_libstatgrab" = "xyes")
 +if test "x$with_libstatgrab" = "xyes"
  then
 -      BUILD_WITH_LIBNETLINK_CFLAGS="$with_libnetlink_cflags"
 -      BUILD_WITH_LIBNETLINK_LIBS="$with_libnetlink_libs"
 -      AC_SUBST(BUILD_WITH_LIBNETLINK_CFLAGS)
 -      AC_SUBST(BUILD_WITH_LIBNETLINK_LIBS)
 +  AC_DEFINE(HAVE_LIBSTATGRAB, 1, [Define to 1 if you have the 'statgrab' library (-lstatgrab)])
 +  BUILD_WITH_LIBSTATGRAB_CFLAGS="$with_libstatgrab_cflags"
 +  BUILD_WITH_LIBSTATGRAB_LDFLAGS="$with_libstatgrab_ldflags"
 +  AC_SUBST(BUILD_WITH_LIBSTATGRAB_CFLAGS)
 +  AC_SUBST(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
  fi
 -AM_CONDITIONAL(BUILD_WITH_LIBNETLINK, test "x$with_libnetlink" = "xyes")
 +# }}}
  
- # --with-libxmms {{{
- with_xmms_config="xmms-config"
- with_xmms_cflags=""
- with_xmms_libs=""
- AC_ARG_WITH(libxmms, [AS_HELP_STRING([--with-libxmms@<:@=PREFIX@:>@], [Path to libxmms.])],
 -with_libopenipmipthread="yes"
 -with_libopenipmipthread_cflags=""
 -with_libopenipmipthread_libs=""
++# --with-libupsclient {{{
++with_libupsclient_config=""
++with_libupsclient_cflags=""
++with_libupsclient_libs=""
++AC_ARG_WITH(libupsclient, [AS_HELP_STRING([--with-libupsclient@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
 +[
-       if test "x$withval" != "xno" \
-               && test "x$withval" != "xyes"
++      if test "x$withval" = "xno"
 +      then
-               if test -f "$withval" && test -x "$withval";
++              with_libupsclient="no"
++      else if test "x$withval" = "xyes"
++      then
++              with_libupsclient="use_pkgconfig"
++      else
++              if test -x "$withval"
 +              then
-                       with_xmms_config="$withval"
-               else if test -x "$withval/bin/xmms-config"
++                      with_libupsclient_config="$withval"
++                      with_libupsclient="use_libupsclient_config"
++              else if test -x "$withval/bin/libupsclient-config"
 +              then
-                       with_xmms_config="$withval/bin/xmms-config"
++                      with_libupsclient_config="$withval/bin/net-snmp-config"
++                      with_libupsclient="use_libupsclient_config"
++              else
++                      AC_MSG_NOTICE([Not checking for libupsclient: Manually configured])
++                      with_libupsclient_cflags="-I$withval/include"
++                      with_libupsclient_libs="-L$withval/lib -lupsclient"
++                      with_libupsclient="yes"
 +              fi; fi
-               with_libxmms="yes"
-       else if test "x$withval" = "xno"
-       then
-               with_libxmms="no"
-       else
-               with_libxmms="yes"
 +      fi; fi
 +],
- [
-       with_libxmms="yes"
- ])
- if test "x$with_libxmms" = "xyes"
- then
-       with_xmms_cflags=`$with_xmms_config --cflags 2>/dev/null`
-       xmms_config_status=$?
++[with_libupsclient="use_pkgconfig"])
  
-       if test $xmms_config_status -ne 0
 -AC_MSG_CHECKING([for pkg-config])
 -temp_result="no"
 -if test "x$PKG_CONFIG" = "x"
++# configure using libupsclient-config
++if test "x$with_libupsclient" = "xuse_libupsclient_config"
+ then
 -      with_libopenipmipthread="no"
 -      temp_result="no"
 -else
 -      temp_result="$PKG_CONFIG"
++      AC_MSG_NOTICE([Checking for libupsclient using $with_libupsclient_config])
++      with_libupsclient_cflags="`$with_libupsclient_config --cflags`"
++      if test $? -ne 0
 +      then
-               with_libxmms="no"
++              with_libupsclient="no ($with_libupsclient_config failed)"
 +      fi
- fi
- if test "x$with_libxmms" = "xyes"
- then
-       with_xmms_libs=`$with_xmms_config --libs 2>/dev/null`
-       xmms_config_status=$?
-       if test $xmms_config_status -ne 0
++      with_libupsclient_libs="`$with_libupsclient_config --libs`"
++      if test $? -ne 0
 +      then
-               with_libxmms="no"
++              with_libupsclient="no ($with_libupsclient_config failed)"
 +      fi
 +fi
- if test "x$with_libxmms" = "xyes"
++if test "x$with_libupsclient" = "xuse_libupsclient_config"
 +then
-       AC_CHECK_LIB(xmms, xmms_remote_get_info,
-       [
-               BUILD_WITH_LIBXMMS_CFLAGS="$with_xmms_cflags"
-               BUILD_WITH_LIBXMMS_LIBS="$with_xmms_libs"
-               AC_SUBST(BUILD_WITH_LIBXMMS_CFLAGS)
-               AC_SUBST(BUILD_WITH_LIBXMMS_LIBS)
-       ],
-       [
-               with_libxmms="no"
-       ],
-       [$with_xmms_libs])
++      with_libupsclient="yes"
  fi
- with_libxmms_numeric=0
- if test "x$with_libxmms" = "xyes"
 -AC_MSG_RESULT([$temp_result])
 -if test "x$with_libopenipmipthread" = "xyes"
++# configure using pkg-config
++if test "x$with_libupsclient" = "xuse_pkgconfig"
  then
-       with_libxmms_numeric=1
 -      AC_MSG_CHECKING([for libOpenIPMIpthread])
 -      $PKG_CONFIG --exists OpenIPMIpthread 2>/dev/null
 -      if test "$?" != "0"
++      if test "x$PKG_CONFIG" = "x"
+       then
 -              with_libopenipmipthread="no ($PKG_CONFIG doesn't know OpenIPMIpthread)"
++              with_libupsclient="no (Don't have pkg-config)"
+       fi
 -      AC_MSG_RESULT([$with_libopenipmipthread])
  fi
- AC_DEFINE_UNQUOTED(HAVE_LIBXMMS, [$with_libxmms_numeric], [Define to 1 if you have the 'xmms' library (-lxmms).])
- AM_CONDITIONAL(BUILD_WITH_LIBXMMS, test "x$with_libxmms" = "xyes")
- # }}}
--
- # pkg-config --exists 'libupsclient' {{{
- with_libupsclient="no (pkg-config isn't available)"
- with_libupsclient_cflags=""
- with_libupsclient_libs=""
- if test "x$PKG_CONFIG" != "x"
 -if test "x$with_libopenipmipthread" = "xyes"
++if test "x$with_libupsclient" = "xuse_pkgconfig"
  then
-       pkg-config --exists 'libupsclient' 2>/dev/null
 -      AC_MSG_CHECKING([for libOpenIPMIpthread CFLAGS])
 -      temp_result="`$PKG_CONFIG --cflags OpenIPMIpthread`"
--      if test "$?" = "0"
++      AC_MSG_NOTICE([Checking for libupsclient using $PKG_CONFIG])
++      $PKG_CONFIG --exists 'libupsclient' 2>/dev/null
++      if test $? -ne 0
        then
-               with_libupsclient="yes"
 -              with_libopenipmipthread_cflags="$temp_result"
--      else
 -              with_libopenipmipthread="no ($PKG_CONFIG --cflags OpenIPMIpthread failed)"
 -              temp_result="$PKG_CONFIG --cflags OpenIPMIpthread failed"
 +              with_libupsclient="no (pkg-config doesn't know library)"
        fi
 -      AC_MSG_RESULT([$temp_result])
  fi
- if test "x$with_libupsclient" = "xyes"
 -
 -if test "x$with_libopenipmipthread" = "xyes"
++if test "x$with_libupsclient" = "xuse_pkgconfig"
  then
-       with_libupsclient_cflags="`pkg-config --cflags 'libupsclient'`"
 -      AC_MSG_CHECKING([for libOpenIPMIpthread LDFLAGS])
 -      temp_result="`$PKG_CONFIG --libs OpenIPMIpthread`"
 -      if test "$?" = "0"
++      with_libupsclient_cflags="`$PKG_CONFIG --cflags 'libupsclient'`"
 +      if test $? -ne 0
        then
-               with_libupsclient="no"
 -              with_libopenipmipthread_ldflags="$temp_result"
 -      else
 -              with_libopenipmipthread="no ($PKG_CONFIG --libs OpenIPMIpthread failed)"
 -              temp_result="$PKG_CONFIG --libs OpenIPMIpthread failed"
++              with_libupsclient="no ($PKG_CONFIG failed)"
        fi
-       with_libupsclient_libs="`pkg-config --libs 'libupsclient'`"
 -      AC_MSG_RESULT([$temp_result])
++      with_libupsclient_libs="`$PKG_CONFIG --libs 'libupsclient'`"
 +      if test $? -ne 0
 +      then
-               with_libupsclient="no"
++              with_libupsclient="no ($PKG_CONFIG failed)"
 +      fi
 +fi
++if test "x$with_libupsclient" = "xuse_pkgconfig"
++then
++      with_libupsclient="yes"
++fi
++
++# with_libupsclient_cflags and with_libupsclient_libs are set up now, let's do
++# the actual checks.
 +if test "x$with_libupsclient" = "xyes"
 +then
 +      SAVE_CPPFLAGS="$CPPFLAGS"
 +      CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
 +
 +      AC_CHECK_HEADERS(upsclient.h, [], [with_libupsclient="no (upsclient.h not found)"])
 +
 +      CPPFLAGS="$SAVE_CPPFLAGS"
  fi
 -
 -if test "x$with_libopenipmipthread" = "xyes"
 +if test "x$with_libupsclient" = "xyes"
  then
        SAVE_CPPFLAGS="$CPPFLAGS"
 -      CPPFLAGS="$CPPFLAGS $with_libopenipmipthread_cflags"
 +      SAVE_LDFLAGS="$LDFLAGS"
  
 -      AC_CHECK_HEADERS(OpenIPMI/ipmi_smi.h,
 -                       [with_libopenipmipthread="yes"],
 -                       [with_libopenipmipthread="no (OpenIPMI/ipmi_smi.h not found)"],
 -[#include <OpenIPMI/ipmiif.h>
 -#include <OpenIPMI/ipmi_err.h>
 -#include <OpenIPMI/ipmi_posix.h>
 -#include <OpenIPMI/ipmi_conn.h>
 -])
 +      CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
 +      LDFLAGS="$LDFLAGS $with_libupsclient_libs"
 +
 +      AC_CHECK_LIB(upsclient, upscli_connect,
 +                   [with_libupsclient="yes"],
 +                   [with_libupsclient="no (symbol upscli_connect not found)"])
  
        CPPFLAGS="$SAVE_CPPFLAGS"
 +      LDFLAGS="$SAVE_LDFLAGS"
  fi
 +if test "x$with_libupsclient" = "xyes"
 +then
 +      SAVE_CPPFLAGS="$CPPFLAGS"
 +      CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
  
 -if test "x$with_libopenipmipthread" = "xyes"
 +      AC_CHECK_TYPES([UPSCONN_t, UPSCONN], [], [],
 +[#include <stdlib.h>
 +#include <stdio.h>
 +#include <upsclient.h>])
 +
 +      CPPFLAGS="$SAVE_CPPFLAGS"
 +fi
 +if test "x$with_libupsclient" = "xyes"
  then
 -      BUILD_WITH_OPENIPMI_CFLAGS="$with_libopenipmipthread_cflags"
 -      BUILD_WITH_OPENIPMI_LIBS="$with_libopenipmipthread_ldflags"
 -      AC_SUBST(BUILD_WITH_OPENIPMI_CFLAGS)
 -      AC_SUBST(BUILD_WITH_OPENIPMI_LIBS)
 +      BUILD_WITH_LIBUPSCLIENT_CFLAGS="$with_libupsclient_cflags"
 +      BUILD_WITH_LIBUPSCLIENT_LIBS="$with_libupsclient_libs"
 +      AC_SUBST(BUILD_WITH_LIBUPSCLIENT_CFLAGS)
 +      AC_SUBST(BUILD_WITH_LIBUPSCLIENT_LIBS)
  fi
 +# }}}
  
 -dnl Check for libpq.
 -with_pg_config="pg_config"
 -with_libpq_includedir=""
 -with_libpq_libdir=""
 -with_libpq_cppflags=""
 -with_libpq_ldflags=""
 -AC_ARG_WITH(libpq, [AS_HELP_STRING([--with-libpq@<:@=PREFIX@:>@],
 -      [Path to libpq.])],
++# --with-libxmms {{{
++with_xmms_config="xmms-config"
++with_xmms_cflags=""
++with_xmms_libs=""
++AC_ARG_WITH(libxmms, [AS_HELP_STRING([--with-libxmms@<:@=PREFIX@:>@], [Path to libxmms.])],
+ [
 -      if test "x$withval" = "xno"
 -      then
 -              with_libpq="no"
 -      else if test "x$withval" = "xyes"
++      if test "x$withval" != "xno" \
++              && test "x$withval" != "xyes"
+       then
 -              with_libpq="yes"
 -      else
+               if test -f "$withval" && test -x "$withval";
+               then
 -                      with_pg_config="$withval"
 -              else if test -x "$withval/bin/pg_config"
++                      with_xmms_config="$withval"
++              else if test -x "$withval/bin/xmms-config"
+               then
 -                      with_pg_config="$withval/bin/pg_config"
++                      with_xmms_config="$withval/bin/xmms-config"
+               fi; fi
 -              with_libpq="yes"
++              with_libxmms="yes"
++      else if test "x$withval" = "xno"
++      then
++              with_libxmms="no"
++      else
++              with_libxmms="yes"
+       fi; fi
+ ],
+ [
 -      with_libpq="yes"
++      with_libxmms="yes"
+ ])
 -if test "x$with_libpq" = "xyes"
++if test "x$with_libxmms" = "xyes"
+ then
 -      with_libpq_includedir=`$with_pg_config --includedir 2> /dev/null`
 -      pg_config_status=$?
++      with_xmms_cflags=`$with_xmms_config --cflags 2>/dev/null`
++      xmms_config_status=$?
 -      if test $pg_config_status -eq 0
++      if test $xmms_config_status -ne 0
+       then
 -              if test -n "$with_libpq_includedir"; then
 -                      for dir in $with_libpq_includedir; do
 -                              with_libpq_cppflags="$with_libpq_cppflags -I$dir"
 -                      done
 -              fi
 -      else
 -              AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
++              with_libxmms="no"
+       fi
 -
 -      SAVE_CPPFLAGS="$CPPFLAGS"
 -      CPPFLAGS="$CPPFLAGS $with_libpq_cppflags"
 -
 -      AC_CHECK_HEADERS(libpq-fe.h, [],
 -              [with_libpq="no (libpq-fe.h not found)"], [])
 -
 -      CPPFLAGS="$SAVE_CPPFLAGS"
+ fi
 -if test "x$with_libpq" = "xyes"
++if test "x$with_libxmms" = "xyes"
+ then
 -      with_libpq_libdir=`$with_pg_config --libdir 2> /dev/null`
 -      pg_config_status=$?
++      with_xmms_libs=`$with_xmms_config --libs 2>/dev/null`
++      xmms_config_status=$?
 -      if test $pg_config_status -eq 0
++      if test $xmms_config_status -ne 0
+       then
 -              if test -n "$with_libpq_libdir"; then
 -                      for dir in $with_libpq_libdir; do
 -                              with_libpq_ldflags="$with_libpq_ldflags -L$dir"
 -                      done
 -              fi
 -      else
 -              AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
++              with_libxmms="no"
+       fi
 -
 -      SAVE_LDFLAGS="$LDFLAGS"
 -      LDFLAGS="$LDFLAGS $with_libpq_ldflags"
 -
 -      AC_CHECK_LIB(pq, PQconnectdb,
 -              [with_libpq="yes"],
 -              [with_libpq="no (symbol 'PQconnectdb' not found)"])
 -
 -      LDFLAGS="$SAVE_LDFLAGS"
+ fi
 -if test "x$with_libpq" = "xyes"
++if test "x$with_libxmms" = "xyes"
+ then
 -      BUILD_WITH_LIBPQ_CPPFLAGS="$with_libpq_cppflags"
 -      BUILD_WITH_LIBPQ_LDFLAGS="$with_libpq_ldflags"
 -      AC_SUBST(BUILD_WITH_LIBPQ_CPPFLAGS)
 -      AC_SUBST(BUILD_WITH_LIBPQ_LDFLAGS)
++      AC_CHECK_LIB(xmms, xmms_remote_get_info,
++      [
++              BUILD_WITH_LIBXMMS_CFLAGS="$with_xmms_cflags"
++              BUILD_WITH_LIBXMMS_LIBS="$with_xmms_libs"
++              AC_SUBST(BUILD_WITH_LIBXMMS_CFLAGS)
++              AC_SUBST(BUILD_WITH_LIBXMMS_LIBS)
++      ],
++      [
++              with_libxmms="no"
++      ],
++      [$with_xmms_libs])
+ fi
 -AM_CONDITIONAL(BUILD_WITH_LIBPQ, test "x$with_libpq" = "xyes")
++with_libxmms_numeric=0
++if test "x$with_libxmms" = "xyes"
++then
++      with_libxmms_numeric=1
++fi
++AC_DEFINE_UNQUOTED(HAVE_LIBXMMS, [$with_libxmms_numeric], [Define to 1 if you have the 'xmms' library (-lxmms).])
++AM_CONDITIONAL(BUILD_WITH_LIBXMMS, test "x$with_libxmms" = "xyes")
++# }}}
 -dnl Check for libvirt and libxml2 libraries.
 +# pkg-config --exists 'libxml-2.0'; pkg-config --exists libvirt {{{
  with_libxml2="no (pkg-config isn't available)"
  with_libxml2_cflags=""
  with_libxml2_ldflags=""
@@@ -2649,92 -2480,8 +2711,92 @@@ if test "x$with_libvirt" = "xyes"; the
        AC_SUBST(BUILD_WITH_LIBVIRT_CFLAGS)
        AC_SUBST(BUILD_WITH_LIBVIRT_LIBS)
  fi
 +# }}}
 +
 +# $PKG_CONFIG --exists OpenIPMIpthread {{{
 +with_libopenipmipthread="yes"
 +with_libopenipmipthread_cflags=""
 +with_libopenipmipthread_libs=""
 +
 +AC_MSG_CHECKING([for pkg-config])
 +temp_result="no"
 +if test "x$PKG_CONFIG" = "x"
 +then
 +      with_libopenipmipthread="no"
 +      temp_result="no"
 +else
 +      temp_result="$PKG_CONFIG"
 +fi
 +AC_MSG_RESULT([$temp_result])
 +
 +if test "x$with_libopenipmipthread" = "xyes"
 +then
 +      AC_MSG_CHECKING([for libOpenIPMIpthread])
 +      $PKG_CONFIG --exists OpenIPMIpthread 2>/dev/null
 +      if test "$?" != "0"
 +      then
 +              with_libopenipmipthread="no ($PKG_CONFIG doesn't know OpenIPMIpthread)"
 +      fi
 +      AC_MSG_RESULT([$with_libopenipmipthread])
 +fi
 +
 +if test "x$with_libopenipmipthread" = "xyes"
 +then
 +      AC_MSG_CHECKING([for libOpenIPMIpthread CFLAGS])
 +      temp_result="`$PKG_CONFIG --cflags OpenIPMIpthread`"
 +      if test "$?" = "0"
 +      then
 +              with_libopenipmipthread_cflags="$temp_result"
 +      else
 +              with_libopenipmipthread="no ($PKG_CONFIG --cflags OpenIPMIpthread failed)"
 +              temp_result="$PKG_CONFIG --cflags OpenIPMIpthread failed"
 +      fi
 +      AC_MSG_RESULT([$temp_result])
 +fi
 +
 +if test "x$with_libopenipmipthread" = "xyes"
 +then
 +      AC_MSG_CHECKING([for libOpenIPMIpthread LDFLAGS])
 +      temp_result="`$PKG_CONFIG --libs OpenIPMIpthread`"
 +      if test "$?" = "0"
 +      then
 +              with_libopenipmipthread_ldflags="$temp_result"
 +      else
 +              with_libopenipmipthread="no ($PKG_CONFIG --libs OpenIPMIpthread failed)"
 +              temp_result="$PKG_CONFIG --libs OpenIPMIpthread failed"
 +      fi
 +      AC_MSG_RESULT([$temp_result])
 +fi
 +
 +if test "x$with_libopenipmipthread" = "xyes"
 +then
 +      SAVE_CPPFLAGS="$CPPFLAGS"
 +      CPPFLAGS="$CPPFLAGS $with_libopenipmipthread_cflags"
 +
 +      AC_CHECK_HEADERS(OpenIPMI/ipmi_smi.h,
 +                       [with_libopenipmipthread="yes"],
 +                       [with_libopenipmipthread="no (OpenIPMI/ipmi_smi.h not found)"],
 +[#include <OpenIPMI/ipmiif.h>
 +#include <OpenIPMI/ipmi_err.h>
 +#include <OpenIPMI/ipmi_posix.h>
 +#include <OpenIPMI/ipmi_conn.h>
 +])
 +
 +      CPPFLAGS="$SAVE_CPPFLAGS"
 +fi
 +
 +if test "x$with_libopenipmipthread" = "xyes"
 +then
 +      BUILD_WITH_OPENIPMI_CFLAGS="$with_libopenipmipthread_cflags"
 +      BUILD_WITH_OPENIPMI_LIBS="$with_libopenipmipthread_ldflags"
 +      AC_SUBST(BUILD_WITH_OPENIPMI_CFLAGS)
 +      AC_SUBST(BUILD_WITH_OPENIPMI_LIBS)
 +fi
 +# }}}
  
 -dnl End of check for libvirt and libxml2 libraries.
 +PKG_CHECK_MODULES([LIBNOTIFY], [libnotify],
 +              [with_libnotify="yes"],
 +              [with_libnotify="no ($LIBNOTIFY_PKG_ERRORS)"])
  
  # Check for enabled/disabled features
  #
@@@ -2848,7 -2595,6 +2910,7 @@@ AC_COLLECTD([getifaddrs],[enable],  [fe
  dependency_error="no"
  plugin_ascent="no"
  plugin_battery="no"
 +plugin_bind="no"
  plugin_cpu="no"
  plugin_cpufreq="no"
  plugin_df="no"
  if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes"
  then
        plugin_ascent="yes"
 +      plugin_bind="yes"
  fi
  
  if test "x$with_libopenipmipthread" = "xyes"
@@@ -2957,11 -2702,6 +3019,11 @@@ if test "x$have_processor_info" = "xyes
  then
        plugin_cpu="yes"
  fi
 +if test "x$have_sysctl" = "xyes"
 +then
 +      plugin_cpu="yes"
 +      plugin_swap="yes"
 +fi
  if test "x$have_sysctlbyname" = "xyes"
  then
        plugin_cpu="yes"
        plugin_swap="yes"
  fi
  
 +if test "x$have_swapctl" = "xyes"
 +then
 +      plugin_swap="yes"
 +fi
 +
  if test "x$with_kvm_openfiles$with_kvm_nlist" = "xyesyes"
  then
        plugin_tcpconns="yes"
@@@ -3043,6 -2778,8 +3105,6 @@@ the
        plugin_users="yes"
  fi
  
 -# FIXME: sysctl for swap plugin
 -
  m4_divert_once([HELP_ENABLE], [
  collectd plugins:])
  
@@@ -3051,12 -2788,10 +3113,12 @@@ AC_PLUGIN([apcups],      [yes]
  AC_PLUGIN([apple_sensors], [$with_libiokit],   [Apple's hardware sensors])
  AC_PLUGIN([ascent],      [$plugin_ascent],     [AscentEmu player statistics])
  AC_PLUGIN([battery],     [$plugin_battery],    [Battery statistics])
 -AC_PLUGIN([cpu],         [$plugin_cpu],        [CPU usage statistics])
 +AC_PLUGIN([bind],        [$plugin_bind],       [ISC Bind nameserver 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([notify_desktop], [$with_libnotify], [Desktop notifications])
 +AC_PLUGIN([curl],        [$with_libcurl],      [CURL generic web 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])
@@@ -3066,16 -2801,13 +3128,16 @@@ AC_PLUGIN([exec],        [yes]
  AC_PLUGIN([filecount],   [yes],                [Count files in directories])
  AC_PLUGIN([hddtemp],     [yes],                [Query hddtempd])
  AC_PLUGIN([interface],   [$plugin_interface],  [Interface traffic statistics])
 -AC_PLUGIN([iptables],    [$with_libiptc],      [IPTables rule counters])
  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([libvirt],     [$plugin_libvirt],    [Virtual machine statistics])
  AC_PLUGIN([load],        [$plugin_load],       [System load])
  AC_PLUGIN([logfile],     [yes],                [File logging plugin])
 +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([memcached],   [yes],                [memcached statistics])
  AC_PLUGIN([memory],      [$plugin_memory],     [Memory usage])
@@@ -3085,30 -2817,23 +3147,30 @@@ AC_PLUGIN([netlink],     [$with_libnetl
  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([nut],         [$with_libupsclient], [Network UPS tools statistics])
  AC_PLUGIN([onewire],     [$with_libowcapi],    [OneWire sensor statistics])
 +AC_PLUGIN([openvpn],     [yes],                [OpenVPN client statistics])
 +AC_PLUGIN([oracle],      [$with_oracle],       [Oracle plugin])
  AC_PLUGIN([perl],        [$plugin_perl],       [Embed a Perl interpreter])
  AC_PLUGIN([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([rrdtool],     [$with_rrdtool],      [RRDTool output plugin])
 -AC_PLUGIN([sensors],     [$with_lm_sensors],   [lm_sensors statistics])
 +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([snmp],        [$with_libnetsnmp],   [SNMP querying plugin])
  AC_PLUGIN([swap],        [$plugin_swap],       [Swap usage statistics])
  AC_PLUGIN([syslog],      [$have_syslog],       [Syslog logging plugin])
  AC_PLUGIN([tail],        [yes],                [Parsing of logfiles])
  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_set],  [yes],                [The set target])
  AC_PLUGIN([tcpconns],    [$plugin_tcpconns],   [TCP connection statistics])
  AC_PLUGIN([teamspeak2],  [yes],                [TeamSpeak2 server statistics])
  AC_PLUGIN([thermal],     [$plugin_thermal],    [Linux ACPI thermal zone statistics])
  AC_SUBST(PERL_BINDINGS)
  AC_SUBST(PERL_BINDINGS_OPTIONS)
  
 -AC_OUTPUT(Makefile src/Makefile src/collectd.conf src/libiptc/Makefile src/liboconfig/Makefile src/liboping/Makefile bindings/Makefile)
 +dnl libcollectdclient
 +LCC_VERSION_MAJOR=`echo $PACKAGE_VERSION | cut -d'.' -f1`
 +LCC_VERSION_MINOR=`echo $PACKAGE_VERSION | cut -d'.' -f2`
 +LCC_VERSION_PATCH=`echo $PACKAGE_VERSION | cut -d'.' -f3`
 +
 +LCC_VERSION_EXTRA=`echo $PACKAGE_VERSION | cut -d'.' -f4-`
 +
 +LCC_VERSION_STRING="$LCC_VERSION_MAJOR.$LCC_VERSION_MINOR.$LCC_VERSION_PATCH"
  
 -if test "x$with_rrdtool" = "xyes" \
 +AC_SUBST(LCC_VERSION_MAJOR)
 +AC_SUBST(LCC_VERSION_MINOR)
 +AC_SUBST(LCC_VERSION_PATCH)
 +AC_SUBST(LCC_VERSION_EXTRA)
 +AC_SUBST(LCC_VERSION_STRING)
 +
 +AC_CONFIG_FILES(src/libcollectdclient/lcc_features.h)
 +
 +AC_OUTPUT(Makefile src/Makefile src/collectd.conf src/libiptc/Makefile src/libcollectdclient/Makefile src/libcollectdclient/libcollectdclient.pc src/liboconfig/Makefile src/liboping/Makefile bindings/Makefile)
 +
 +if test "x$with_librrd" = "xyes" \
        && test "x$librrd_threadsafe" != "xyes"
  then
 -      with_rrdtool="yes (warning: librrd is not thread-safe)"
 +      with_librrd="yes (warning: librrd is not thread-safe)"
  fi
  
  if test "x$with_liboping" = "xyes" \
@@@ -3211,7 -2919,6 +3273,7 @@@ cat <<EOF
  Configuration:
    Libraries:
      libcurl . . . . . . . $with_libcurl
 +    libdbi  . . . . . . . $with_libdbi
      libesmtp  . . . . . . $with_libesmtp
      libiokit  . . . . . . $with_libiokit
      libiptc . . . . . . . $with_libiptc
      libopenipmi . . . . . $with_libopenipmipthread
      liboping  . . . . . . $with_liboping
      libpcap . . . . . . . $with_libpcap
 +    libpcre . . . . . . . $with_libpcre
      libperl . . . . . . . $with_libperl
 -    libpthread  . . . . . $with_libpthread
      libpq . . . . . . . . $with_libpq
 -    librrd  . . . . . . . $with_rrdtool
 -    libsensors  . . . . . $with_lm_sensors
 +    libpthread  . . . . . $with_libpthread
 +    librrd  . . . . . . . $with_librrd
 +    libsensors  . . . . . $with_libsensors
      libstatgrab . . . . . $with_libstatgrab
      libupsclient  . . . . $with_libupsclient
      libvirt . . . . . . . $with_libvirt
      libxml2 . . . . . . . $with_libxml2
      libxmms . . . . . . . $with_libxmms
 +    oracle  . . . . . . . $with_oracle
  
    Features:
      daemon mode . . . . . $enable_daemon
      apple_sensors . . . . $enable_apple_sensors
      ascent  . . . . . . . $enable_ascent
      battery . . . . . . . $enable_battery
 +    bind  . . . . . . . . $enable_bind
      cpu . . . . . . . . . $enable_cpu
      cpufreq . . . . . . . $enable_cpufreq
      csv . . . . . . . . . $enable_csv
 +    curl  . . . . . . . . $enable_curl
 +    dbi . . . . . . . . . $enable_dbi
      df  . . . . . . . . . $enable_df
      disk  . . . . . . . . $enable_disk
      dns . . . . . . . . . $enable_dns
      filecount . . . . . . $enable_filecount
      hddtemp . . . . . . . $enable_hddtemp
      interface . . . . . . $enable_interface
 -    iptables  . . . . . . $enable_iptables
      ipmi  . . . . . . . . $enable_ipmi
 +    iptables  . . . . . . $enable_iptables
      ipvs  . . . . . . . . $enable_ipvs
      irq . . . . . . . . . $enable_irq
      libvirt . . . . . . . $enable_libvirt
      load  . . . . . . . . $enable_load
      logfile . . . . . . . $enable_logfile
 +    match_regex . . . . . $enable_match_regex
 +    match_timediff  . . . $enable_match_timediff
 +    match_value . . . . . $enable_match_value
      mbmon . . . . . . . . $enable_mbmon
      memcached . . . . . . $enable_memcached
      memory  . . . . . . . $enable_memory
      ntpd  . . . . . . . . $enable_ntpd
      nut . . . . . . . . . $enable_nut
      onewire . . . . . . . $enable_onewire
 +    openvpn . . . . . . . $enable_openvpn
 +    oracle  . . . . . . . $enable_oracle
      perl  . . . . . . . . $enable_perl
      ping  . . . . . . . . $enable_ping
      postgresql  . . . . . $enable_postgresql
      powerdns  . . . . . . $enable_powerdns
      processes . . . . . . $enable_processes
 +    rrdcached . . . . . . $enable_rrdcached
      rrdtool . . . . . . . $enable_rrdtool
      sensors . . . . . . . $enable_sensors
      serial  . . . . . . . $enable_serial
      syslog  . . . . . . . $enable_syslog
      tail  . . . . . . . . $enable_tail
      tape  . . . . . . . . $enable_tape
 +    target_notification . $enable_target_notification
 +    target_replace  . . . $enable_target_replace
 +    target_set  . . . . . $enable_target_set
      tcpconns  . . . . . . $enable_tcpconns
      teamspeak2  . . . . . $enable_teamspeak2
      thermal . . . . . . . $enable_thermal
@@@ -3325,5 -3018,3 +3387,5 @@@ EO
  if test "x$dependency_error" = "xyes"; then
        AC_MSG_ERROR("Some plugins are missing dependencies - see above summary for details")
  fi
 +
 +# vim: set fdm=marker :
diff --combined src/collectd.conf.pod
@@@ -126,14 -126,6 +126,14 @@@ The sample config file that is installe
  line which sets this option, though, so that default installations will have
  this setting enabled.
  
 +=item B<PreCacheChain> I<ChainName>
 +
 +=item B<PostCacheChain> I<ChainName>
 +
 +Configure the name of the "pre-cache chain" and the "post-cache chain". Please
 +see L<FILTER CONFIGURATION> below on information on chains and how these
 +setting change the daemon's behavior.
 +
  =back
  
  =head1 PLUGIN OPTIONS
@@@ -265,150 -257,6 +265,150 @@@ and are checked by default depends on t
  
  =back
  
 +=head2 Plugin C<bind>
 +
 +Starting with BIND 9.5.0, the most widely used DNS server software provides
 +extensive statistics about queries, responses and lots of other information.
 +The bind plugin retrieves this information that's encoded in XML and provided
 +via HTTP and submits the values to collectd.
 +
 +To use this plugin, you first need to tell BIND to make this information
 +available. This is done with the C<statistics-channels> configuration option:
 +
 + statistics-channels {
 +   inet localhost port 8053;
 + };
 +
 +The configuration follows the grouping that can be seen when looking at the
 +data with an XSLT compatible viewer, such as a modern web browser. It's
 +probably a good idea to make yourself familiar with the provided values, so you
 +can understand what the collected statistics actually mean.
 +
 +Synopsis:
 +
 + <Plugin "bind">
 +   URL "http://localhost:8053/"
 +   OpCodes         true
 +   QTypes          true
 + 
 +   ServerStats     true
 +   ZoneMaintStats  true
 +   ResolverStats   false
 +   MemoryStats     true
 + 
 +   <View "_default">
 +     QTypes        true
 +     ResolverStats true
 +     CacheRRSets   true
 + 
 +     Zone "127.in-addr.arpa/IN"
 +   </View>
 + </Plugin>
 +
 +The bind plugin accepts the following configuration options:
 +
 +=over 4
 +
 +=item B<URL> I<URL>
 +
 +URL from which to retrieve the XML data. If not specified,
 +C<http://localhost:8053/> will be used.
 +
 +=item B<OpCodes> I<true>|I<false>
 +
 +When enabled, statistics about the I<"OpCodes">, for example the number of
 +C<QUERY> packets, are collected.
 +
 +Default: Enabled.
 +
 +=item B<QTypes> I<true>|I<false>
 +
 +When enabled, the number of I<incoming> queries by query types (for example
 +C<A>, C<MX>, C<AAAA>) is collected.
 +
 +Default: Enabled.
 +
 +=item B<ServerStats> I<true>|I<false>
 +
 +Collect global server statistics, such as requests received over IPv4 and IPv6,
 +successful queries, and failed updates.
 +
 +Default: Enabled.
 +
 +=item B<ZoneMaintStats> I<true>|I<false>
 +
 +Collect zone maintenance statistics, mostly information about notifications
 +(zone updates) and zone transfers.
 +
 +Default: Enabled.
 +
 +=item B<ResolverStats> I<true>|I<false>
 +
 +Collect resolver statistics, i.E<nbsp>e. statistics about outgoing requests
 +(e.E<nbsp>g. queries over IPv4, lame servers). Since the global resolver
 +counters apparently were removed in BIND 9.5.1 and 9.6.0, this is disabled by
 +default. Use the B<ResolverStats> option within a B<View "_default"> block
 +instead for the same functionality.
 +
 +Default: Disabled.
 +
 +=item B<MemoryStats>
 +
 +Collect global memory statistics.
 +
 +Default: Enabled.
 +
 +=item B<View> I<Name>
 +
 +Collect statistics about a specific I<"view">. BIND can behave different,
 +mostly depending on the source IP-address of the request. These different
 +configurations are called "views". If you don't use this feature, you most
 +likely are only interested in the C<_default> view.
 +
 +Within a E<lt>B<View>E<nbsp>I<name>E<gt> block, you can specify which
 +information you want to collect about a view. If no B<View> block is
 +configured, no detailed view statistics will be collected.
 +
 +=over 4
 +
 +=item B<QTypes> I<true>|I<false>
 +
 +If enabled, the number of I<outgoing> queries by query type (e.E<nbsp>g. C<A>,
 +C<MX>) is collected.
 +
 +Default: Enabled.
 +
 +=item B<ResolverStats> I<true>|I<false>
 +
 +Collect resolver statistics, i.E<nbsp>e. statistics about outgoing requests
 +(e.E<nbsp>g. queries over IPv4, lame servers).
 +
 +Default: Enabled.
 +
 +=item B<CacheRRSets> I<true>|I<false>
 +
 +If enabled, the number of entries (I<"RR sets">) in the view's cache by query
 +type is collected. Negative entries (queries which resulted in an error, for
 +example names that do not exist) are reported with a leading exclamation mark,
 +e.E<nbsp>g. "!A".
 +
 +Default: Enabled.
 +
 +=item B<Zone> I<Name>
 +
 +When given, collect detailed information about the given zone in the view. The
 +information collected if very similar to the global B<ServerStats> information
 +(see above).
 +
 +You can repeat this option to collect detailed information about multiple
 +zones.
 +
 +By default no detailed zone information is collected.
 +
 +=back
 +
 +=back
 +
  =head2 Plugin C<cpufreq>
  
  This plugin doesn't have any options. It reads
@@@ -425,9 -273,6 +425,9 @@@ installed and an "cpu governor" (that'
  
  Set the directory to store CSV-files under. Per default CSV-files are generated
  beneath the daemon's working directory, i.E<nbsp>e. the B<BaseDir>.
 +The special strings B<stdout> and B<stderr> can be used to write to the standard
 +output and standard error channels, respectively. This, of course, only makes
 +much sense when collectd is running in foreground- or non-daemon-mode.
  
  =item B<StoreRates> B<true|false>
  
@@@ -437,309 -282,6 +437,309 @@@ number
  
  =back
  
 +=head2 Plugin C<curl>
 +
 +The curl plugin uses the B<libcurl> (L<http://curl.haxx.se/>) to read web pages
 +and the match infrastructure (the same code used by the tail plugin) to use
 +regular expressions with the received data.
 +
 +The following example will read the current value of AMD stock from google's
 +finance page and dispatch the value to collectd.
 +
 +  <Plugin curl>
 +    <Page "stock_quotes">
 +      URL "http://finance.google.com/finance?q=NYSE%3AAMD"
 +      User "foo"
 +      Password "bar"
 +      <Match>
 +        Regex "<span +class=\"pr\"[^>]*> *([0-9]*\\.[0-9]+) *</span>"
 +        DSType "GaugeAverage"
 +      # Note: `stock_value' is not a standard type.
 +        Type "stock_value"
 +        Instance "AMD"
 +      </Match>
 +    </Page>
 +  </Plugin>
 +
 +In the B<Plugin> block, there may be one or more B<Page> blocks, each defining
 +a web page and one or more "matches" to be performed on the returned data. The
 +string argument to the B<Page> block is used as plugin instance.
 +
 +The following options are valid within B<Page> blocks:
 +
 +=over 4
 +
 +=item B<URL> I<URL>
 +
 +URL of the web site to retrieve. Since a regular expression will be used to
 +extract information from this data, non-binary data is a big plus here ;)
 +
 +=item B<User> I<Name>
 +
 +Username to use if authorization is required to read the page.
 +
 +=item B<Password> I<Password>
 +
 +Password to use if authorization is required to read the page.
 +
 +=item B<VerifyPeer> B<true>|B<false>
 +
 +Enable or disable peer SSL certificate verification. See
 +L<http://curl.haxx.se/docs/sslcerts.html> for details. Enabled by default.
 +
 +=item B<VerifyHost> B<true>|B<false>
 +
 +Enable or disable peer host name verification. If enabled, the plugin checks if
 +the C<Common Name> or a C<Subject Alternate Name> field of the SSL certificate
 +matches the host name provided by the B<URL> option. If this identity check
 +fails, the connection is aborted. Obviously, only works when connecting to a
 +SSL enabled server. Enabled by default.
 +
 +=item B<CACert> I<file>
 +
 +File that holds one or more SSL certificates. If you want to use HTTPS you will
 +possibly need this option. What CA certificates come bundled with C<libcurl>
 +and are checked by default depends on the distribution you use.
 +
 +=item B<E<lt>MatchE<gt>>
 +
 +One or more B<Match> blocks that define how to match information in the data
 +returned by C<libcurl>. The C<curl> plugin uses the same infrastructure that's
 +used by the C<tail> plugin, so please see the documentation of the C<tail>
 +plugin below on how matches are defined.
 +
 +=back
 +
 +=head2 Plugin C<dbi>
 +
 +This plugin uses the B<dbi> library (L<http://libdbi.sourceforge.net/>) to
 +connect to various databases, execute I<SQL> statements and read back the
 +results. I<dbi> is an acronym for "database interface" in case you were
 +wondering about the name. You can configure how each column is to be
 +interpreted and the plugin will generate one or more data sets from each row
 +returned according to these rules.
 +
 +Because the plugin is very generic, the configuration is a little more complex
 +than those of other plugins. It usually looks something like this:
 +
 +  <Plugin dbi>
 +    <Query "out_of_stock">
 +      Statement "SELECT category, COUNT(*) AS value FROM products WHERE in_stock = 0 GROUP BY category"
 +      # Use with MySQL 5.0.0 or later
 +      MinVersion 50000
 +      <Result>
 +        Type "gauge"
 +      InstancePrefix "out_of_stock"
 +        InstancesFrom "category"
 +        ValuesFrom "value"
 +      </Result>
 +    </Query>
 +    <Database "product_information">
 +      Driver "mysql"
 +      DriverOption "host" "localhost"
 +      DriverOption "username" "collectd"
 +      DriverOption "password" "aZo6daiw"
 +      DriverOption "dbname" "prod_info"
 +      SelectDB "prod_info"
 +      Query "out_of_stock"
 +    </Database>
 +  </Plugin>
 +
 +The configuration above defines one query with one result and one database. The
 +query is then linked to the database with the B<Query> option I<within> the
 +B<E<lt>DatabaseE<gt>> block. You can have any number of queries and databases
 +and you can also use the B<Include> statement to split up the configuration
 +file in multiple, smaller files. However, the B<E<lt>QueryE<gt>> block I<must>
 +precede the B<E<lt>DatabaseE<gt>> blocks, because the file is interpreted from
 +top to bottom!
 +
 +The following is a complete list of options:
 +
 +=head3 B<Query> blocks
 +
 +Query blocks define I<SQL> statements and how the returned data should be
 +interpreted. They are identified by the name that is given in the opening line
 +of the block. Thus the name needs to be unique. Other than that, the name is
 +not used in collectd. 
 +
 +In each B<Query> block, there is one or more B<Result> blocks. B<Result> blocks
 +define which column holds which value or instance information. You can use
 +multiple B<Result> blocks to create multiple values from one returned row. This
 +is especially useful, when queries take a long time and sending almost the same
 +query again and again is not desirable.
 +
 +Example:
 +
 +  <Query "environment">
 +    Statement "select station, temperature, humidity from environment"
 +    <Result>
 +      Type "temperature"
 +      # InstancePrefix "foo"
 +      InstancesFrom "station"
 +      ValuesFrom "temperature"
 +    </Result>
 +    <Result>
 +      Type "humidity"
 +      InstancesFrom "station"
 +      ValuesFrom "humidity"
 +    </Result>
 +  </Query>
 +
 +The following options are accepted:
 +
 +=over 4
 +
 +=item B<Statement> I<SQL>
 +
 +Sets the statement that should be executed on the server. This is B<not>
 +interpreted by collectd, but simply passed to the database server. Therefore,
 +the SQL dialect that's used depends on the server collectd is connected to.
 +
 +The query has to return at least two columns, one for the instance and one
 +value. You cannot omit the instance, even if the statement is guaranteed to
 +always return exactly one line. In that case, you can usually specify something
 +like this:
 +
 +  Statement "SELECT \"instance\", COUNT(*) AS value FROM table"
 +
 +(That works with MySQL but may not be valid SQL according to the spec. If you
 +use a more strict database server, you may have to select from a dummy table or
 +something.)
 +
 +=item B<MinVersion> I<Version>
 +
 +=item B<MaxVersion> I<Value>
 +
 +Only use this query for the specified database version. You can use these
 +options to provide multiple queries with the same name but with a slightly
 +different syntax. The plugin will use only those queries, where the specified
 +minimum and maximum versions fit the version of the database in use.
 +
 +The database version is determined by C<dbi_conn_get_engine_version>, see the 
 +L<libdbi documentation|http://libdbi.sourceforge.net/docs/programmers-guide/reference-conn.html#DBI-CONN-GET-ENGINE-VERSION>
 +for details. Basically, each part of the version is assumed to be in the range
 +from B<00> to B<99> and all dots are removed. So version "4.1.2" becomes
 +"40102", version "5.0.42" becomes "50042".
 +
 +B<Warning:> The plugin will use B<all> matching queries, so if you specify
 +multiple queries with the same name and B<overlapping> ranges, weird stuff will
 +happen. Don't to it! A valid example would be something along these lines:
 +
 +  MinVersion 40000
 +  MaxVersion 49999
 +  ...
 +  MinVersion 50000
 +  MaxVersion 50099
 +  ...
 +  MinVersion 50100
 +  # No maximum
 +
 +In the above example, there are three ranges that don't overlap. The last one
 +goes from version "5.1.0" to infinity, meaning "all later versions". Versions
 +before "4.0.0" are not specified.
 +
 +=item B<Type> I<Type>
 +
 +The B<type> that's used for each line returned. See L<types.db(5)> for more
 +details on how types are defined. In short: A type is a predefined layout of
 +data and the number of values and type of values has to match the type
 +definition.
 +
 +If you specify "temperature" here, you need exactly one gauge column. If you
 +specify "if_octets", you will need two counter columns. See the B<ValuesFrom>
 +setting below.
 +
 +There must be exactly one B<Type> option inside each B<Result> block.
 +
 +=item B<InstancePrefix> I<prefix>
 +
 +Prepends I<prefix> followed by a dash I<("-")> to the type instance. See
 +B<InstancesFrom> on how the rest of the type instance is built.
 +
 +=item B<InstancesFrom> I<column0> [I<column1> ...]
 +
 +Specifies the columns whose values will be used to create the "TypeInstance"
 +for each row. You need to specify at least one column for each query. If you
 +specify more than one column, the value of all columns will be join together
 +with the hyphen as separation character.
 +
 +The plugin itself does not check whether or not all built instances are
 +different. It's your responsibility to assure that each is unique.
 +
 +There must be at least one B<InstancesFrom> option inside each B<Result> block.
 +
 +=item B<ValuesFrom> I<column0> [I<column1> ...]
 +
 +Names the columns whose content is used as the actual data for the data sets
 +that are dispatched to the daemon. How many such columns you need is determined
 +by the B<Type> setting above. If you specify too many or not enough columns,
 +the plugin will complain about that and no data will be submitted to the
 +daemon.
 +
 +The actual data type in the columns is not that important. The plugin will
 +automatically cast the values to the right type if it know how to do that. So
 +it should be able to handle integer an floating point types, as well as strings
 +(if they include a number at the beginning).
 +
 +There must be at least one B<ValuesFrom> option inside each B<Result> block.
 +
 +=back
 +
 +=head3 B<Database> blocks
 +
 +Database blocks define a connection to a database and which queries should be
 +sent to that database. Since the used "dbi" library can handle a wide variety
 +of databases, the configuration is very generic. If in doubt, refer to libdbi's
 +documentationE<nbsp>- we stick as close to the terminology used there.
 +
 +Each database needs a "name" as string argument in the starting tag of the
 +block. This name will be used as "PluginInstance" in the values submitted to
 +the daemon. Other than that, that name is not used.
 +
 +=over 4
 +
 +=item B<Driver> I<Driver>
 +
 +Specifies the driver to use to connect to the database. In many cases those
 +drivers are named after the database they can connect to, but this is not a
 +technical necessity. These drivers are sometimes referred to as "DBD",
 +B<D>ataB<B>ase B<D>river, and some distributions ship them in separate
 +packages. Drivers for the "dbi" library are developed by the B<libdbi-drivers>
 +project at L<http://libdbi-drivers.sourceforge.net/>.
 +
 +You need to give the driver name as expected by the "dbi" library here. You
 +should be able to find that in the documentation for each driver. If you
 +mistype the driver name, the plugin will dump a list of all known driver names
 +to the log.
 +
 +=item B<DriverOption> I<Key> I<Value>
 +
 +Sets driver-specific options. What option a driver supports can be found in the
 +documentation for each driver, somewhere at
 +L<http://libdbi-drivers.sourceforge.net/>. However, the options "host",
 +"username", "password", and "dbname" seem to be deE<nbsp>facto standards.
 +
 +Unfortunately, drivers are not too keen to report errors when an unknown option
 +is passed to them, so invalid settings here may go unnoticed. This is not the
 +plugin's fault, it will report errors if it gets them from the libraryE<nbsp>/
 +the driver. If a driver complains about an option, the plugin will dump a
 +complete list of all options understood by that driver to the log.
 +
 +=item B<SelectDB> I<Database>
 +
 +In some cases, the database name you connect with is not the database name you
 +want to use for querying data. If this option is set, the plugin will "select"
 +(switch to) that database after the connection is established.
 +
 +=item B<Query> I<QueryName>
 +
 +Associates the query named I<QueryName> with this database connection. The
 +query needs to be defined I<before> this statement, i.E<nbsp>e. all query
 +blocks you want to refer to must be placed above the database block you want to
 +refer to them from.
 +
 +=back
 +
  =head2 Plugin C<df>
  
  =over 4
@@@ -949,101 -491,6 +949,101 @@@ description see above. Valid multiplier
  C<m> (megabyte), C<g> (gigabyte), C<t> (terabyte), and C<p> (petabyte). Please
  note that there are 1000 bytes in a kilobyte, not 1024.
  
 +=item B<Recursive> I<true>|I<false>
 +
 +Controls whether or not to recurse into subdirectories. Enabled by default.
 +
 +=back
 +
 +=head2 Plugin C<filter_pcre>
 +
 +This plugin allows you to filter and rewrite value lists based on
 +Perl-compatible regular expressions whose syntax and semantics are as close as
 +possible to those of the Perl 5 language. See L<pcre(3)> for details.
 +
 +  <Plugin filter_pcre>
 +    <RegEx>
 +      Host "^mail\d+$"
 +      Plugin "^tcpconns$"
 +      TypeInstance "^SYN_"
 +
 +      Action NoWrite
 +    </RegEx>
 +
 +    <RegEx>
 +      Plugin "^sensors$"
 +      PluginInstance "^Some Weird Sensor Chip Name Prefix"
 +
 +      SubstitutePluginInstance "foo"
 +    </RegEx>
 +  </Plugin>
 +
 +The configuration consists of one or more C<RegEx> blocks, each of which
 +specifies a regular expression identifying a set of value lists and how to
 +handle successful matches. A value list keeps the values of a single data-set
 +and is identified by the tuple (host, plugin, plugin instance, type, type
 +instance). The plugin and type instances are optional components. If they are
 +missing they are treated as empty strings. Within those blocks, the following
 +options are recognized:
 +
 +=over 4
 +
 +=item B<Host> I<regex>
 +
 +=item B<Plugin> I<regex>
 +
 +=item B<PluginInstance> I<regex>
 +
 +=item B<Type> I<regex>
 +
 +=item B<TypeInstance> I<regex>
 +
 +Specifies the regular expression for each component of the identifier. If any
 +of these options is missing it is interpreted as a pattern which matches any
 +string. All five components of a value list have to match the appropriate
 +regular expression to trigger the specified action.
 +
 +=item B<Action> I<NoWrite>|I<NoThresholdCheck>|I<Ignore>
 +
 +Specify how to handle successful matches:
 +
 +=over 4
 +
 +=item B<NoWrite>
 +
 +Do not send the value list to any output (a.k.a. write) plugins.
 +
 +=item B<NoThresholdCheck>
 +
 +Skip threshold checking for this value list.
 +
 +=item B<Ignore>
 +
 +Completely ignore this value list.
 +
 +=back
 +
 +Two or more actions may be combined by specifying multiple B<Action> options.
 +
 +=item B<SubstituteHost> I<replacement>
 +
 +=item B<SubstitutePlugin> I<replacement>
 +
 +=item B<SubstitutePluginInstance> I<replacement>
 +
 +=item B<SubstituteType> I<replacement>
 +
 +=item B<SubstituteTypeInstance> I<replacement>
 +
 +Upon a successful match, the matching substring will be replaced by the
 +specified I<replacement> text. These options require that an appropriate regex
 +has been specified before, e.E<nbsp>g. B<SubstituteHost> requires that the
 +B<Host> option has been specified before.
 +
 +B<Note>: It is not recommended to modify the type unless you really know what
 +you are doing. The type is used to identify the data-set definition of the
 +dispatched values.
 +
  =back
  
  =head2 Plugin C<hddtemp>
@@@ -1272,10 -719,6 +1272,10 @@@ Prefix all lines printed by the curren
  
  =back
  
 +B<Note>: There is no need to notify the daemon after moving or removing the
 +log file (e.E<nbsp>g. when rotating the logs). The plugin reopens the file
 +for each line it writes.
 +
  =head2 Plugin C<mbmon>
  
  The C<mbmon plugin> uses mbmon to retrieve temperature, voltage, etc.
@@@ -1356,23 -799,6 +1356,23 @@@ Password needed to log into the databas
  Select this database. Defaults to I<no database> which is a perfectly reasonable
  option for what this plugin does.
  
 +=item B<Port> I<Port>
 +
 +TCP-port to connect to. The port must be specified in its numeric form, but it
 +must be passed as a string nonetheless. For example:
 +
 +  Port "3306"
 +
 +If B<Host> is set to B<localhost> (the default), this setting has no effect.
 +See the documentation for the C<mysql_real_connect> function for details.
 +
 +=item B<Socket> I<Socket>
 +
 +Specifies the path to the UNIX domain socket of the MySQL server. This option
 +only has any effect, if B<Host> is set to B<localhost> (the default).
 +Otherwise, use the B<Port> option above. See the documentation for the
 +C<mysql_real_connect> function for details.
 +
  =back
  
  =head2 Plugin C<netlink>
@@@ -1581,6 -1007,61 +1581,61 @@@ has been specified, the default is use
  
  =back
  
+ =head2 Plugin C<notify_email>
+ The I<notify_email> plugin uses the I<ESMTP> library to send notifications to a
+ configured email address.
+ I<libESMTP> is available from L<http://www.stafford.uklinux.net/libesmtp/>.
+ Available configuration options:
+ =over 4
+ =item B<From> I<Address>
+ Email address from which the emails should appear to come from.
+ Default: C<root@localhost>
+ =item B<Recipient> I<Address>
+ Configures the email address(es) to which the notifications should be mailed.
+ May be repeated to send notifications to multiple addresses.
+ At least one B<Recipient> must be present for the plugin to work correctly.
+ =item B<SMTPServer> I<Hostname>
+ Hostname of the SMTP server to connect to.
+ Default: C<localhost>
+ =item B<SMTPPort> I<Port>
+ TCP port to connect to.
+ Default: C<25>
+ =item B<SMTPUser> I<Username>
+ Username for ASMTP authentication. Optional.
+ =item B<SMTPPassword> I<Password>
+ Password for ASMTP authentication. Optional.
+ =item B<Subject> I<Subject>
+ Subject-template to use when sending emails. There must be exactly two
+ string-placeholders in the subject, given in the standard I<printf(3)> syntax,
+ i.E<nbsp>e. C<%s>. The first will be replaced with the severity, the second
+ with the hostname.
+ Default: C<Collectd notify: %s@%s>
+ =back
  =head2 Plugin C<ntpd>
  
  =over 4
@@@ -1670,99 -1151,11 +1725,99 @@@ controller, but as soon as you throw i
  or two, reading all values will take more than ten seconds (the default
  interval). We will probably add some separate thread for reading the sensors
  and some cache or something like that, but it's not done yet. We will try to
 -maintain backwards compatibility in the future, but we can't probmise. So in
 -short: If it works for you: Great! But kaap in mind that the config I<might>
 +maintain backwards compatibility in the future, but we can't promise. So in
 +short: If it works for you: Great! But keep in mind that the config I<might>
  change, though this is unlikely. Oh, and if you want to help improving this
  plugin, just send a short notice to the mailing list. ThanksE<nbsp>:)
  
 +=head2 Plugin C<openvpn>
 +
 +The OpenVPN plugin reads a status file maintained by OpenVPN and gathers
 +traffic statistics about connected clients.
 +
 +To set up OpenVPN to write to the status file periodically, use the
 +B<--status> option of OpenVPN. Since OpenVPN can write two different formats,
 +you need to set the required format, too. This is done by setting
 +B<--status-version> to B<2>.
 +
 +So, in a nutshell you need:
 +
 +  openvpn $OTHER_OPTIONS \
 +    --status "/var/run/openvpn-status" 10 \
 +    --status-version 2
 +
 +Available options:
 +
 +=over 4
 +
 +=item B<StatusFile> I<File>
 +
 +Specifies the location of the status file.
 +
 +=back
 +
 +=head2 Plugin C<oracle>
 +
 +The "oracle" plugin uses the Oracle® Call Interface I<(OCI)> to connect to an
 +Oracle® Database and lets you execute SQL statements there. It is very similar
 +to the "dbi" plugin, because it was written around the same time. See the "dbi"
 +plugin's documentation above for details.
 +
 +  <Plugin oracle>
 +    <Query "out_of_stock">
 +      Statement "SELECT category, COUNT(*) AS value FROM products WHERE in_stock = 0 GROUP BY category"
 +      <Result>
 +        Type "gauge"
 +        # InstancePrefix "foo"
 +        InstancesFrom "category"
 +        ValuesFrom "value"
 +      </Result>
 +    </Query>
 +    <Database "product_information">
 +      ConnectID "db01"
 +      Username "oracle"
 +      Password "secret"
 +      Query "out_of_stock"
 +    </Database>
 +  </Plugin>
 +
 +=head3 B<Query> blocks
 +
 +The Query blocks are handled identically to the Query blocks of the "dbi"
 +plugin. Please see its documentation above for details on how to specify
 +queries.
 +
 +=head3 B<Database> blocks
 +
 +Database blocks define a connection to a database and which queries should be
 +sent to that database. Each database needs a "name" as string argument in the
 +starting tag of the block. This name will be used as "PluginInstance" in the
 +values submitted to the daemon. Other than that, that name is not used.
 +
 +=over 4
 +
 +=item B<ConnectID> I<ID>
 +
 +Defines the "database alias" or "service name" to connect to. Usually, these
 +names are defined in the file named C<$ORACLE_HOME/network/admin/tnsnames.ora>.
 +
 +=item B<Username> I<Username>
 +
 +Username used for authentication.
 +
 +=item B<Password> I<Password>
 +
 +Password used for authentication.
 +
 +=item B<Query> I<QueryName>
 +
 +Associates the query named I<QueryName> with this database connection. The
 +query needs to be defined I<before> this statement, i.E<nbsp>e. all query
 +blocks you want to refer to must be placed above the database block you want to
 +refer to them from.
 +
 +=back
 +
  =head2 Plugin C<perl>
  
  This plugin embeds a Perl-interpreter into collectd and provides an interface
@@@ -1806,28 -1199,10 +1861,28 @@@ L<http://www.postgresql.org/docs/manual
  
    <Plugin postgresql>
      <Query magic>
 -      Query "SELECT magic, spells FROM wizard WHERE host = $1;"
 +      Statement "SELECT magic FROM wizard WHERE host = $1;"
        Param hostname
 -      Column gauge magic
 -      Column counter spells
 +      <Result>
 +        Type gauge
 +        InstancePrefix "magic"
 +        ValuesFrom magic
 +      </Result>
 +    </Query>
 +
 +    <Query rt36_tickets>
 +      Statement "SELECT COUNT(type) AS count, type \
 +                        FROM (SELECT CASE \
 +                                     WHEN resolved = 'epoch' THEN 'open' \
 +                                     ELSE 'resolved' END AS type \
 +                                     FROM tickets) type \
 +                        GROUP BY type;"
 +      <Result>
 +        Type counter
 +        InstancePrefix "rt36_tickets"
 +        InstancesFrom "type"
 +        ValuesFrom "count"
 +      </Result>
      </Query>
  
      <Database foo>
        KRBSrvName "kerberos_service_name"
        Query magic
      </Database>
 +
      <Database bar>
        Service "service_name"
 +      Query backend # predefined
 +      Query rt36_tickets
      </Database>
    </Plugin>
  
  The B<Query> block defines one database query which may later be used by a
  database definition. It accepts a single mandatory argument which specifies
 -the name of the query. The names of all queries have to be unique. The
 -following configuration options are available to define the query:
 +the name of the query. The names of all queries have to be unique (see the
 +B<MinPGVersion> and B<MaxPGVersion> options below for an exception to this
 +rule). The following configuration options are available to define the query:
 +
 +In each B<Query> block, there is one or more B<Result> blocks. B<Result>
 +blocks define how to handle the values returned from the query. They define
 +which column holds which value and how to dispatch that value to the daemon.
 +Multiple B<Result> blocks may be used to extract multiple values from a single
 +query.
  
  =over 4
  
 -=item B<Query> I<sql query>
 +=item B<Statement> I<sql query statement>
  
 -Specify the I<sql query> which the plugin should execute. The string may
 -contain the tokens B<$1>, B<$2>, etc. which are used to reference the first,
 -second, etc. parameter. The value of the parameters is specified by the
 +Specify the I<sql query statement> which the plugin should execute. The string
 +may contain the tokens B<$1>, B<$2>, etc. which are used to reference the
 +first, second, etc. parameter. The value of the parameters is specified by the
  B<Param> configuration option - see below for details. To include a literal
  B<$> character followed by a number, surround it with single quotes (B<'>).
  
@@@ -1873,14 -1238,7 +1928,14 @@@ Any SQL command which may return data (
  allowed. Note, however, that only a single command may be used. Semicolons are
  allowed as long as a single non-empty command has been specified only.
  
 -=item B<Param> I<hostname>|I<database>|I<username>
 +The returned lines will be handled separately one after another.
 +
 +=item B<Query> I<sql query statement>
 +
 +This is a deprecated synonym for B<Statement>. It will be removed in version 5
 +of collectd.
 +
 +=item B<Param> I<hostname>|I<database>|I<username>|I<interval>
  
  Specify the parameters which should be passed to the SQL query. The parameters
  are referred to in the SQL query as B<$1>, B<$2>, etc. in the same order as
@@@ -1902,72 -1260,17 +1957,72 @@@ The name of the database of the curren
  
  The username used to connect to the database.
  
 +=item I<interval>
 +
 +The interval collectd is using (as specified by the B<Interval> option).
 +
  =back
  
  Please note that parameters are only supported by PostgreSQL's protocol
  version 3 and above which was introduced in version 7.4 of PostgreSQL.
  
 +=item B<Type> I<type>
 +
 +The I<type> name to be used when dispatching the values. The type describes
 +how to handle the data and where to store it. See L<types.db(5)> for more
 +details on types and their configuration. The number and type of values (as
 +selected by the B<ValuesFrom> option) has to match the type of the given name.
 +
 +This option is required inside a B<Result> block.
 +
 +=item B<InstancePrefix> I<prefix>
 +
 +=item B<InstancesFrom> I<column0> [I<column1> ...]
 +
 +Specify how to create the "TypeInstance" for each data set (i.E<nbsp>e. line).
 +B<InstancePrefix> defines a static prefix that will be prepended to all type
 +instances. B<InstancesFrom> defines the column names whose values will be used
 +to create the type instance. Multiple values will be joined together using the
 +hyphen (C<->) as separation character.
 +
 +The plugin itself does not check whether or not all built instances are
 +different. It is your responsibility to assure that each is unique.
 +
 +Both options are optional. If none is specified, the type instance will be
 +empty.
 +
 +=item B<ValuesFrom> I<column0> [I<column1> ...]
 +
 +Names the columns whose content is used as the actual data for the data sets
 +that are dispatched to the daemon. How many such columns you need is
 +determined by the B<Type> setting as explained above. If you specify too many
 +or not enough columns, the plugin will complain about that and no data will be
 +submitted to the daemon.
 +
 +The actual data type, as seen by PostgreSQL, is not that important as long as
 +it represents numbers. The plugin will automatically cast the values to the
 +right type if it know how to do that. For that, it uses the L<strtoll(3)> and
 +L<strtod(3)> functions, so anything supported by those functions is supported
 +by the plugin as well.
 +
 +This option is required inside a B<Result> block and may be specified multiple
 +times. If multiple B<ValuesFrom> options are specified, the columns are read
 +in the given order.
 +
  =item B<Column> I<type> [I<type instance>]
  
 -Specify the I<type> and optional I<type instance> used to dispatch the value
 -of each result column. Detailed information about types and their
 -configuration can be found in L<types.db(5)>. The number and order of the
 -B<Column> options has to match the columns of the query result.
 +This is a deprecated alternative to a B<Result> block. It will be removed in
 +version 5 of collectd. It is equivalent to the following B<Result> block:
 +
 +  <Result>
 +    Type I<type>
 +    InstancePrefix I<type instance>
 +    ValuesFrom I<name of the x. column>
 +  </Result>
 +
 +The order of the B<Column> options defines which columns of the query result
 +should be used. The first option specifies the data found in the first column,
 +the second option that of the second column, and so on.
  
  =item B<MinPGVersion> I<version>
  
@@@ -2252,65 -1555,6 +2307,65 @@@ collected for these selected processes 
  (RSS), user- and system-time used, number of processes and number of threads,
  and minor and major pagefaults.
  
 +=item B<ProcessMatch> I<name> I<regex>
 +
 +Similar to the B<Process> option this allows to select more detailed
 +statistics of processes matching the specified I<regex> (see L<regex(7)> for
 +details). The statistics of all matching processes are summed up and
 +dispatched to the daemon using the specified I<name> as an identifier. This
 +allows to "group" several processes together. I<name> must not contain
 +slashes.
 +
 +=back
 +
 +=head2 Plugin C<rrdcached>
 +
 +The C<rrdcached> plugin uses the RRDTool accelerator daemon, L<rrdcached(1)>,
 +to store values to RRD files in an efficient manner. The combination of the
 +C<rrdcached> B<plugin> and the C<rrdcached> B<daemon> is very similar to the
 +way the C<rrdtool> plugin works (see below). The added abstraction layer
 +provides a number of benefits, though: Because the cache is not within
 +C<collectd> anymore, it does not need to be flushed when C<collectd> is to be
 +restarted. This results in much shorter (if any) gaps in graphs, especially
 +under heavy load. Also, the C<rrdtool> command line utility is aware of the
 +daemon so that it can flush values to disk automatically when needed. This
 +allows to integrate automated flushing of values into graphing solutions much
 +more easily.
 +
 +There are disadvantages, though: The daemon may reside on a different host, so
 +it may not be possible for C<collectd> to create the appropriate RRD files
 +anymore. And even if C<rrdcached> runs on the same host, it may run in a
 +different base directory, so relative paths may do weird stuff if you're not
 +careful.
 +
 +So the B<recommended configuration> is to let C<collectd> and C<rrdcached> run
 +on the same host, communicating via a UNIX domain socket. The B<DataDir>
 +setting should be set to an absolute path, so that a changed base directory
 +does not result in RRD files being createdE<nbsp>/ expected in the wrong place.
 +
 +=over 4
 +
 +=item B<DaemonAddress> I<Address>
 +
 +Address of the daemon as understood by the C<rrdc_connect> function of the RRD
 +library. See L<rrdcached(1)> for details. Example:
 +
 +  <Plugin "rrdcached">
 +    DaemonAddress "unix:/var/run/rrdcached.sock"
 +  </Plugin>
 +
 +=item B<DataDir> I<Directory>
 +
 +Set the base directory in which the RRD files reside. If this is a relative
 +path, it is relative to the working base directory of the C<rrdcached> daemon!
 +Use of an absolute path is recommended.
 +
 +=item B<CreateFiles> B<true>|B<false>
 +
 +Enables or disables the creation of RRD files. If the daemon is not running
 +locally, or B<DataDir> is set to a relative path, this will not work as
 +expected. Default is B<true>.
 +
  =back
  
  =head2 Plugin C<rrdtool>
@@@ -2761,12 -2005,6 +2816,12 @@@ the F</proc/virtual> filesystem that i
  
  The B<VServer> homepage can be found at L<http://linux-vserver.org/>.
  
 +B<Note>: The traffic collected by this plugin accounts for the amount of
 +traffic passing a socket which might be a lot less than the actual on-wire
 +traffic (e.E<nbsp>g. due to headers and retransmission). If you want to
 +collect on-wire traffic you could, for example, use the logging facilities of
 +iptables to feed data for the guest IPs into the iptables plugin.
 +
  =head1 THRESHOLD CONFIGURATION
  
  Starting with version C<4.3.0> collectd has support for B<monitoring>. By that
@@@ -2894,618 -2132,6 +2949,618 @@@ only one such notification is generate
  
  =back
  
 +=head1 FILTER CONFIGURATION
 +
 +TODO: Update this entire section once development is done.
 +
 +Starting with collectd 4.6 there is a powerful filtering infrastructure
 +implemented in the daemon. The concept has mostly been copied from I<iptables>,
 +the packet filter infrastructure for Linux. We'll use a similar terminology, so
 +that users that are familiar with iptables feel right at home.
 +
 +=head2 Terminology
 +
 +The most important terms are:
 +
 +=over 4
 +
 +=item B<Match>
 +
 +A I<match> is a criteria to select specific values. Examples are, of course, the
 +name of the value or it's current value.
 +
 +=item B<Target>
 +
 +A I<target> is some action that is to be performed with data. Such actions
 +could, for example, be to change part of the value's identifier or to ignore
 +the value completely. Built-in functions are B<write> and B<stop>, see below.
 +
 +Some targets, for example the built-in B<stop> target, signal that processing
 +of a value should be stopped. In that case processing of the current chain will
 +be aborted.
 +
 +=item B<Rule>
 +
 +The combination of any number of matches and at least one target is called a
 +I<rule>. The target actions will be performed for all values for which B<all>
 +matches apply. If the rule does not have any matches associated with it, the
 +target action will be performed for all values.
 +
 +If any target returns the stop condition, the processing will stop right away.
 +This means that any targets following the current one will not be called after
 +the stop condition has been returned.
 +
 +=item B<Chain>
 +
 +A I<chain> is a list of rules and possibly default targets. The rules are tried
 +in order and if one matches, the associated target will be called. If a value
 +is handled by a rule, it depends on the target whether or not any subsequent
 +rules are considered or if traversal of the chain is aborted. After all rules
 +have been checked and no target returned the stop condition, the default
 +targets will be executed.
 +
 +=back
 +
 +=head2 General structure
 +
 +The following shows the resulting structure:
 +
 + +---------+
 + ! Chain   !
 + +---------+
 +      !
 +      V
 + +---------+  +---------+  +---------+  +---------+
 + ! Rule    !->! Match   !->! Match   !->! Target  !
 + +---------+  +---------+  +---------+  +---------+
 +      !
 +      V
 + +---------+  +---------+  +---------+
 + ! Rule    !->! Target  !->! Target  !
 + +---------+  +---------+  +---------+
 +      !
 +      V
 +      :
 +      :
 +      !
 +      V
 + +---------+  +---------+  +---------+
 + ! Rule    !->! Match   !->! Target  !
 + +---------+  +---------+  +---------+
 +      !
 +      V
 + +---------+
 + ! Default !
 + ! Target  !
 + +---------+
 +
 +=head2 Synopsis
 +
 +The configuration reflects this structure directly:
 +
 + PostCacheChain "PostCache"
 + <Chain "PostCache">
 +   <Rule "ignore_mysql_show">
 +     <Match "regex">
 +       Plugin "^mysql$"
 +       Type "^mysql_command$"
 +       TypeInstance "^show_"
 +     </Match>
 +     <Target "stop">
 +     </Target>
 +   </Rule>
 +   <Target "write">
 +     Plugin "rrdtool"
 +   </Target>
 + </Chain>
 +
 +The above configuration example will ignore all values where the plugin field
 +is "mysql", the type is "mysql_command" and the type instance begins with
 +"show_". All other values will be sent to the C<rrdtool> write plugin via the
 +default target of the chain. Since this chain is run after the value has been
 +added to the cache, the MySQL C<show_*> command statistics will be available
 +via the C<unixsock> plugin.
 +
 +=head2 List of configuration options
 +
 +=over 4
 +
 +=item B<PreCacheChain> I<ChainName>
 +
 +=item B<PostCacheChain> I<ChainName>
 +
 +Configure the name of the "pre-cache chain" and the "post-cache chain". The
 +argument is the name of a I<chain> that should be executed before and/or after
 +the values have been added to the cache.
 +
 +To understand the implications, it's important you know what is going on inside
 +I<collectd>. The following diagram shows how values are passed from the
 +read-plugins to the write-plugins:
 +
 +   +---------------+
 +   !  Read-Plugin  !
 +   +-------+-------+
 +           !
 + + - - - - V - - - - +
 + : +---------------+ :
 + : !   Pre-Cache   ! :
 + : !     Chain     ! :
 + : +-------+-------+ :
 + :         !         :
 + :         V         :
 + : +-------+-------+ :  +---------------+
 + : !     Cache     !--->!  Value Cache  !
 + : !     insert    ! :  +---+---+-------+
 + : +-------+-------+ :      !   !
 + :         !   ,------------'   !
 + :         V   V     :          V
 + : +-------+---+---+ :  +-------+-------+
 + : !  Post-Cache   +--->! Write-Plugins !
 + : !     Chain     ! :  +---------------+
 + : +---------------+ :
 + :                   :
 + :  dispatch values  :
 + + - - - - - - - - - +
 +
 +After the values are passed from the read-plugins to the dispatch functions,
 +the pre-cache chain is run first. The values are added to the internal cache
 +afterwards. The post-cache chain is run after the values have been added to the
 +cache. So why is it such a huge deal if chains are run before or after the
 +values have been added to this cache?
 +
 +Targets that change the identifier of a value list should be executed before
 +the values are added to the cache, so that the name in the cache matches the
 +name that is used in the write-plugins. The C<unixsock> plugin, too, uses this
 +cache to receive a list of all available values. If you change the identifier
 +after the value list has been added to the cache, this may easily lead to
 +confusion, but it's not forbidden of course.
 +
 +The cache is also used to convert counter values to rates. These rates are, for
 +example, used by the C<value> match (see below). If you use the rate stored in
 +the cache B<before> the new value is added, you will use the old, B<previous>
 +rate. Write plugins may use this rate, too, see the C<csv> plugin, for example.
 +The C<unixsock> plugin uses these rates too, to implement the C<GETVAL>
 +command.
 +
 +Last but not last, the B<stop> target makes a difference: If the pre-cache
 +chain returns the stop condition, the value will not be added to the cache and
 +the post-cache chain will not be run.
 +
 +=item B<Chain> I<Name>
 +
 +Adds a new chain with a certain name. This name can be used to refer to a
 +specific chain, for example to jump to it.
 +
 +Within the B<Chain> block, there can be B<Rule> blocks and B<Target> blocks.
 +
 +=item B<Rule> [I<Name>]
 +
 +Adds a new rule to the current chain. The name of the rule is optional and
 +currently has no meaning for the daemon.
 +
 +Within the B<Rule> block, there may be any number of B<Match> blocks and there
 +must be at least one B<Target> block.
 +
 +=item B<Match> I<Name>
 +
 +Adds a match to a B<Rule> block. The name specifies what kind of match should
 +be performed. Available matches depend on the plugins that have been loaded.
 +
 +The arguments inside the B<Match> block are passed to the plugin implementing
 +the match, so which arguments are valid here depends on the plugin being used.
 +If you do not need any to pass any arguments to a match, you can use the
 +shorter syntax:
 +
 + Match "foobar"
 +
 +Which is equivalent to:
 +
 + <Match "foobar">
 + </Match>
 +
 +=item B<Target> I<Name>
 +
 +Add a target to a rule or a default target to a chain. The name specifies what
 +kind of target is to be added. Which targets are available depends on the
 +plugins being loaded.
 +
 +The arguments inside the B<Target> block are passed to the plugin implementing
 +the target, so which arguments are valid here depends on the plugin being used.
 +If you do not need any to pass any arguments to a target, you can use the
 +shorter syntax:
 +
 + Target "stop"
 +
 +This is the same as writing:
 +
 + <Target "stop">
 + </Target>
 +
 +=back
 +
 +=head2 Built-in targets 
 +
 +The following targets are built into the core daemon and therefore need no
 +plugins to be loaded:
 +
 +=over 4
 +
 +=item B<return>
 +
 +Signals the "return" condition. This causes the current chain to stop
 +processing the value and returns control to the calling chain. The calling
 +chain will continue processing targets and rules just after the B<jump> target
 +(see below). This is very similar to the B<RETURN> target of iptables, see
 +L<iptables(8)>.
 +
 +This target does not have any options.
 +
 +Example:
 +
 + Target "return"
 +
 +=item B<stop>
 +
 +Signals the "stop" condition, causing processing of the value to be aborted
 +immediately. This is similar to the B<DROP> target of iptables, see
 +L<iptables(8)>.
 +
 +This target does not have any options.
 +
 +Example:
 +
 + Target "stop"
 +
 +=item B<write>
 +
 +Sends the value to write plugins.
 +
 +Available options:
 +
 +=over 4
 +
 +=item B<Plugin> I<Name>
 +
 +Name of the write plugin to which the data should be sent. This option may be
 +given multiple times to send the data to more than one write plugin.
 +
 +=back
 +
 +If no plugin is explicitly specified, the values will be sent to all available
 +write plugins.
 +
 +Example:
 +
 + <Target "write">
 +   Plugin "rrdtool"
 + </Target>
 +
 +=item B<jump>
 +
 +Starts processing the rules of another chain. If the end of that chain is
 +reached, or a stop condition is encountered, processing will continue right
 +after the B<jump> target, i.E<nbsp>e. with the next target or the next rule.
 +This is similar to the B<-j> command line option of iptables, see
 +L<iptables(8)>.
 +
 +Available options:
 +
 +=over 4
 +
 +=item B<Chain> I<Name>
 +
 +Jumps to the chain I<Name>. This argument is required and may appear only once.
 +
 +=back
 +
 +Example:
 +
 + <Target "jump">
 +   Chain "foobar"
 + </Target>
 +
 +=back
 +
 +=head2 Available matches
 +
 +=over 4
 +
 +=item B<regex>
 +
 +Matches a value using regular expressions.
 +
 +Available options:
 +
 +=over 4
 +
 +=item B<Host> I<Regex>
 +
 +=item B<Plugin> I<Regex>
 +
 +=item B<PluginInstance> I<Regex>
 +
 +=item B<Type> I<Regex>
 +
 +=item B<TypeInstance> I<Regex>
 +
 +Match values where the given regular expressions match the various fields of
 +the identifier of a value. If multiple regular expressions are given, B<all>
 +regexen must match for a value to match.
 +
 +=back
 +
 +Example:
 +
 + <Match "regex">
 +   Host "customer[0-9]+"
 +   Plugin "^foobar$"
 + </Match>
 +
 +=item B<timediff>
 +
 +Matches values that have a time which differs from the time on the server.
 +
 +This match is mainly intended for servers that receive values over the
 +C<network> plugin and write them to disk using the C<rrdtool> plugin. RRDtool
 +is very sensitive to the timestamp used when updating the RRD files. In
 +particular, the time must be ever increasing. If a misbehaving client sends one
 +packet with a timestamp far in the future, all further packets with a correct
 +time will be ignored because of that one packet. What's worse, such corrupted
 +RRD files are hard to fix.
 +
 +This match lets one match all values B<outside> a specified time range
 +(relative to the server's time), so you can use the B<stop> target (see below)
 +to ignore the value, for example.
 +
 +Available options:
 +
 +=over 4
 +
 +=item B<Future> I<Seconds>
 +
 +Matches all values that are I<ahead> of the server's time by I<Seconds> or more
 +seconds. Set to zero for no limit. Either B<Future> or B<Past> must be
 +non-zero.
 +
 +=item B<Past> I<Seconds>
 +
 +Matches all values that are I<behind> of the server's time by I<Seconds> or
 +more seconds. Set to zero for no limit. Either B<Future> or B<Past> must be
 +non-zero.
 +
 +=back
 +
 +Example:
 +
 + <Match "timediff">
 +   Future  300
 +   Past   3600
 + </Match>
 +
 +This example matches all values that are five minutes or more ahead of the
 +server or one hour (or more) lagging behind.
 +
 +=item B<value>
 +
 +Matches the actual value of data sources against given minimumE<nbsp>/ maximum
 +values. If a data-set consists of more than one data-source, all data-sources
 +must match the specified ranges for a positive match.
 +
 +Available options:
 +
 +=over 4
 +
 +=item B<Min> I<Value>
 +
 +Sets the smallest value which still results in a match. If unset, behaves like
 +negative infinity.
 +
 +=item B<Max> I<Value>
 +
 +Sets the largest value which still results in a match. If unset, behaves like
 +positive infinity.
 +
 +=item B<Invert> B<true>|B<false>
 +
 +Inverts the selection. If the B<Min> and B<Max> settings result in a match,
 +no-match is returned and vice versa. Please note that the B<Invert> setting
 +only effects how B<Min> and B<Max> are applied to a specific value. Especially
 +the B<DataSource> and B<Satisfy> settings (see below) are not inverted.
 +
 +=item B<DataSource> I<DSName> [I<DSName> ...]
 +
 +Select one or more of the data sources. If no data source is configured, all
 +data sources will be checked. If the type handled by the match does not have a
 +data source of the specified name(s), this will always result in no match
 +(independent of the B<Invert> setting).
 +
 +=item B<Satisfy> B<Any>|B<All>
 +
 +Specifies how checking with several data sources is performed. If set to
 +B<Any>, the match succeeds if one of the data sources is in the configured
 +range. If set to B<All> the match only succeeds if all data sources are within
 +the configured range. Default is B<All>.
 +
 +Usually B<All> is used for positive matches, B<Any> is used for negative
 +matches. This means that with B<All> you usually check that all values are in a
 +"good" range, while with B<Any> you check if any value is within a "bad" range
 +(or outside the "good" range).
 +
 +=back
 +
 +Either B<Min> or B<Max>, but not both, may be unset.
 +
 +Example:
 +
 + # Match all values smaller than or equal to 100. Matches only if all data
 + # sources are below 100.
 + <Match "value">
 +   Max 100
 +   Satisfy "All"
 + </Match>
 + 
 + # Match if the value of any data source is outside the range of 0 - 100.
 + <Match "value">
 +   Min   0
 +   Max 100
 +   Invert true
 +   Satisfy "Any"
 + </Match>
 +
 +=back
 +
 +=head2 Available targets
 +
 +=over 4
 +
 +=item B<notification>
 +
 +Creates and dispatches a notification.
 +
 +Available options:
 +
 +=over 4
 +
 +=item B<Message> I<String>
 +
 +This required option sets the message of the notification. The following
 +placeholders will be replaced by an appropriate value:
 +
 +=over 4
 +
 +=item B<%{host}>
 +
 +=item B<%{plugin}>
 +
 +=item B<%{plugin_instance}>
 +
 +=item B<%{type}>
 +
 +=item B<%{type_instance}>
 +
 +These placeholders are replaced by the identifier field of the same name.
 +
 +=item B<%{ds:>I<name>B<}>
 +
 +These placeholders are replaced by a (hopefully) human readable representation
 +of the current rate of this data source. If you changed the instance name
 +(using the B<set> or B<replace> targets, see below), it may not be possible to
 +convert counter values to rates.
 +
 +=back
 +
 +Please note that these placeholders are B<case sensitive>!
 +
 +=item B<Severity> B<"FATAL">|B<"WARNING">|B<"OKAY">
 +
 +Sets the severity of the message. If omitted, the severity B<"WARNING"> is
 +used.
 +
 +=back
 +
 +Example:
 +
 +  <Target "notification">
 +    Message "Oops, the %{type_instance} temperature is currently %{ds:value}!"
 +    Severity "WARNING"
 +  </Target>
 +
 +=item B<replace>
 +
 +Replaces parts of the identifier using regular expressions.
 +
 +Available options:
 +
 +=over 4
 +
 +=item B<Host> I<Regex> I<Replacement>
 +
 +=item B<Plugin> I<Regex> I<Replacement>
 +
 +=item B<PluginInstance> I<Regex> I<Replacement>
 +
 +=item B<TypeInstance> I<Regex> I<Replacement>
 +
 +Match the appropriate field with the given regular expression I<Regex>. If the
 +regular expression matches, that part that matches is replaced with
 +I<Replacement>. If multiple places of the input buffer match a given regular
 +expression, only the first occurrence will be replaced.
 +
 +You can specify each option multiple times to use multiple regular expressions
 +one after another.
 +
 +=back
 +
 +Example:
 +
 + <Target "replace">
 +   # Replace "example.net" with "example.com"
 +   Host "\\<example.net\\>" "example.com"
 + 
 +   # Strip "www." from hostnames
 +   Host "\\<www\\." ""
 + </Target>
 +
 +=item B<set>
 +
 +Sets part of the identifier of a value to a given string.
 +
 +Available options:
 +
 +=over 4
 +
 +=item B<Host> I<String>
 +
 +=item B<Plugin> I<String>
 +
 +=item B<PluginInstance> I<String>
 +
 +=item B<TypeInstance> I<String>
 +
 +Set the appropriate field to the given string. The strings for plugin instance
 +and type instance may be empty, the strings for host and plugin may not be
 +empty. It's currently not possible to set the type of a value this way.
 +
 +=back
 +
 +Example:
 +
 + <Target "set">
 +   PluginInstance "coretemp"
 +   TypeInstance "core3"
 + </Target>
 +
 +=back
 +
 +=head2 Backwards compatibility
 +
 +If you use collectd with an old configuration, i.E<nbsp>e. one without a
 +B<Chain> block, it will behave as it used to. This is equivalent to the
 +following configuration:
 +
 + <Chain "PostCache">
 +   Target "write"
 + </Chain>
 +
 +If you specify a B<PostCacheChain>, the B<write> target will not be added
 +anywhere and you will have to make sure that it is called where appropriate. We
 +suggest to add the above snippet as default target to your "PostCache" chain.
 +
 +=head2 Examples
 +
 +Ignore all values, where the hostname does not contain a dot, i.E<nbsp>e. can't
 +be an FQDN.
 +
 + <Chain "PreCache">
 +   <Rule "no_fqdn">
 +     <Match "regex">
 +       Host "^[^\.]*$"
 +     </Match>
 +     Target "stop"
 +   </Rule>
 +   Target "write"
 + </Chain>
 +
  =head1 SEE ALSO
  
  L<collectd(1)>,
@@@ -3514,12 -2140,9 +3569,12 @@@ L<collectd-perl(5)>
  L<collectd-unixsock(5)>,
  L<types.db(5)>,
  L<hddtemp(8)>,
 +L<iptables(8)>,
  L<kstat(3KSTAT)>,
  L<mbmon(1)>,
 +L<pcre(3)>,
  L<psql(1)>,
 +L<regex(7)>,
  L<rrdtool(1)>,
  L<sensors(1)>