Merge branch 'collectd-4.10'
authorFlorian Forster <octo@huhu.verplant.org>
Tue, 4 Jan 2011 11:42:23 +0000 (12:42 +0100)
committerFlorian Forster <octo@huhu.verplant.org>
Tue, 4 Jan 2011 11:42:23 +0000 (12:42 +0100)
1  2 
README
configure.in
src/curl_json.c
src/dns.c
src/java.c

diff --combined README
--- 1/README
--- 2/README
+++ b/README
@@@ -125,10 -125,6 +125,10 @@@ Feature
      - load
        System load average over the last 1, 5 and 15 minutes.
  
 +    - lpar
 +      Detailed CPU statistics of the “Logical Partitions” virtualization
 +      technique built into IBM's POWER processors.
 +
      - libvirt
        CPU, disk and network I/O statistics from virtual machines.
  
        collectd without the need to start a heavy interpreter every interval.
        See collectd-python(5) for details.
  
 +    - redis
 +      The redis plugin gathers information from a redis server, including:
 +      uptime, used memory, total connections etc.
 +
      - routeros
        Query interface and wireless registration statistics from RouterOS.
  
      - users
        Users currently logged in.
  
 +    - varnish
 +      Various statistics from Varnish, an HTTP accelerator.
 +
      - vmem
        Virtual memory statistics, e. g. the number of page-ins/-outs or the
        number of pagefaults.
    * Output can be written or sent to various destinations by the following
      plugins:
  
 +    - amqp
 +      Sends JSON-encoded data to an Advanced Message Queuing Protocol (AMQP)
 +      server, such as RabbitMQ.
 +
      - csv
        Write to comma separated values (CSV) files. This needs lots of
        diskspace but is extremely portable and can be analysed with almost
  
    * Miscellaneous plugins:
  
 +    - threshold
 +      Checks values against configured thresholds and creates notifications if
 +      values are out of bounds. See collectd-threshold(5) for details.
 +
      - uuid
        Sets the hostname to an unique identifier. This is meant for setups
        where each client may migrate to another physical host, possibly going
@@@ -523,10 -504,6 +523,10 @@@ Prerequisite
    * libclntsh (optional)
      Used by the `oracle' plugin.
  
 +  * libcredis (optional)
 +    Used by the redis plugin. Please note that you require a 0.2.2 version
 +    or higher. <http://code.google.com/p/credis/>
 +
    * libcurl (optional)
      If you want to use the `apache', `ascent', `curl', `nginx', or `write_http'
      plugin.
      <http://tangent.org/552/libmemcached.html>
  
    * libmodbus (optional)
-     Used by the `modbus' plugin to communicate with Modbus/TCP devices.
-     <https://launchpad.net/libmodbus>
+     Used by the “modbus” plugin to communicate with Modbus/TCP devices. The
+     “modbus” plugin works with version 2.0.3 of the library – due to frequent
+     API changes other versions may or may not compile cleanly.
+     <http://www.libmodbus.org/>
  
    * libmysqlclient (optional)
      Unsurprisingly used by the `mysql' plugin.
      Used by the `python' plugin. Currently, only 2.3 ≦ Python < 3 is supported.
      <http://www.python.org/>
  
 +  * librabbitmq (optional; also called “rabbitmq-c”)
 +    Used by the AMQP plugin for AMQP connections, for example to RabbitMQ.
 +    <http://hg.rabbitmq.com/rabbitmq-c/>
 +
    * librouteros (optional)
      Used by the `routeros' plugin to connect to a device running `RouterOS'.
      <http://verplant.org/librouteros/>
      Parse JSON data. This is needed for the `curl_json' plugin.
      <http://github.com/lloyd/yajl>
  
 +  * libvarnish (optional)
 +     Fetches statistics from a Varnish instance. This is needed for the Varnish plugin
 +     <http://varnish-cache.org>
 +
  Configuring / Compiling / Installing
  ------------------------------------
  
diff --combined configure.in
@@@ -108,13 -108,9 +108,13 @@@ AC_ARG_ENABLE(standards
  if test "x$enable_standards" = "xyes"
  then
        AC_DEFINE(_ISOC99_SOURCE,        1, [Define to enforce ISO C99 compliance.])
 -      AC_DEFINE(_POSIX_C_SOURCE, 200112L, [Define to enforce POSIX.1-2001 compliance.])
 -      AC_DEFINE(_XOPEN_SOURCE,       600, [Define to enforce X/Open 6 (XSI) compliance.])
 +      AC_DEFINE(_POSIX_C_SOURCE, 200809L, [Define to enforce POSIX.1-2008 compliance.])
 +      AC_DEFINE(_XOPEN_SOURCE,       700, [Define to enforce X/Open 7 (XSI) compliance.])
        AC_DEFINE(_REENTRANT,            1, [Define to enable reentrancy interfaces.])
 +      if test "x$GCC" = "xyes"
 +      then
 +              CFLAGS="$CFLAGS -std=c99"
 +      fi
  fi
  AM_CONDITIONAL(BUILD_FEATURE_STANDARDS, test "x$enable_standards" = "xyes")
  
@@@ -572,27 -568,6 +572,27 @@@ socket_needs_socket="no
  AC_CHECK_FUNCS(socket, [], AC_CHECK_LIB(socket, socket, [socket_needs_socket="yes"], AC_MSG_ERROR(cannot find socket)))
  AM_CONDITIONAL(BUILD_WITH_LIBSOCKET, test "x$socket_needs_socket" = "xyes")
  
 +clock_gettime_needs_rt="no"
 +clock_gettime_needs_posix4="no"
 +have_clock_gettime="no"
 +AC_CHECK_FUNCS(clock_gettime, [have_clock_gettime="yes"])
 +if test "x$have_clock_gettime" = "xno"
 +then
 +      AC_CHECK_LIB(rt, clock_gettime, [clock_gettime_needs_rt="yes"
 +                                       have_clock_gettime="yes"])
 +fi
 +if test "x$have_clock_gettime" = "xno"
 +then
 +      AC_CHECK_LIB(posix4, clock_gettime, [clock_gettime_needs_posix4="yes"
 +                                           have_clock_gettime="yes"])
 +fi
 +if test "x$have_clock_gettime" = "xyes"
 +then
 +      AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if the clock_gettime(2) function is available.])
 +else
 +      AC_MSG_WARN(cannot find clock_gettime)
 +fi
 +
  nanosleep_needs_rt="no"
  nanosleep_needs_posix4="no"
  AC_CHECK_FUNCS(nanosleep,
          AC_CHECK_LIB(posix4, nanosleep,
              [nanosleep_needs_posix4="yes"],
              AC_MSG_ERROR(cannot find nanosleep))))
 -AM_CONDITIONAL(BUILD_WITH_LIBRT, test "x$nanosleep_needs_rt" = "xyes")
 -AM_CONDITIONAL(BUILD_WITH_LIBPOSIX4, test "x$nanosleep_needs_posix4" = "xyes")
 +
 +AM_CONDITIONAL(BUILD_WITH_LIBRT, test "x$clock_gettime_needs_rt" = "xyes" || test "x$nanosleep_needs_rt" = "xyes")
 +AM_CONDITIONAL(BUILD_WITH_LIBPOSIX4, test "x$clock_gettime_needs_posix4" = "xyes" || test "x$nanosleep_needs_posix4" = "xyes")
  
  AC_CHECK_FUNCS(sysctl, [have_sysctl="yes"], [have_sysctl="no"])
  AC_CHECK_FUNCS(sysctlbyname, [have_sysctlbyname="yes"], [have_sysctlbyname="no"])
@@@ -614,127 -588,13 +614,127 @@@ AC_CHECK_FUNCS(thread_info, [have_threa
  AC_CHECK_FUNCS(statfs, [have_statfs="yes"], [have_statfs="no"])
  AC_CHECK_FUNCS(statvfs, [have_statvfs="yes"], [have_statvfs="no"])
  AC_CHECK_FUNCS(getifaddrs, [have_getifaddrs="yes"], [have_getifaddrs="no"])
 +AC_CHECK_FUNCS(getloadavg, [have_getloadavg="yes"], [have_getloadavg="no"])
  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"])
 +# Check for strptime {{{
 +if test "x$GCC" = "xyes"
 +then
 +      SAVE_CFLAGS="$CFLAGS"
 +      CFLAGS="$CFLAGS -Wall -Wextra -Werror"
 +fi
 +
 +AC_CHECK_FUNCS(strptime, [have_strptime="yes"], [have_strptime="no"])
 +if test "x$have_strptime" = "xyes"
 +then
 +      AC_CACHE_CHECK([whether strptime is exported by default],
 +                     [c_cv_have_strptime_default],
 +                     AC_COMPILE_IFELSE(
 +AC_LANG_PROGRAM(
 +[[
 +AC_INCLUDES_DEFAULT
 +#include <time.h>
 +]],
 +[[
 + struct tm stm;
 + (void) strptime ("2010-12-30%13:42:42", "%Y-%m-%dT%T", &stm);
 +]]),
 +                     [c_cv_have_strptime_default="yes"],
 +                     [c_cv_have_strptime_default="no"]))
 +fi
 +if test "x$have_strptime" = "xyes" && test "x$c_cv_have_strptime_default" = "xno"
 +then
 +      AC_CACHE_CHECK([whether strptime needs standards mode],
 +                     [c_cv_have_strptime_standards],
 +                     AC_COMPILE_IFELSE(
 +AC_LANG_PROGRAM(
 +[[
 +#ifndef _ISOC99_SOURCE
 +# define _ISOC99_SOURCE 1
 +#endif
 +#ifndef _POSIX_C_SOURCE
 +# define _POSIX_C_SOURCE 200112L
 +#endif
 +#ifndef _XOPEN_SOURCE
 +# define _XOPEN_SOURCE 500
 +#endif
 +AC_INCLUDES_DEFAULT
 +#include <time.h>
 +]],
 +[[
 + struct tm stm;
 + (void) strptime ("2010-12-30%13:42:42", "%Y-%m-%dT%T", &stm);
 +]]),
 +                     [c_cv_have_strptime_standards="yes"],
 +                     [c_cv_have_strptime_standards="no"]))
 +
 +      if test "x$c_cv_have_strptime_standards" = "xyes"
 +      then
 +              AC_DEFINE([STRPTIME_NEEDS_STANDARDS], 1, [Set to true if strptime is only exported in X/Open mode (GNU libc).])
 +      else
 +              have_strptime="no"
 +      fi
 +fi
 +
 +if test "x$GCC" = "xyes"
 +then
 +      CFLAGS="$SAVE_CFLAGS"
 +fi
 +
 +# }}} Check for strptime
 +
 +AC_CHECK_FUNCS(swapctl, [have_swapctl="yes"], [have_swapctl="no"])
 +if test "x$have_swapctl" = "xyes"; then
 +        AC_CACHE_CHECK([whether swapctl takes two arguments],
 +                [c_cv_have_swapctl_two_args],
 +                AC_COMPILE_IFELSE(
 +                        AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
 +#if HAVE_SYS_SWAP_H && !defined(_LP64) && _FILE_OFFSET_BITS == 64
 +#  undef _FILE_OFFSET_BITS
 +#  undef _LARGEFILE64_SOURCE
 +#endif
 +#include <sys/stat.h>
 +#include <sys/swap.h>]],
 +                                [[
 +                                int num = swapctl(0, NULL);
 +                                ]]
 +                        ),
 +                        [c_cv_have_swapctl_two_args="yes"],
 +                        [c_cv_have_swapctl_two_args="no"]
 +                )
 +        )
 +        AC_CACHE_CHECK([whether swapctl takes three arguments],
 +                [c_cv_have_swapctl_three_args],
 +                AC_COMPILE_IFELSE(
 +                        AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
 +#if HAVE_SYS_SWAP_H && !defined(_LP64) && _FILE_OFFSET_BITS == 64
 +#  undef _FILE_OFFSET_BITS
 +#  undef _LARGEFILE64_SOURCE
 +#endif
 +#include <sys/stat.h>
 +#include <sys/swap.h>]],
 +                                [[
 +                                int num = swapctl(0, NULL,0);
 +                                ]]
 +                        ),
 +                        [c_cv_have_swapctl_three_args="yes"],
 +                        [c_cv_have_swapctl_three_args="no"]
 +                )
 +        )
 +fi
 +# Check for different versions of `swapctl' here..
 +if test "x$have_swapctl" = "xyes"; then
 +        if test "x$c_cv_have_swapctl_two_args" = "xyes"; then
 +                AC_DEFINE(HAVE_SWAPCTL_TWO_ARGS, 1,
 +                          [Define if the function swapctl exists and takes two arguments.])
 +        fi
 +        if test "x$c_cv_have_swapctl_three_args" = "xyes"; then
 +                AC_DEFINE(HAVE_SWAPCTL_THREE_ARGS, 1,
 +                          [Define if the function swapctl exists and takes three arguments.])
 +        fi
 +fi
  
  # Check for NAN
  AC_ARG_WITH(nan-emulation, [AS_HELP_STRING([--with-nan-emulation], [use emulated NAN. For crosscompiling only.])],
@@@ -756,7 -616,7 +756,7 @@@ if test "x$nan_type" = "xnone"; the
        [[
  #include <stdlib.h>
  #include <math.h>
 -static float foo = NAN;
 +static double foo = NAN;
        ]],
        [[
         if (isnan (foo))
@@@ -782,7 -642,7 +782,7 @@@ if test "x$nan_type" = "xnone"; the
  #include <stdlib.h>
  #define __USE_ISOC99 1
  #include <math.h>
 -static float foo = NAN;
 +static double foo = NAN;
        ]],
        [[
         if (isnan (foo))
@@@ -816,7 -676,7 +816,7 @@@ if test "x$nan_type" = "xnone"; the
  #ifndef isnan
  # define isnan(f) ((f) != (f))
  #endif
 -static float foo = NAN;
 +static double foo = NAN;
        ]],
        [[
         if (isnan (foo))
  if test "x$with_perfstat" = "xyes"
  then
         AC_DEFINE(HAVE_PERFSTAT, 1, [Define to 1 if you have the 'perfstat' library (-lperfstat)])
 +       # struct members pertaining to donation have been added to libperfstat somewhere between AIX5.3ML5 and AIX5.3ML9
 +       AC_CHECK_MEMBER([perfstat_partition_type_t.b.donate_enabled], [], [], [[#include <libperfstat.h]])
 +       if test "x$av_cv_member_perfstat_partition_type_t_b_donate_enabled" = "xyes"
 +       then
 +              AC_DEFINE(PERFSTAT_SUPPORTS_DONATION, 1, [Define to 1 if your version of the 'perfstat' library supports donation])
 +       fi
  fi
  AM_CONDITIONAL(BUILD_WITH_PERFSTAT, test "x$with_perfstat" = "xyes")
  
  fi
  AM_CONDITIONAL(BUILD_WITH_LIBKVM_OPENFILES, test "x$with_kvm_openfiles" = "xyes")
  
 +# --with-libcredis {{{
 +AC_ARG_WITH(libcredis, [AS_HELP_STRING([--with-libcredis@<:@=PREFIX@:>@], [Path to libcredis.])],
 +[
 + if test "x$withval" = "xyes"
 + then
 +       with_libcredis="yes"
 + else if test "x$withval" = "xno"
 + then
 +       with_libcredis="no"
 + else
 +       with_libcredis="yes"
 +       LIBCREDIS_CPPFLAGS="$LIBCREDIS_CPPFLAGS -I$withval/include"
 +       LIBCREDIS_LDFLAGS="$LIBCREDIS_LDFLAGS -L$withval/lib"
 + fi; fi
 +],
 +[with_libcredis="yes"])
 +
 +SAVE_CPPFLAGS="$CPPFLAGS"
 +SAVE_LDFLAGS="$LDFLAGS"
 +
 +CPPFLAGS="$CPPFLAGS $LIBCREDIS_CPPFLAGS"
 +LDFLAGS="$LDFLAGS $LIBCREDIS_LDFLAGS"
 +
 +if test "x$with_libcredis" = "xyes"
 +then
 +      if test "x$LIBCREDIS_CPPFLAGS" != "x"
 +      then
 +              AC_MSG_NOTICE([libcredis CPPFLAGS: $LIBCREDIS_CPPFLAGS])
 +      fi
 +      AC_CHECK_HEADERS(credis.h,
 +      [with_libcredis="yes"],
 +      [with_libcredis="no ('credis.h' not found)"])
 +fi
 +if test "x$with_libcredis" = "xyes"
 +then
 +      if test "x$LIBCREDIS_LDFLAGS" != "x"
 +      then
 +              AC_MSG_NOTICE([libcredis LDFLAGS: $LIBCREDIS_LDFLAGS])
 +      fi
 +      AC_CHECK_LIB(credis, credis_info,
 +      [with_libcredis="yes"],
 +      [with_libcredis="no (symbol 'credis_info' not found)"])
 +
 +fi
 +
 +CPPFLAGS="$SAVE_CPPFLAGS"
 +LDFLAGS="$SAVE_LDFLAGS"
 +
 +if test "x$with_libcredis" = "xyes"
 +then
 +      BUILD_WITH_LIBCREDIS_CPPFLAGS="$LIBCREDIS_CPPFLAGS"
 +      BUILD_WITH_LIBCREDIS_LDFLAGS="$LIBCREDIS_LDFLAGS"
 +      AC_SUBST(BUILD_WITH_LIBCREDIS_CPPFLAGS)
 +      AC_SUBST(BUILD_WITH_LIBCREDIS_LDFLAGS)
 +fi
 +AM_CONDITIONAL(BUILD_WITH_LIBCREDIS, test "x$with_libcredis" = "xyes")
 +# }}}
 +
  # --with-libcurl {{{
  with_curl_config="curl-config"
  with_curl_cflags=""
@@@ -2169,9 -1965,9 +2169,9 @@@ the
        CPPFLAGS="$CPPFLAGS $with_libmodbus_cflags"
        LDFLAGS="$LDFLAGS $with_libmodbus_libs"
  
 -      AC_CHECK_LIB(modbus, modbus_init_tcp,
 +      AC_CHECK_LIB(modbus, modbus_connect,
                     [with_libmodbus="yes"],
 -                   [with_libmodbus="no (symbol modbus_init_tcp not found)"])
 +                   [with_libmodbus="no (symbol modbus_connect not found)"])
  
        CPPFLAGS="$SAVE_CPPFLAGS"
        LDFLAGS="$SAVE_LDFLAGS"
  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)"])
+       AC_CHECK_HEADERS(pcap.h,,
+                        [with_libpcap="no (pcap.h not found)"])
  fi
  if test "x$with_libpcap" = "xyes"
  then
-       collect_libpcap=1
- else
-       collect_libpcap=0
+       AC_CHECK_HEADERS(pcap-bpf.h)
  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")
  # }}}
  
  fi
  # }}} --with-python
  
 +# --with-librabbitmq {{{
 +with_librabbitmq_cppflags=""
 +with_librabbitmq_ldflags=""
 +AC_ARG_WITH(librabbitmq, [AS_HELP_STRING([--with-librabbitmq@<:@=PREFIX@:>@], [Path to librabbitmq.])],
 +[
 +      if test "x$withval" != "xno" && test "x$withval" != "xyes"
 +      then
 +              with_librabbitmq_cppflags="-I$withval/include"
 +              with_librabbitmq_ldflags="-L$withval/lib"
 +              with_librabbitmq="yes"
 +      else
 +              with_librabbitmq="$withval"
 +      fi
 +],
 +[
 +      with_librabbitmq="yes"
 +])
 +if test "x$with_librabbitmq" = "xyes"
 +then
 +      SAVE_CPPFLAGS="$CPPFLAGS"
 +      CPPFLAGS="$CPPFLAGS $with_librabbitmq_cppflags"
 +
 +      AC_CHECK_HEADERS(amqp.h, [with_librabbitmq="yes"], [with_librabbitmq="no (amqp.h not found)"])
 +
 +      CPPFLAGS="$SAVE_CPPFLAGS"
 +fi
 +if test "x$with_librabbitmq" = "xyes"
 +then
 +      SAVE_CPPFLAGS="$CPPFLAGS"
 +      SAVE_LDFLAGS="$LDFLAGS"
 +      CPPFLAGS="$CPPFLAGS $with_librabbitmq_cppflags"
 +      LDFLAGS="$LDFLAGS $with_librabbitmq_ldflags"
 +
 +      AC_CHECK_LIB(rabbitmq, amqp_basic_publish, [with_librabbitmq="yes"], [with_librabbitmq="no (Symbol 'amqp_basic_publish' not found)"])
 +
 +      CPPFLAGS="$SAVE_CPPFLAGS"
 +      LDFLAGS="$SAVE_LDFLAGS"
 +fi
 +if test "x$with_librabbitmq" = "xyes"
 +then
 +      BUILD_WITH_LIBRABBITMQ_CPPFLAGS="$with_librabbitmq_cppflags"
 +      BUILD_WITH_LIBRABBITMQ_LDFLAGS="$with_librabbitmq_ldflags"
 +      BUILD_WITH_LIBRABBITMQ_LIBS="-lrabbitmq"
 +      AC_SUBST(BUILD_WITH_LIBRABBITMQ_CPPFLAGS)
 +      AC_SUBST(BUILD_WITH_LIBRABBITMQ_LDFLAGS)
 +      AC_SUBST(BUILD_WITH_LIBRABBITMQ_LIBS)
 +      AC_DEFINE(HAVE_LIBRABBITMQ, 1, [Define if librabbitmq is present and usable.])
 +fi
 +AM_CONDITIONAL(BUILD_WITH_LIBRABBITMQ, test "x$with_librabbitmq" = "xyes")
 +# }}}
 +
  # --with-librouteros {{{
  AC_ARG_WITH(librouteros, [AS_HELP_STRING([--with-librouteros@<:@=PREFIX@:>@], [Path to librouteros.])],
  [
  AM_CONDITIONAL(BUILD_WITH_LIBYAJL, test "x$with_libyajl" = "xyes")
  # }}}
  
 +# --with-libvarnish {{{
 +with_libvarnish_cppflags=""
 +with_libvarnish_cflags=""
 +with_libvarnish_libs=""
 +AC_ARG_WITH(libvarnish, [AS_HELP_STRING([--with-libvarnish@<:@=PREFIX@:>@], [Path to libvarnish.])],
 +[
 +      if test "x$withval" = "xno"
 +      then
 +              with_libvarnish="no"
 +      else if test "x$withval" = "xyes"
 +      then
 +              with_libvarnish="use_pkgconfig"
 +      else if test -d "$with_libvarnish/lib"
 +      then
 +              AC_MSG_NOTICE([Not checking for libvarnish: Manually configured])
 +              with_libvarnish_cflags="-I$withval/include"
 +              with_libvarnish_libs="-L$withval/lib -lvarnish -lvarnishcompat -lvarnishapi"
 +              with_libvarnish="yes"
 +      fi; fi; fi
 +],
 +[with_libvarnish="use_pkgconfig"])
 +
 +# configure using pkg-config
 +if test "x$with_libvarnish" = "xuse_pkgconfig"
 +then
 +      if test "x$PKG_CONFIG" = "x"
 +      then
 +              with_libvarnish="no (Don't have pkg-config)"
 +      fi
 +fi
 +if test "x$with_libvarnish" = "xuse_pkgconfig"
 +then
 +      AC_MSG_NOTICE([Checking for varnishapi using $PKG_CONFIG])
 +      $PKG_CONFIG --exists 'varnishapi' 2>/dev/null
 +      if test $? -ne 0
 +      then
 +              with_libvarnish="no (pkg-config doesn't know library)"
 +      fi
 +fi
 +if test "x$with_libvarnish" = "xuse_pkgconfig"
 +then
 +      with_libvarnish_cflags="`$PKG_CONFIG --cflags 'varnishapi'`"
 +      if test $? -ne 0
 +      then
 +              with_libvarnish="no ($PKG_CONFIG failed)"
 +      fi
 +      with_libvarnish_libs="`$PKG_CONFIG --libs 'varnishapi'`"
 +      if test $? -ne 0
 +      then
 +              with_libvarnish="no ($PKG_CONFIG failed)"
 +      fi
 +fi
 +if test "x$with_libvarnish" = "xuse_pkgconfig"
 +then
 +      with_libvarnish="yes"
 +fi
 +
 +# with_libvarnish_cflags and with_libvarnish_libs are set up now, let's do
 +# the actual checks.
 +if test "x$with_libvarnish" = "xyes"
 +then
 +      SAVE_CPPFLAGS="$CPPFLAGS"
 +      CPPFLAGS="$CPPFLAGS $with_libvarnish_cflags"
 +      AC_CHECK_HEADERS(varnish/varnishapi.h, [], [with_libvarnish="no (varnish/varnishapi.h not found)"])
 +
 +      CPPFLAGS="$SAVE_CPPFLAGS"
 +fi
 +if test "x$with_libvarnish" = "xyes"
 +then
 +      SAVE_CPPFLAGS="$CPPFLAGS"
 +      #SAVE_LDFLAGS="$LDFLAGS"
 +
 +      CPPFLAGS="$CPPFLAGS $with_libvarnish_cflags"
 +      #LDFLAGS="$LDFLAGS $with_libvarnish_libs"
 +
 +      AC_CHECK_LIB(varnishapi, VSL_OpenStats,
 +                   [with_libvarnish="yes"],
 +                   [with_libvarnish="no (symbol VSL_OpenStats not found)"],
 +                   [$with_libvarnish_libs])
 +
 +      CPPFLAGS="$SAVE_CPPFLAGS"
 +      #LDFLAGS="$SAVE_LDFLAGS"
 +fi
 +if test "x$with_libvarnish" = "xyes"
 +then
 +      BUILD_WITH_LIBVARNISH_CFLAGS="$with_libvarnish_cflags"
 +      BUILD_WITH_LIBVARNISH_LIBS="$with_libvarnish_libs"
 +      AC_SUBST(BUILD_WITH_LIBVARNISH_CFLAGS)
 +      AC_SUBST(BUILD_WITH_LIBVARNISH_LIBS)
 +fi
 +# }}}
 +
  # pkg-config --exists 'libxml-2.0'; pkg-config --exists libvirt {{{
  with_libxml2="no (pkg-config isn't available)"
  with_libxml2_cflags=""
@@@ -4431,6 -4078,11 +4425,6 @@@ the
        plugin_tape="yes"
  fi
  
 -if test "x$have_sys_swap_h$with_kstat$ac_system" = "xyesyesSolaris"
 -then
 -      plugin_swap="yes"
 -fi
 -
  # libstatgrab
  if test "x$with_libstatgrab" = "xyes"
  then
  if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes"
  then
        plugin_ascent="yes"
 -      plugin_bind="yes"
 +      if test "x$have_strptime" = "xyes"
 +      then
 +              plugin_bind="yes"
 +      fi
  fi
  
  if test "x$with_libopenipmipthread" = "xyes"
@@@ -4480,7 -4129,6 +4474,7 @@@ the
  fi
  if test "x$have_sysctlbyname" = "xyes"
  then
 +      plugin_contextswitch="yes"
        plugin_cpu="yes"
        plugin_memory="yes"
        plugin_tcpconns="yes"
@@@ -4608,7 -4256,6 +4602,7 @@@ AC_ARG_ENABLE([all-plugins]
  
  m4_divert_once([HELP_ENABLE], [])
  
 +AC_PLUGIN([amqp],        [$with_librabbitmq],  [AMQP output plugin])
  AC_PLUGIN([apache],      [$with_libcurl],      [Apache httpd statistics])
  AC_PLUGIN([apcups],      [yes],                [Statistics of UPSes by APC])
  AC_PLUGIN([apple_sensors], [$with_libiokit],   [Apple's hardware sensors])
@@@ -4643,7 -4290,6 +4637,7 @@@ AC_PLUGIN([java],        [$with_java]
  AC_PLUGIN([libvirt],     [$plugin_libvirt],    [Virtual machine statistics])
  AC_PLUGIN([load],        [$plugin_load],       [System load])
  AC_PLUGIN([logfile],     [yes],                [File logging plugin])
 +AC_PLUGIN([lpar],        [$with_perfstat],     [AIX logical partitions statistics])
  AC_PLUGIN([madwifi],     [$have_linux_wireless_h], [Madwifi wireless statistics])
  AC_PLUGIN([match_empty_counter], [yes],        [The empty counter match])
  AC_PLUGIN([match_hashed], [yes],               [The hashed match])
@@@ -4679,7 -4325,6 +4673,7 @@@ AC_PLUGIN([powerdns],    [yes]
  AC_PLUGIN([processes],   [$plugin_processes],  [Process statistics])
  AC_PLUGIN([protocols],   [$plugin_protocols],  [Protocol (IP, TCP, ...) statistics])
  AC_PLUGIN([python],      [$with_python],       [Embed a Python interpreter])
 +AC_PLUGIN([redis],       [$with_libcredis],    [Redis plugin])
  AC_PLUGIN([routeros],    [$with_librouteros],  [RouterOS plugin])
  AC_PLUGIN([rrdcached],   [$librrd_rrdc_update], [RRDTool output plugin])
  AC_PLUGIN([rrdtool],     [$with_librrd],       [RRDTool output plugin])
@@@ -4695,23 -4340,19 +4689,23 @@@ AC_PLUGIN([target_notification], [yes]
  AC_PLUGIN([target_replace], [yes],             [The replace target])
  AC_PLUGIN([target_scale],[yes],                [The scale target])
  AC_PLUGIN([target_set],  [yes],                [The set target])
 +AC_PLUGIN([target_v5upgrade], [yes],           [The v5upgrade target])
  AC_PLUGIN([tcpconns],    [$plugin_tcpconns],   [TCP connection statistics])
  AC_PLUGIN([teamspeak2],  [yes],                [TeamSpeak2 server statistics])
  AC_PLUGIN([ted],         [$plugin_ted],        [Read The Energy Detective values])
  AC_PLUGIN([thermal],     [$plugin_thermal],    [Linux ACPI thermal zone statistics])
 +AC_PLUGIN([threshold],   [yes],                [Threshold checking plugin])
  AC_PLUGIN([tokyotyrant], [$with_libtokyotyrant],  [TokyoTyrant database statistics])
  AC_PLUGIN([unixsock],    [yes],                [Unixsock communication plugin])
  AC_PLUGIN([uptime],      [$plugin_uptime],     [Uptime statistics])
  AC_PLUGIN([users],       [$plugin_users],      [User statistics])
  AC_PLUGIN([uuid],        [yes],                [UUID as hostname plugin])
 +AC_PLUGIN([varnish],     [$with_libvarnish],   [Varnish cache statistics])
  AC_PLUGIN([vmem],        [$plugin_vmem],       [Virtual memory statistics])
  AC_PLUGIN([vserver],     [$plugin_vserver],    [Linux VServer statistics])
  AC_PLUGIN([wireless],    [$plugin_wireless],   [Wireless statistics])
  AC_PLUGIN([write_http],  [$with_libcurl],      [HTTP output plugin])
 +AC_PLUGIN([write_redis], [$with_libcredis],    [Redis output plugin])
  AC_PLUGIN([xmms],        [$with_libxmms],      [XMMS statistics])
  AC_PLUGIN([zfs_arc],     [$plugin_zfs_arc],    [ZFS ARC statistics])
  
@@@ -4886,7 -4527,6 +4880,7 @@@ Configuration
    Libraries:
      libcurl . . . . . . . $with_libcurl
      libdbi  . . . . . . . $with_libdbi
 +    libcredis . . . . . . $with_libcredis
      libesmtp  . . . . . . $with_libesmtp
      libganglia  . . . . . $with_libganglia
      libgcrypt . . . . . . $with_libgcrypt
      libperl . . . . . . . $with_libperl
      libpq . . . . . . . . $with_libpq
      libpthread  . . . . . $with_libpthread
 +    librabbitmq . . . . . $with_librabbitmq
      librouteros . . . . . $with_librouteros
      librrd  . . . . . . . $with_librrd
      libsensors  . . . . . $with_libsensors
      libstatgrab . . . . . $with_libstatgrab
      libtokyotyrant  . . . $with_libtokyotyrant
      libupsclient  . . . . $with_libupsclient
 +    libvarnish  . . . . . $with_libvarnish
      libvirt . . . . . . . $with_libvirt
      libxml2 . . . . . . . $with_libxml2
      libxmms . . . . . . . $with_libxmms
      perl  . . . . . . . . $with_perl_bindings
  
    Modules:
 +    amqp    . . . . . . . $enable_amqp
      apache  . . . . . . . $enable_apache
      apcups  . . . . . . . $enable_apcups
      apple_sensors . . . . $enable_apple_sensors
      libvirt . . . . . . . $enable_libvirt
      load  . . . . . . . . $enable_load
      logfile . . . . . . . $enable_logfile
 +    lpar... . . . . . . . $enable_lpar
      madwifi . . . . . . . $enable_madwifi
      match_empty_counter . $enable_match_empty_counter
      match_hashed  . . . . $enable_match_hashed
      processes . . . . . . $enable_processes
      protocols . . . . . . $enable_protocols
      python  . . . . . . . $enable_python
 +    redis . . . . . . . . $enable_redis
      routeros  . . . . . . $enable_routeros
      rrdcached . . . . . . $enable_rrdcached
      rrdtool . . . . . . . $enable_rrdtool
      target_replace  . . . $enable_target_replace
      target_scale  . . . . $enable_target_scale
      target_set  . . . . . $enable_target_set
 +    target_v5upgrade  . . $enable_target_v5upgrade
      tcpconns  . . . . . . $enable_tcpconns
      teamspeak2  . . . . . $enable_teamspeak2
      ted . . . . . . . . . $enable_ted
      thermal . . . . . . . $enable_thermal
 +    threshold . . . . . . $enable_threshold
      tokyotyrant . . . . . $enable_tokyotyrant
      unixsock  . . . . . . $enable_unixsock
      uptime  . . . . . . . $enable_uptime
      users . . . . . . . . $enable_users
      uuid  . . . . . . . . $enable_uuid
 +    varnish . . . . . . . $enable_varnish
      vmem  . . . . . . . . $enable_vmem
      vserver . . . . . . . $enable_vserver
      wireless  . . . . . . $enable_wireless
      write_http  . . . . . $enable_write_http
 +    write_redis . . . . . $enable_write_redis
      xmms  . . . . . . . . $enable_xmms
      zfs_arc . . . . . . . $enable_zfs_arc
  
diff --combined src/curl_json.c
@@@ -32,7 -32,7 +32,7 @@@
  
  #define CJ_DEFAULT_HOST "localhost"
  #define CJ_KEY_MAGIC 0x43484b59UL /* CHKY */
 -#define CJ_IS_KEY(key) (key)->magic == CJ_KEY_MAGIC
 +#define CJ_IS_KEY(key) ((key)->magic == CJ_KEY_MAGIC)
  #define CJ_ANY "*"
  #define COUCH_MIN(x,y) ((x) < (y) ? (x) : (y))
  
@@@ -56,8 -56,8 +56,8 @@@ struct cj_s /* {{{ *
    char *user;
    char *pass;
    char *credentials;
 -  int   verify_peer;
 -  int   verify_host;
 +  _Bool verify_peer;
 +  _Bool verify_host;
    char *cacert;
  
    CURL *curl;
@@@ -98,12 -98,18 +98,12 @@@ static size_t cj_curl_callback (void *b
      return (0);
  
    status = yajl_parse(db->yajl, (unsigned char *)buf, len);
 -  if (status == yajl_status_ok)
 -  {
 -    status = yajl_parse_complete(db->yajl);
 -    return (len);
 -  }
 -  else if (status == yajl_status_insufficient_data)
 -    return (len);
 -
 -  if (status != yajl_status_ok)
 +  if ((status != yajl_status_ok)
 +      && (status != yajl_status_insufficient_data))
    {
      unsigned char *msg =
 -      yajl_get_error(db->yajl, 1, (unsigned char *)buf, len);
 +      yajl_get_error(db->yajl, /* verbose = */ 1,
 +          /* jsonText = */ (unsigned char *) buf, (unsigned int) len);
      ERROR ("curl_json plugin: yajl_parse failed: %s", msg);
      yajl_free_error(db->yajl, msg);
      return (0); /* abort write callback */
@@@ -136,21 -142,39 +136,21 @@@ static int cj_cb_number (void *ctx
  
    cj_t *db = (cj_t *)ctx;
    cj_key_t *key = db->state[db->depth].key;
 -  char *endptr;
    value_t vt;
    int type;
 +  int status;
  
 -  if (key == NULL)
 +  if ((key == NULL) || !CJ_IS_KEY (key))
      return (CJ_CB_CONTINUE);
  
    memcpy (buffer, number, number_len);
    buffer[sizeof (buffer) - 1] = 0;
  
    type = cj_get_type (key);
 -
 -  endptr = NULL;
 -  errno = 0;
 -
 -  if (type == DS_TYPE_COUNTER)
 -    vt.counter = (counter_t) strtoull (buffer, &endptr, /* base = */ 0);
 -  else if (type == DS_TYPE_GAUGE)
 -    vt.gauge = (gauge_t) strtod (buffer, &endptr);
 -  else if (type == DS_TYPE_DERIVE)
 -    vt.derive = (derive_t) strtoll (buffer, &endptr, /* base = */ 0);
 -  else if (type == DS_TYPE_ABSOLUTE)
 -    vt.absolute = (absolute_t) strtoull (buffer, &endptr, /* base = */ 0);
 -  else
 -  {
 -    ERROR ("curl_json plugin: Unknown data source type: \"%s\"", key->type);
 -    return (CJ_CB_ABORT);
 -  }
 -
 -  if ((endptr == &buffer[0]) || (errno != 0))
 +  status = parse_value (buffer, &vt, type);
 +  if (status != 0)
    {
 -    NOTICE ("curl_json plugin: Overflow while parsing number. "
 -        "Ignoring this value.");
 +    NOTICE ("curl_json plugin: Unable to parse number: \"%s\"", buffer);
      return (CJ_CB_CONTINUE);
    }
  
@@@ -190,26 -214,34 +190,26 @@@ static int cj_cb_string (void *ctx, con
                             unsigned int len)
  {
    cj_t *db = (cj_t *)ctx;
 -  c_avl_tree_t *tree;
 -  char *ptr;
 -
 -  if (db->depth != 1) /* e.g. _all_dbs */
 -    return (CJ_CB_CONTINUE);
 +  char str[len + 1];
  
 -  cj_cb_map_key (ctx, val, len); /* same logic */
 +  /* Create a null-terminated version of the string. */
 +  memcpy (str, val, len);
 +  str[len] = 0;
  
 -  tree = db->state[db->depth].tree;
 +  /* No configuration for this string -> simply return. */
 +  if (db->state[db->depth].key == NULL)
 +    return (CJ_CB_CONTINUE);
  
 -  if ((tree != NULL) && (ptr = rindex (db->url, '/')))
 +  if (!CJ_IS_KEY (db->state[db->depth].key))
    {
 -    char url[PATH_MAX];
 -    CURL *curl;
 -
 -    /* url =~ s,[^/]+$,$name, */
 -    len = (ptr - db->url) + 1;
 -    ptr = url;
 -    sstrncpy (ptr, db->url, sizeof (url));
 -    sstrncpy (ptr + len, db->state[db->depth].name, sizeof (url) - len);
 -
 -    curl = curl_easy_duphandle (db->curl);
 -    curl_easy_setopt (curl, CURLOPT_URL, url);
 -    cj_curl_perform (db, curl);
 -    curl_easy_cleanup (curl);
 +    NOTICE ("curl_json plugin: Found string \"%s\", but the configuration "
 +        "expects a map here.", str);
 +    return (CJ_CB_CONTINUE);
    }
 -  return (CJ_CB_CONTINUE);
 -}
 +
 +  /* Handle the string as if it was a number. */
 +  return (cj_cb_number (ctx, (const char *) val, len));
 +} /* int cj_cb_string */
  
  static int cj_cb_start (void *ctx)
  {
@@@ -247,7 -279,7 +247,7 @@@ static int cj_cb_start_array (void * ct
  
  static int cj_cb_end_array (void * ctx)
  {
-   return cj_cb_start (ctx);
+   return cj_cb_end (ctx);
  }
  
  static yajl_callbacks ycallbacks = {
@@@ -331,6 -363,37 +331,6 @@@ static void cj_free (void *arg) /* {{{ 
  
  /* Configuration handling functions {{{ */
  
 -static int cj_config_add_string (const char *name, char **dest, /* {{{ */
 -                                      oconfig_item_t *ci)
 -{
 -  if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING))
 -  {
 -    WARNING ("curl_json plugin: `%s' needs exactly one string argument.", name);
 -    return (-1);
 -  }
 -
 -  sfree (*dest);
 -  *dest = strdup (ci->values[0].value.string);
 -  if (*dest == NULL)
 -    return (-1);
 -
 -  return (0);
 -} /* }}} int cj_config_add_string */
 -
 -static int cj_config_set_boolean (const char *name, int *dest, /* {{{ */
 -                                       oconfig_item_t *ci)
 -{
 -  if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN))
 -  {
 -    WARNING ("curl_json plugin: `%s' needs exactly one boolean argument.", name);
 -    return (-1);
 -  }
 -
 -  *dest = ci->values[0].value.boolean ? 1 : 0;
 -
 -  return (0);
 -} /* }}} int cj_config_set_boolean */
 -
  static c_avl_tree_t *cj_avl_create(void)
  {
    return c_avl_create ((int (*) (const void *, const void *)) strcmp);
@@@ -362,7 -425,7 +362,7 @@@ static int cj_config_add_key (cj_t *db
  
    if (strcasecmp ("Key", ci->key) == 0)
    {
 -    status = cj_config_add_string ("Key", &key->path, ci);
 +    status = cf_util_get_string (ci, &key->path);
      if (status != 0)
      {
        sfree (key);
      oconfig_item_t *child = ci->children + i;
  
      if (strcasecmp ("Type", child->key) == 0)
 -      status = cj_config_add_string ("Type", &key->type, child);
 +      status = cf_util_get_string (child, &key->type);
      else if (strcasecmp ("Instance", child->key) == 0)
 -      status = cj_config_add_string ("Instance", &key->instance, child);
 +      status = cf_util_get_string (child, &key->instance);
      else
      {
        WARNING ("curl_json plugin: Option `%s' not allowed here.", child->key);
@@@ -499,9 -562,9 +499,9 @@@ static int cj_init_curl (cj_t *db) /* {
      curl_easy_setopt (db->curl, CURLOPT_USERPWD, db->credentials);
    }
  
 -  curl_easy_setopt (db->curl, CURLOPT_SSL_VERIFYPEER, db->verify_peer);
 +  curl_easy_setopt (db->curl, CURLOPT_SSL_VERIFYPEER, (int) db->verify_peer);
    curl_easy_setopt (db->curl, CURLOPT_SSL_VERIFYHOST,
 -                    db->verify_host ? 2 : 0);
 +                    (int) (db->verify_host ? 2 : 0));
    if (db->cacert != NULL)
      curl_easy_setopt (db->curl, CURLOPT_CAINFO, db->cacert);
  
@@@ -532,7 -595,7 +532,7 @@@ static int cj_config_add_url (oconfig_i
  
    if (strcasecmp ("URL", ci->key) == 0)
    {
 -    status = cj_config_add_string ("URL", &db->url, ci);
 +    status = cf_util_get_string (ci, &db->url);
      if (status != 0)
      {
        sfree (db);
      oconfig_item_t *child = ci->children + i;
  
      if (strcasecmp ("Instance", child->key) == 0)
 -      status = cj_config_add_string ("Instance", &db->instance, child);
 +      status = cf_util_get_string (child, &db->instance);
      else if (strcasecmp ("Host", child->key) == 0)
 -      status = cj_config_add_string ("Host", &db->host, child);
 +      status = cf_util_get_string (child, &db->host);
      else if (strcasecmp ("User", child->key) == 0)
 -      status = cj_config_add_string ("User", &db->user, child);
 +      status = cf_util_get_string (child, &db->user);
      else if (strcasecmp ("Password", child->key) == 0)
 -      status = cj_config_add_string ("Password", &db->pass, child);
 +      status = cf_util_get_string (child, &db->pass);
      else if (strcasecmp ("VerifyPeer", child->key) == 0)
 -      status = cj_config_set_boolean ("VerifyPeer", &db->verify_peer, child);
 +      status = cf_util_get_boolean (child, &db->verify_peer);
      else if (strcasecmp ("VerifyHost", child->key) == 0)
 -      status = cj_config_set_boolean ("VerifyHost", &db->verify_host, child);
 +      status = cf_util_get_boolean (child, &db->verify_host);
      else if (strcasecmp ("CACert", child->key) == 0)
 -      status = cj_config_add_string ("CACert", &db->cacert, child);
 +      status = cf_util_get_string (child, &db->cacert);
      else if (strcasecmp ("Key", child->key) == 0)
        status = cj_config_add_key (db, child);
      else
@@@ -705,48 -768,29 +705,48 @@@ static int cj_curl_perform (cj_t *db, C
      return (-1);
    }
  
 -  status = curl_easy_perform (curl);
 +  url = NULL;
 +  curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &url);
  
 -  yajl_free (db->yajl);
 -  db->yajl = yprev;
 +  status = curl_easy_perform (curl);
 +  if (status != 0)
 +  {
 +    ERROR ("curl_json plugin: curl_easy_perform failed with status %i: %s (%s)",
 +           status, db->curl_errbuf, (url != NULL) ? url : "<null>");
 +    yajl_free (db->yajl);
 +    db->yajl = yprev;
 +    return (-1);
 +  }
  
 -  curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &url);
    curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &rc);
  
    /* The response code is zero if a non-HTTP transport was used. */
    if ((rc != 0) && (rc != 200))
    {
 -    ERROR ("curl_json plugin: curl_easy_perform failed with response code %ld (%s)",
 -           rc, url);
 +    ERROR ("curl_json plugin: curl_easy_perform failed with "
 +        "response code %ld (%s)", rc, url);
 +    yajl_free (db->yajl);
 +    db->yajl = yprev;
      return (-1);
    }
  
 -  if (status != 0)
 +  status = yajl_parse_complete (db->yajl);
 +  if (status != yajl_status_ok)
    {
 -    ERROR ("curl_json plugin: curl_easy_perform failed with status %i: %s (%s)",
 -           status, db->curl_errbuf, url);
 +    unsigned char *errmsg;
 +
 +    errmsg = yajl_get_error (db->yajl, /* verbose = */ 0,
 +        /* jsonText = */ NULL, /* jsonTextLen = */ 0);
 +    ERROR ("curl_json plugin: yajl_parse_complete failed: %s",
 +        (char *) errmsg);
 +    yajl_free_error (db->yajl, errmsg);
 +    yajl_free (db->yajl);
 +    db->yajl = yprev;
      return (-1);
    }
  
 +  yajl_free (db->yajl);
 +  db->yajl = yprev;
    return (0);
  } /* }}} int cj_curl_perform */
  
diff --combined src/dns.c
+++ b/src/dns.c
@@@ -1,6 -1,6 +1,6 @@@
  /**
   * collectd - src/dns.c
-  * Copyright (C) 2006,2007  Florian octo Forster
+  * Copyright (C) 2006-2011  Florian octo Forster
   * Copyright (C) 2009       Mirko Buffoni
   *
   * This program is free software; you can redistribute it and/or modify it
@@@ -17,7 -17,7 +17,7 @@@
   * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
   *
   * Authors:
-  *   Florian octo Forster <octo at verplant.org>
+  *   Florian octo Forster <octo at collectd.org>
   *   Mirko Buffoni <briareos at eswat.org>
   **/
  
  
  #include "utils_dns.h"
  #include <pthread.h>
- #include <pcap.h>
  #include <poll.h>
  
+ #include <pcap.h>
+ #if HAVE_PCAP_BPF_H
+ # include <pcap-bpf.h>
+ #endif
  /*
   * Private data types
   */
@@@ -59,8 -63,8 +63,8 @@@ static int select_numeric_qtype = 1
  #define PCAP_SNAPLEN 1460
  static char   *pcap_device = NULL;
  
 -static counter_t       tr_queries;
 -static counter_t       tr_responses;
 +static derive_t       tr_queries;
 +static derive_t       tr_responses;
  static counter_list_t *qtype_list;
  static counter_list_t *opcode_list;
  static counter_list_t *rcode_list;
@@@ -80,10 -84,14 +84,10 @@@ static counter_list_t *counter_list_sea
  {
        counter_list_t *entry;
  
 -      DEBUG ("counter_list_search (list = %p, key = %u)",
 -                      (void *) *list, key);
 -
        for (entry = *list; entry != NULL; entry = entry->next)
                if (entry->key == key)
                        break;
  
 -      DEBUG ("return (%p)", (void *) entry);
        return (entry);
  }
  
@@@ -92,6 -100,9 +96,6 @@@ static counter_list_t *counter_list_cre
  {
        counter_list_t *entry;
  
 -      DEBUG ("counter_list_create (list = %p, key = %u, value = %u)",
 -                      (void *) *list, key, value);
 -
        entry = (counter_list_t *) malloc (sizeof (counter_list_t));
        if (entry == NULL)
                return (NULL);
                last->next = entry;
        }
  
 -      DEBUG ("return (%p)", (void *) entry);
        return (entry);
  }
  
@@@ -123,6 -135,9 +127,6 @@@ static void counter_list_add (counter_l
  {
        counter_list_t *entry;
  
 -      DEBUG ("counter_list_add (list = %p, key = %u, increment = %u)",
 -                      (void *) *list, key, increment);
 -
        entry = counter_list_search (list, key);
  
        if (entry != NULL)
        {
                counter_list_create (list, key, increment);
        }
 -      DEBUG ("return ()");
  }
  
  static int dns_config (const char *key, const char *value)
@@@ -206,7 -222,7 +210,7 @@@ static void dns_child_callback (const r
        pthread_mutex_unlock (&opcode_mutex);
  }
  
- static void *dns_child_loop (void __attribute__((unused)) *dummy)
+ static void *dns_child_loop (__attribute__((unused)) void *dummy)
  {
        pcap_t *pcap_obj;
        char    pcap_error[PCAP_ERRBUF_SIZE];
        pcap_obj = pcap_open_live ((pcap_device != NULL) ? pcap_device : "any",
                        PCAP_SNAPLEN,
                        0 /* Not promiscuous */,
 -                      interval_g,
 +                      (int) CDTIME_T_TO_MS (interval_g / 2),
                        pcap_error);
        if (pcap_obj == NULL)
        {
                return (NULL);
        }
  
 -      DEBUG ("PCAP object created.");
 +      DEBUG ("dns plugin: PCAP object created.");
  
        dnstop_set_pcap_obj (pcap_obj);
        dnstop_set_callback (dns_child_callback);
                ERROR ("dns plugin: Listener thread is exiting "
                                "abnormally: %s", pcap_geterr (pcap_obj));
  
 -      DEBUG ("child is exiting");
 +      DEBUG ("dns plugin: Child is exiting.");
  
        pcap_close (pcap_obj);
        listen_thread_init = 0;
@@@ -299,13 -315,13 +303,13 @@@ static int dns_init (void
        return (0);
  } /* int dns_init */
  
 -static void submit_counter (const char *type, const char *type_instance,
 -              counter_t value)
 +static void submit_derive (const char *type, const char *type_instance,
 +              derive_t value)
  {
        value_t values[1];
        value_list_t vl = VALUE_LIST_INIT;
  
 -      values[0].counter = value;
 +      values[0].derive = value;
  
        vl.values = values;
        vl.values_len = 1;
        sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
  
        plugin_dispatch_values (&vl);
 -} /* void submit_counter */
 +} /* void submit_derive */
  
 -static void submit_octets (counter_t queries, counter_t responses)
 +static void submit_octets (derive_t queries, derive_t responses)
  {
        value_t values[2];
        value_list_t vl = VALUE_LIST_INIT;
  
 -      values[0].counter = queries;
 -      values[1].counter = responses;
 +      values[0].derive = queries;
 +      values[1].derive = responses;
  
        vl.values = values;
        vl.values_len = 2;
        sstrncpy (vl.type, "dns_octets", sizeof (vl.type));
  
        plugin_dispatch_values (&vl);
 -} /* void submit_counter */
 +} /* void submit_octets */
  
  static int dns_read (void)
  {
  
        for (i = 0; i < len; i++)
        {
 -              DEBUG ("qtype = %u; counter = %u;", keys[i], values[i]);
 -              submit_counter ("dns_qtype", qtype_str (keys[i]), values[i]);
 +              DEBUG ("dns plugin: qtype = %u; counter = %u;", keys[i], values[i]);
 +              submit_derive ("dns_qtype", qtype_str (keys[i]), values[i]);
        }
  
        pthread_mutex_lock (&opcode_mutex);
  
        for (i = 0; i < len; i++)
        {
 -              DEBUG ("opcode = %u; counter = %u;", keys[i], values[i]);
 -              submit_counter ("dns_opcode", opcode_str (keys[i]), values[i]);
 +              DEBUG ("dns plugin: opcode = %u; counter = %u;", keys[i], values[i]);
 +              submit_derive ("dns_opcode", opcode_str (keys[i]), values[i]);
        }
  
        pthread_mutex_lock (&rcode_mutex);
  
        for (i = 0; i < len; i++)
        {
 -              DEBUG ("rcode = %u; counter = %u;", keys[i], values[i]);
 -              submit_counter ("dns_rcode", rcode_str (keys[i]), values[i]);
 +              DEBUG ("dns plugin: rcode = %u; counter = %u;", keys[i], values[i]);
 +              submit_derive ("dns_rcode", rcode_str (keys[i]), values[i]);
        }
  
        return (0);
diff --combined src/java.c
@@@ -109,7 -109,7 +109,7 @@@ static int cjni_callback_register (JNIE
  static int cjni_read (user_data_t *user_data);
  static int cjni_write (const data_set_t *ds, const value_list_t *vl,
      user_data_t *ud);
 -static int cjni_flush (int timeout, const char *identifier, user_data_t *ud);
 +static int cjni_flush (cdtime_t timeout, const char *identifier, user_data_t *ud);
  static void cjni_log (int severity, const char *message, user_data_t *ud);
  static int cjni_notification (const notification_t *n, user_data_t *ud);
  
@@@ -809,7 -809,7 +809,7 @@@ static jobject ctoj_value_list (JNIEnv 
  #undef SET_STRING
  
    /* Set the `time' member. Java stores time in milliseconds. */
 -  status = ctoj_long (jvm_env, ((jlong) vl->time) * ((jlong) 1000),
 +  status = ctoj_long (jvm_env, (jlong) CDTIME_T_TO_MS (vl->time),
        c_valuelist, o_valuelist, "setTime");
    if (status != 0)
    {
    }
  
    /* Set the `interval' member.. */
 -  status = ctoj_long (jvm_env, (jlong) vl->interval,
 +  status = ctoj_long (jvm_env,
 +      (jlong) CDTIME_T_TO_MS (vl->interval),
        c_valuelist, o_valuelist, "setInterval");
    if (status != 0)
    {
@@@ -915,7 -914,7 +915,7 @@@ static jobject ctoj_notification (JNIEn
      return (NULL);
    }
  
 -  /* Set the `interval' member.. */
 +  /* Set the `severity' member.. */
    status = ctoj_int (jvm_env, (jint) n->severity,
        c_notification, o_notification, "setSeverity");
    if (status != 0)
@@@ -1243,7 -1242,7 +1243,7 @@@ static int jtoc_value_list (JNIEnv *jvm
      return (-1);
    }
    /* Java measures time in milliseconds. */
 -  vl->time = (time_t) (tmp_long / ((jlong) 1000));
 +  vl->time = MS_TO_CDTIME_T (tmp_long);
  
    status = jtoc_long (jvm_env, &tmp_long,
        class_ptr, object_ptr, "getInterval");
      ERROR ("java plugin: jtoc_value_list: jtoc_long (getInterval) failed.");
      return (-1);
    }
 -  vl->interval = (int) tmp_long;
 +  vl->interval = MS_TO_CDTIME_T (tmp_long);
  
    status = jtoc_values_array (jvm_env, ds, vl, class_ptr, object_ptr);
    if (status != 0)
@@@ -1730,7 -1729,7 +1730,7 @@@ static cjni_callback_info_t *cjni_callb
  
      case CB_TYPE_FLUSH:
        method_name = "flush";
 -      method_signature = "(ILjava/lang/String;)I";
 +      method_signature = "(Ljava/lang/Number;Ljava/lang/String;)I";
        break;
  
      case CB_TYPE_SHUTDOWN:
@@@ -1932,7 -1931,9 +1932,9 @@@ static int cjni_init_native (JNIEnv *jv
    api_class_ptr = (*jvm_env)->FindClass (jvm_env, "org/collectd/api/Collectd");
    if (api_class_ptr == NULL)
    {
-     ERROR ("cjni_init_native: Cannot find API class `org/collectd/api/Collectd'.");
+     ERROR ("cjni_init_native: Cannot find the API class \"org.collectd.api"
+         ".Collectd\". Please set the correct class path "
+         "using 'JVMArg \"-Djava.class.path=...\"'.");
      return (-1);
    }
  
@@@ -2552,12 -2553,11 +2554,12 @@@ static int cjni_write (const data_set_
  } /* }}} int cjni_write */
  
  /* Call the CB_TYPE_FLUSH callback pointed to by the `user_data_t' pointer. */
 -static int cjni_flush (int timeout, const char *identifier, /* {{{ */
 +static int cjni_flush (cdtime_t timeout, const char *identifier, /* {{{ */
      user_data_t *ud)
  {
    JNIEnv *jvm_env;
    cjni_callback_info_t *cbi;
 +  jobject o_timeout;
    jobject o_identifier;
    int status;
    int ret_status;
  
    cbi = (cjni_callback_info_t *) ud->data;
  
 +  o_timeout = ctoj_jdouble_to_number (jvm_env,
 +      (jdouble) CDTIME_T_TO_DOUBLE (timeout));
 +  if (o_timeout == NULL)
 +  {
 +    ERROR ("java plugin: cjni_flush: Converting double "
 +        "to Number object failed.");
 +    return (-1);
 +  }
 +
    o_identifier = NULL;
    if (identifier != NULL)
    {
      o_identifier = (*jvm_env)->NewStringUTF (jvm_env, identifier);
      if (o_identifier == NULL)
      {
 +      (*jvm_env)->DeleteLocalRef (jvm_env, o_timeout);
        ERROR ("java plugin: cjni_flush: NewStringUTF failed.");
        return (-1);
      }
    }
  
    ret_status = (*jvm_env)->CallIntMethod (jvm_env,
 -      cbi->object, cbi->method, (jint) timeout, o_identifier);
 +      cbi->object, cbi->method, o_timeout, o_identifier);
  
    (*jvm_env)->DeleteLocalRef (jvm_env, o_identifier);
 +  (*jvm_env)->DeleteLocalRef (jvm_env, o_timeout);
  
    status = cjni_thread_detach ();
    if (status != 0)