Merge branch 'collectd-4.10' into collectd-5.0
authorFlorian Forster <octo@collectd.org>
Sun, 21 Aug 2011 14:43:22 +0000 (16:43 +0200)
committerFlorian Forster <octo@collectd.org>
Sun, 21 Aug 2011 14:43:22 +0000 (16:43 +0200)
Conflicts:
src/curl_json.c
src/libvirt.c

Change-Id: I0852495b416435fa3cfd36068d967e0cd5ff689f

18 files changed:
1  2 
configure.in
src/apache.c
src/bind.c
src/csv.c
src/curl.c
src/curl_json.c
src/df.c
src/disk.c
src/java.c
src/libvirt.c
src/mysql.c
src/network.c
src/nginx.c
src/notify_email.c
src/processes.c
src/teamspeak2.c
src/utils_dns.c
src/write_http.c

diff --combined configure.in
@@@ -2,6 -2,7 +2,7 @@@ dnl Process this file with autoconf to 
  AC_INIT(collectd, m4_esyscmd(./version-gen.sh))
  AC_CONFIG_SRCDIR(src/collectd.c)
  AC_CONFIG_HEADERS(src/config.h)
+ AC_CONFIG_AUX_DIR([libltdl/config])
  
  m4_ifdef([LT_PACKAGE_VERSION],
        # libtool >= 2.2
@@@ -108,13 -109,9 +109,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 -569,6 +573,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 -589,13 +615,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 -617,7 +757,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 -643,7 +783,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 -677,7 +817,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=""
@@@ -1841,7 -1638,8 +1842,8 @@@ the
        [
                with_libiptc="yes"
                with_own_libiptc="yes"
-       ])
+       ],
+       [-lip4tc -lip6tc])
  fi
  # The system wide version failed for some reason. Check if we have the required
  # headers to build the shipped version.
@@@ -2129,7 -1927,7 +2131,7 @@@ the
        $PKG_CONFIG --exists 'modbus' 2>/dev/null
        if test $? -ne 0
        then
 -              with_libmodbus="no (pkg-config doesn't know library)"
 +              with_libmodbus="no (pkg-config doesn't know modbus)"
        fi
  fi
  if test "x$with_libmodbus" = "xuse_pkgconfig"
@@@ -2169,9 -1967,9 +2171,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"
@@@ -2594,7 -2392,7 +2596,7 @@@ the
        fi
        AC_CHECK_HEADERS(oping.h,
        [with_liboping="yes"],
 -      [with_liboping="no ('oping.h' not found)"])
 +      [with_liboping="no (oping.h not found)"])
  fi
  if test "x$with_liboping" = "xyes"
  then
@@@ -2765,8 -2563,7 +2767,8 @@@ the
  fi
  if test "x$with_libpcap" = "xyes"
  then
 -      AC_CHECK_HEADERS(pcap-bpf.h)
 +      AC_CHECK_HEADERS(pcap-bpf.h,,
 +                       [with_libpcap="no (pcap-bpf.h not found)"])
  fi
  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.])],
  [
@@@ -3283,7 -3029,7 +3285,7 @@@ the
        fi
        AC_CHECK_HEADERS(routeros_api.h,
        [with_librouteros="yes"],
 -      [with_librouteros="no ('routeros_api.h' not found)"])
 +      [with_librouteros="no (routeros_api.h not found)"])
  fi
  if test "x$with_librouteros" = "xyes"
  then
@@@ -3482,7 -3228,7 +3484,7 @@@ the
      if test "$?" != "0"
      then
        with_libstatgrab_pkg_config="no"
 -      with_libstatgrab="no ($PKG_CONFIG doesn't know libstatgrab)"
 +      with_libstatgrab="no (pkg-config doesn't know libstatgrab)"
        temp_result="not found"
      fi
      AC_MSG_RESULT([$temp_result])
@@@ -3702,7 -3448,7 +3704,7 @@@ the
        $PKG_CONFIG --exists 'libupsclient' 2>/dev/null
        if test $? -ne 0
        then
 -              with_libupsclient="no (pkg-config doesn't know library)"
 +              with_libupsclient="no (pkg-config doesn't know libupsclient)"
        fi
  fi
  if test "x$with_libupsclient" = "xuse_pkgconfig"
@@@ -3863,6 -3609,7 +3865,7 @@@ the
        CPPFLAGS="$CPPFLAGS $with_libyajl_cppflags"
  
        AC_CHECK_HEADERS(yajl/yajl_parse.h, [with_libyajl="yes"], [with_libyajl="no (yajl/yajl_parse.h not found)"])
+       AC_CHECK_HEADERS(yajl/yajl_version.h)
  
        CPPFLAGS="$SAVE_CPPFLAGS"
  fi
  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 varnishapi)"
 +      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=""
@@@ -3997,7 -3652,7 +4000,7 @@@ the
        then
                with_libxml2="yes"
        else
 -              with_libxml2="no (pkg-config doesn't know library)"
 +              with_libxml2="no (pkg-config doesn't know libxml-2.0)"
        fi
  
        pkg-config --exists libvirt 2>/dev/null
        then
                with_libvirt="yes"
        else
 -              with_libvirt="no (pkg-config doesn't know library)"
 +              with_libvirt="no (pkg-config doesn't know libvirt)"
        fi
  fi
  if test "x$with_libxml2" = "xyes"
@@@ -4122,7 -3777,7 +4125,7 @@@ the
        $PKG_CONFIG --exists OpenIPMIpthread 2>/dev/null
        if test "$?" != "0"
        then
 -              with_libopenipmipthread="no ($PKG_CONFIG doesn't know OpenIPMIpthread)"
 +              with_libopenipmipthread="no (pkg-config doesn't know OpenIPMIpthread)"
        fi
        AC_MSG_RESULT([$with_libopenipmipthread])
  fi
  
  PKG_CHECK_MODULES([LIBNOTIFY], [libnotify],
                [with_libnotify="yes"],
 -              [with_libnotify="no ($LIBNOTIFY_PKG_ERRORS)"])
 +              [if test "x$LIBNOTIFY_PKG_ERRORS" = "x"; then
 +                       with_libnotify="no"
 +               else
 +                       with_libnotify="no ($LIBNOTIFY_PKG_ERRORS)"
 +               fi])
  
  # Check for enabled/disabled features
  #
@@@ -4430,6 -4081,11 +4433,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"
@@@ -4474,15 -4127,11 +4477,15 @@@ if test "x$have_sysctl" = "xyes
  then
        plugin_cpu="yes"
        plugin_memory="yes"
 -      plugin_swap="yes"
        plugin_uptime="yes"
 +      if test "x$ac_system" = "xDarwin"
 +      then
 +              plugin_swap="yes"
 +      fi
  fi
  if test "x$have_sysctlbyname" = "xyes"
  then
 +      plugin_contextswitch="yes"
        plugin_cpu="yes"
        plugin_memory="yes"
        plugin_tcpconns="yes"
@@@ -4570,7 -4219,7 +4573,7 @@@ the
        plugin_swap="yes"
  fi
  
 -if test "x$have_swapctl" = "xyes"
 +if test "x$have_swapctl" = "xyes" && test "x$c_cv_have_swapctl_two_args" = "xyes"
  then
        plugin_swap="yes"
  fi
@@@ -4610,7 -4259,6 +4613,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])
@@@ -4645,7 -4293,6 +4648,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])
@@@ -4681,7 -4328,6 +4684,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])
@@@ -4697,23 -4343,19 +4700,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])
  
@@@ -4888,7 -4530,6 +4891,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/apache.c
@@@ -1,6 -1,6 +1,6 @@@
  /**
   * collectd - src/apache.c
 - * Copyright (C) 2006-2009  Florian octo Forster
 + * Copyright (C) 2006-2010  Florian octo Forster
   * Copyright (C) 2007       Florent EppO Monbillard
   * Copyright (C) 2009       Amit Gupta
   *
@@@ -144,8 -144,6 +144,8 @@@ static size_t apache_header_callback (v
                st->server_type = APACHE;
        else if (strstr (buf, "lighttpd") != NULL)
                st->server_type = LIGHTTPD;
 +      else if (strstr (buf, "IBM_HTTP_Server") != NULL)
 +              st->server_type = APACHE;
        else
        {
                const char *hdr = buf;
@@@ -335,22 -333,57 +335,22 @@@ static int config (oconfig_item_t *ci
  {
        int status = 0;
        int i;
 -      oconfig_item_t *lci = NULL; /* legacy config */
  
        for (i = 0; i < ci->children_num; i++)
        {
                oconfig_item_t *child = ci->children + i;
  
 -              if (strcasecmp ("Instance", child->key) == 0 && child->children_num > 0)
 +              if (strcasecmp ("Instance", child->key) == 0)
                        config_add (child);
                else
 -              {
 -                      /* legacy mode - convert to <Instance ...> config */
 -                      if (lci == NULL)
 -                      {
 -                              lci = malloc (sizeof(*lci));
 -                              if (lci == NULL)
 -                              {
 -                                      ERROR ("apache plugin: malloc failed.");
 -                                      return (-1);
 -                              }
 -                              memset (lci, '\0', sizeof (*lci));
 -                      }
 -
 -                      lci->children_num++;
 -                      lci->children =
 -                              realloc (lci->children,
 -                                       lci->children_num * sizeof (*child));
 -                      if (lci->children == NULL)
 -                      {
 -                              ERROR ("apache plugin: realloc failed.");
 -                              return (-1);
 -                      }
 -                      memcpy (&lci->children[lci->children_num-1], child, sizeof (*child));
 -              }
 +                      WARNING ("apache plugin: The configuration option "
 +                                      "\"%s\" is not allowed here. Did you "
 +                                      "forget to add an <Instance /> block "
 +                                      "around the configuration?",
 +                                      child->key);
        } /* for (ci->children) */
  
 -      if (lci)
 -      {
 -              /* create a <Instance ""> entry */
 -              lci->key = "Instance";
 -              lci->values_num = 1;
 -              lci->values = (oconfig_value_t *) malloc (lci->values_num * sizeof (oconfig_value_t));
 -              lci->values[0].type = OCONFIG_TYPE_STRING;
 -              lci->values[0].value.string = "";
 -
 -              status = config_add (lci);
 -              sfree (lci->values);
 -              sfree (lci->children);
 -              sfree (lci);
 -      }
 -
 -      return status;
 +      return (status);
  } /* int config */
  
  /* initialize curl for each host */
@@@ -373,6 -406,7 +373,7 @@@ static int init_host (apache_t *st) /* 
                return (-1);
        }
  
+       curl_easy_setopt (st->curl, CURLOPT_NOSIGNAL, 1);
        curl_easy_setopt (st->curl, CURLOPT_WRITEFUNCTION, apache_curl_callback);
        curl_easy_setopt (st->curl, CURLOPT_WRITEDATA, st);
  
                        st->server_type = APACHE;
                else if (strcasecmp(st->server, "lighttpd") == 0)
                        st->server_type = LIGHTTPD;
 +              else if (strcasecmp(st->server, "ibm_http_server") == 0)
 +                      st->server_type = APACHE;
                else
                        WARNING ("apache plugin: Unknown `Server' setting: %s",
                                        st->server);
@@@ -476,13 -508,13 +477,13 @@@ static void submit_value (const char *t
        plugin_dispatch_values (&vl);
  } /* void submit_value */
  
 -static void submit_counter (const char *type, const char *type_instance,
 -              counter_t c, apache_t *st)
 +static void submit_derive (const char *type, const char *type_instance,
 +              derive_t c, apache_t *st)
  {
        value_t v;
 -      v.counter = c;
 +      v.derive = c;
        submit_value (type, type_instance, v, st);
 -} /* void submit_counter */
 +} /* void submit_derive */
  
  static void submit_gauge (const char *type, const char *type_instance,
                gauge_t g, apache_t *st)
@@@ -644,11 -676,11 +645,11 @@@ static int apache_read_host (user_data_
                {
                        if ((strcmp (fields[0], "Total") == 0)
                                        && (strcmp (fields[1], "Accesses:") == 0))
 -                              submit_counter ("apache_requests", "",
 +                              submit_derive ("apache_requests", "",
                                                atoll (fields[2]), st);
                        else if ((strcmp (fields[0], "Total") == 0)
                                        && (strcmp (fields[1], "kBytes:") == 0))
 -                              submit_counter ("apache_bytes", "",
 +                              submit_derive ("apache_bytes", "",
                                                1024LL * atoll (fields[2]), st);
                }
                else if (fields_num == 2)
diff --combined src/bind.c
@@@ -1,7 -1,7 +1,7 @@@
  /**
   * collectd - src/bind.c
 - * Copyright (C) 2009  Bruno Prémont
 - * Copyright (C) 2009  Florian Forster
 + * Copyright (C) 2009       Bruno Prémont
 + * Copyright (C) 2009,2010  Florian Forster
   *
   * This program is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License as published by the
   *
   * Authors:
   *   Bruno Prémont <bonbons at linux-vserver.org>
 - *   Florian Forster <octo at verplant.org>
 + *   Florian Forster <octo at collectd.org>
   **/
  
  #include "config.h"
  
 -#ifndef _XOPEN_SOURCE
 -# define _XOPEN_SOURCE 600 /* glibc2 needs this for strptime */
 -#endif
 +#if STRPTIME_NEEDS_STANDARDS
 +# 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
 +#endif /* STRPTIME_NEEDS_STANDARDS */
  
  #include "collectd.h"
  #include "common.h"
@@@ -249,7 -241,7 +249,7 @@@ static void submit (time_t ts, const ch
  
    vl.values = values;
    vl.values_len = 1;
 -  vl.time = ts;
 +  vl.time = TIME_T_TO_CDTIME_T (ts);
    sstrncpy(vl.host, hostname_g, sizeof(vl.host));
    sstrncpy(vl.plugin, "bind", sizeof(vl.plugin));
    if (plugin_instance) {
@@@ -345,31 -337,36 +345,31 @@@ static int bind_xml_list_callback (cons
    return (0);
  } /* }}} int bind_xml_list_callback */
  
 -static int bind_xml_read_counter (xmlDoc *doc, xmlNode *node, /* {{{ */
 -    counter_t *ret_value)
 +static int bind_xml_read_derive (xmlDoc *doc, xmlNode *node, /* {{{ */
 +    derive_t *ret_value)
  {
 -  char *str_ptr, *end_ptr;
 -  long long int value;
 +  char *str_ptr;
 +  value_t value;
 +  int status;
  
    str_ptr = (char *) xmlNodeListGetString (doc, node->xmlChildrenNode, 1);
    if (str_ptr == NULL)
    {
 -    ERROR ("bind plugin: bind_xml_read_counter: xmlNodeListGetString failed.");
 +    ERROR ("bind plugin: bind_xml_read_derive: xmlNodeListGetString failed.");
      return (-1);
    }
  
 -  errno = 0;
 -  value = strtoll (str_ptr, &end_ptr, 10);
 -  xmlFree(str_ptr);
 -  if (str_ptr == end_ptr || errno)
 +  status = parse_value (str_ptr, &value, DS_TYPE_DERIVE);
 +  if (status != 0)
    {
 -    if (errno && (value < 0))
 -      ERROR ("bind plugin: bind_xml_read_counter: strtoll failed with underflow.");
 -    else if (errno && (value > 0))
 -      ERROR ("bind plugin: bind_xml_read_counter: strtoll failed with overflow.");
 -    else
 -      ERROR ("bind plugin: bind_xml_read_counter: strtoll failed.");
 +    ERROR ("bind plugin: Parsing string \"%s\" to derive value failed.",
 +        str_ptr);
      return (-1);
    }
  
 -  *ret_value = value;
 +  *ret_value = value.derive;
    return (0);
 -} /* }}} int bind_xml_read_counter */
 +} /* }}} int bind_xml_read_derive */
  
  static int bind_xml_read_gauge (xmlDoc *doc, xmlNode *node, /* {{{ */
      gauge_t *ret_value)
@@@ -530,7 -527,7 +530,7 @@@ static int bind_parse_generic_name_valu
        if (ds_type == DS_TYPE_GAUGE)
          status = bind_xml_read_gauge (doc, counter, &value.gauge);
        else
 -        status = bind_xml_read_counter (doc, counter, &value.counter);
 +        status = bind_xml_read_derive (doc, counter, &value.derive);
        if (status != 0)
          continue;
  
@@@ -603,7 -600,7 +603,7 @@@ static int bind_parse_generic_value_lis
        if (ds_type == DS_TYPE_GAUGE)
          status = bind_xml_read_gauge (doc, child, &value.gauge);
        else
 -        status = bind_xml_read_counter (doc, child, &value.counter);
 +        status = bind_xml_read_derive (doc, child, &value.derive);
        if (status != 0)
          continue;
  
@@@ -1385,6 -1382,7 +1385,7 @@@ static int bind_init (void) /* {{{ *
      return (-1);
    }
  
+   curl_easy_setopt (curl, CURLOPT_NOSIGNAL, 1);
    curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, bind_curl_callback);
    curl_easy_setopt (curl, CURLOPT_USERAGENT, PACKAGE_NAME"/"PACKAGE_VERSION);
    curl_easy_setopt (curl, CURLOPT_ERRORBUFFER, bind_curl_error);
diff --combined src/csv.c
+++ b/src/csv.c
@@@ -53,8 -53,7 +53,8 @@@ static int value_list_to_string (char *
  
        memset (buffer, '\0', buffer_len);
  
 -      status = ssnprintf (buffer, buffer_len, "%u", (unsigned int) vl->time);
 +      status = ssnprintf (buffer, buffer_len, "%.3f",
 +                      CDTIME_T_TO_DOUBLE (vl->time));
        if ((status < 1) || (status >= buffer_len))
                return (-1);
        offset = status;
@@@ -264,7 -263,7 +264,7 @@@ static int csv_write (const data_set_t 
  {
        struct stat  statbuf;
        char         filename[512];
-       char         values[512];
+       char         values[4096];
        FILE        *csv;
        int          csv_fd;
        struct flock fl;
                }
  
                fprintf (use_stdio == 1 ? stdout : stderr,
 -                       "PUTVAL %s interval=%i %s\n",
 -                       filename, vl->interval, values);
 +                       "PUTVAL %s interval=%.3f %s\n",
 +                       filename,
 +                       CDTIME_T_TO_DOUBLE (vl->interval),
 +                       values);
                return (0);
        }
  
diff --combined src/curl.c
@@@ -370,6 -370,7 +370,7 @@@ static int cc_page_init_curl (web_page_
      return (-1);
    }
  
+   curl_easy_setopt (wp->curl, CURLOPT_NOSIGNAL, 1);
    curl_easy_setopt (wp->curl, CURLOPT_WRITEFUNCTION, cc_curl_callback);
    curl_easy_setopt (wp->curl, CURLOPT_WRITEDATA, wp);
    curl_easy_setopt (wp->curl, CURLOPT_USERAGENT,
@@@ -577,6 -578,7 +578,6 @@@ static void cc_submit (const web_page_
  
    vl.values = values;
    vl.values_len = 1;
 -  vl.time = time (NULL);
    sstrncpy (vl.host, hostname_g, sizeof (vl.host));
    sstrncpy (vl.plugin, "curl", sizeof (vl.plugin));
    sstrncpy (vl.plugin_instance, wp->instance, sizeof (vl.plugin_instance));
@@@ -595,6 -597,7 +596,6 @@@ static void cc_submit_response_time (co
  
    vl.values = values;
    vl.values_len = 1;
 -  vl.time = time (NULL);
    sstrncpy (vl.host, hostname_g, sizeof (vl.host));
    sstrncpy (vl.plugin, "curl", sizeof (vl.plugin));
    sstrncpy (vl.plugin_instance, wp->instance, sizeof (vl.plugin_instance));
diff --combined src/curl_json.c
@@@ -1,7 -1,7 +1,7 @@@
  /**
   * collectd - src/curl_json.c
   * Copyright (C) 2009       Doug MacEachern
-  * Copyright (C) 2006-2010  Florian octo Forster
+  * Copyright (C) 2006-2011  Florian octo Forster
   *
   * This program is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License as published by the
@@@ -18,7 -18,7 +18,7 @@@
   *
   * Authors:
   *   Doug MacEachern <dougm at hyperic.com>
-  *   Florian octo Forster <octo at verplant.org>
+  *   Florian octo Forster <octo at collectd.org>
   **/
  
  #include "collectd.h"
  
  #include <curl/curl.h>
  #include <yajl/yajl_parse.h>
+ #if HAVE_YAJL_YAJL_VERSION_H
+ # include <yajl/yajl_version.h>
+ #endif
+ #if defined(YAJL_MAJOR) && (YAJL_MAJOR > 1)
+ # define HAVE_YAJL_V2 1
+ #endif
  
  #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 -63,8 +63,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;
  };
  typedef struct cj_s cj_t; /* }}} */
  
+ #if HAVE_YAJL_V2
+ typedef size_t yajl_len_t;
+ #else
+ typedef unsigned int yajl_len_t;
+ #endif
  static int cj_read (user_data_t *ud);
  static int cj_curl_perform (cj_t *db, CURL *curl);
  static void cj_submit (cj_t *db, cj_key_t *key, value_t *value);
@@@ -97,13 -110,25 +110,26 @@@ static size_t cj_curl_callback (void *b
    if (db == NULL)
      return (0);
  
--  status = yajl_parse(db->yajl, (unsigned char *)buf, len);
-   if ((status != yajl_status_ok)
-       && (status != yajl_status_insufficient_data))
++  status = yajl_parse(db->yajl, (unsigned char *) buf, len);
+   if (status == yajl_status_ok)
+   {
+ #if HAVE_YAJL_V2
+     status = yajl_complete_parse(db->yajl);
+ #else
+     status = yajl_parse_complete(db->yajl);
+ #endif
+     return (len);
+   }
+ #if !HAVE_YAJL_V2
+   else if (status == yajl_status_insufficient_data)
+     return (len);
+ #endif
+   if (status != yajl_status_ok)
    {
      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 */
@@@ -130,27 -155,45 +156,27 @@@ static int cj_get_type (cj_key_t *key
  /* "number" may not be null terminated, so copy it into a buffer before
   * parsing. */
  static int cj_cb_number (void *ctx,
-     const char *number, unsigned int number_len)
+     const char *number, yajl_len_t number_len)
  {
    char buffer[number_len + 1];
  
    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);
    }
  
  } /* int cj_cb_number */
  
  static int cj_cb_map_key (void *ctx, const unsigned char *val,
-                             unsigned int len)
+     yajl_len_t len)
  {
    cj_t *db = (cj_t *)ctx;
    c_avl_tree_t *tree;
  }
  
  static int cj_cb_string (void *ctx, const unsigned char *val,
-                            unsigned int len)
+     yajl_len_t len)
  {
    cj_t *db = (cj_t *)ctx;
 -  c_avl_tree_t *tree;
 -  char *ptr;
 +  char str[len + 1];
  
 -  if (db->depth != 1) /* e.g. _all_dbs */
 -    return (CJ_CB_CONTINUE);
 +  /* Create a null-terminated version of the string. */
 +  memcpy (str, val, len);
 +  str[len] = 0;
  
 -  cj_cb_map_key (ctx, val, len); /* same logic */
 -
 -  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)
  {
@@@ -331,6 -382,37 +357,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 -444,7 +388,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);
@@@ -472,6 -554,7 +498,7 @@@ static int cj_init_curl (cj_t *db) /* {
      return (-1);
    }
  
+   curl_easy_setopt (db->curl, CURLOPT_NOSIGNAL, 1);
    curl_easy_setopt (db->curl, CURLOPT_WRITEFUNCTION, cj_curl_callback);
    curl_easy_setopt (db->curl, CURLOPT_WRITEDATA, db);
    curl_easy_setopt (db->curl, CURLOPT_USERAGENT,
      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 -615,7 +559,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
@@@ -697,7 -780,13 +724,13 @@@ static int cj_curl_perform (cj_t *db, C
    char *url;
    yajl_handle yprev = db->yajl;
  
-   db->yajl = yajl_alloc (&ycallbacks, NULL, NULL, (void *)db);
+   db->yajl = yajl_alloc (&ycallbacks,
+ #if HAVE_YAJL_V2
+       /* alloc funcs = */ NULL,
+ #else
+       /* alloc funcs = */ NULL, NULL,
+ #endif
+       /* context = */ (void *)db);
    if (db->yajl == NULL)
    {
      ERROR ("curl_json plugin: yajl_alloc failed.");
      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/df.c
+++ b/src/df.c
  #  include <sys/statvfs.h>
  # endif
  # define STATANYFS statvfs
+ # define STATANYFS_STR "statvfs"
  # define BLOCKSIZE(s) ((s).f_frsize ? (s).f_frsize : (s).f_bsize)
  #elif HAVE_STATFS
  # if HAVE_SYS_STATFS_H
  #  include <sys/statfs.h>
  # endif
  # define STATANYFS statfs
+ # define STATANYFS_STR "statfs"
  # define BLOCKSIZE(s) (s).f_bsize
  #else
  # error "No applicable input method."
@@@ -60,8 -62,9 +62,8 @@@ static ignorelist_t *il_device = NULL
  static ignorelist_t *il_mountpoint = NULL;
  static ignorelist_t *il_fstype = NULL;
  
 -static _Bool by_device = false;
 -static _Bool report_reserved = false;
 -static _Bool report_inodes = false;
 +static _Bool by_device = 0;
 +static _Bool report_inodes = 0;
  
  static int df_init (void)
  {
@@@ -116,16 -119,25 +118,16 @@@ static int df_config (const char *key, 
        else if (strcasecmp (key, "ReportByDevice") == 0)
        {
                if (IS_TRUE (value))
 -                      by_device = true;
 -
 -              return (0);
 -      }
 -      else if (strcasecmp (key, "ReportReserved") == 0)
 -      {
 -              if (IS_TRUE (value))
 -                      report_reserved = true;
 -              else
 -                      report_reserved = false;
 +                      by_device = 1;
  
                return (0);
        }
        else if (strcasecmp (key, "ReportInodes") == 0)
        {
                if (IS_TRUE (value))
 -                      report_inodes = true;
 +                      report_inodes = 1;
                else
 -                      report_inodes = false;
 +                      report_inodes = 0;
  
                return (0);
        }
        return (-1);
  }
  
 -static void df_submit_two (char *df_name,
 -              const char *type,
 -              gauge_t df_used,
 -              gauge_t df_free)
 -{
 -      value_t values[2];
 -      value_list_t vl = VALUE_LIST_INIT;
 -
 -      values[0].gauge = df_used;
 -      values[1].gauge = df_free;
 -
 -      vl.values = values;
 -      vl.values_len = 2;
 -      sstrncpy (vl.host, hostname_g, sizeof (vl.host));
 -      sstrncpy (vl.plugin, "df", sizeof (vl.plugin));
 -      sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance));
 -      sstrncpy (vl.type, type, sizeof (vl.type));
 -      sstrncpy (vl.type_instance, df_name, sizeof (vl.type_instance));
 -
 -      plugin_dispatch_values (&vl);
 -} /* void df_submit_two */
 -
  __attribute__ ((nonnull(2)))
  static void df_submit_one (char *plugin_instance,
                const char *type, const char *type_instance,
@@@ -181,9 -215,6 +183,9 @@@ static int df_read (void
        {
                unsigned long long blocksize;
                char disk_name[256];
 +              uint64_t blk_free;
 +              uint64_t blk_reserved;
 +              uint64_t blk_used;
  
                if (ignorelist_match (il_device,
                                        (mnt_ptr->spec_device != NULL)
                if (STATANYFS (mnt_ptr->dir, &statbuf) < 0)
                {
                        char errbuf[1024];
-                       ERROR ("statv?fs failed: %s",
+                       ERROR (STATANYFS_STR"(%s) failed: %s",
+                                       mnt_ptr->dir,
                                        sstrerror (errno, errbuf,
                                                sizeof (errbuf)));
                        continue;
  
                blocksize = BLOCKSIZE(statbuf);
  
 -              if (report_reserved)
 -              {
 -                      uint64_t blk_free;
 -                      uint64_t blk_reserved;
 -                      uint64_t blk_used;
 -
 -                      /* Sanity-check for the values in the struct */
 -                      if (statbuf.f_bfree < statbuf.f_bavail)
 -                              statbuf.f_bfree = statbuf.f_bavail;
 -                      if (statbuf.f_blocks < statbuf.f_bfree)
 -                              statbuf.f_blocks = statbuf.f_bfree;
 -
 -                      blk_free = (uint64_t) statbuf.f_bavail;
 -                      blk_reserved = (uint64_t) (statbuf.f_bfree - statbuf.f_bavail);
 -                      blk_used = (uint64_t) (statbuf.f_blocks - statbuf.f_bfree);
 -                      
 -                      df_submit_one (disk_name, "df_complex", "free",
 -                                      (gauge_t) (blk_free * blocksize));
 -                      df_submit_one (disk_name, "df_complex", "reserved",
 -                                      (gauge_t) (blk_reserved * blocksize));
 -                      df_submit_one (disk_name, "df_complex", "used",
 -                                      (gauge_t) (blk_used * blocksize));
 -              }
 -              else /* compatibility code */
 -              {
 -                      gauge_t df_free;
 -                      gauge_t df_used;
 -
 -                      df_free = statbuf.f_bfree * blocksize;
 -                      df_used = (statbuf.f_blocks - statbuf.f_bfree) * blocksize;
 -
 -                      df_submit_two (disk_name, "df", df_used, df_free);
 -              }
 +              /* Sanity-check for the values in the struct */
 +              if (statbuf.f_bfree < statbuf.f_bavail)
 +                      statbuf.f_bfree = statbuf.f_bavail;
 +              if (statbuf.f_blocks < statbuf.f_bfree)
 +                      statbuf.f_blocks = statbuf.f_bfree;
 +
 +              blk_free     = (uint64_t) statbuf.f_bavail;
 +              blk_reserved = (uint64_t) (statbuf.f_bfree - statbuf.f_bavail);
 +              blk_used     = (uint64_t) (statbuf.f_blocks - statbuf.f_bfree);
 +
 +              df_submit_one (disk_name, "df_complex", "free",
 +                              (gauge_t) (blk_free * blocksize));
 +              df_submit_one (disk_name, "df_complex", "reserved",
 +                              (gauge_t) (blk_reserved * blocksize));
 +              df_submit_one (disk_name, "df_complex", "used",
 +                              (gauge_t) (blk_used * blocksize));
  
                /* inode handling */
                if (report_inodes)
diff --combined src/disk.c
@@@ -1,6 -1,6 +1,6 @@@
  /**
   * collectd - src/disk.c
 - * Copyright (C) 2005-2008  Florian octo Forster
 + * Copyright (C) 2005-2010  Florian octo Forster
   * Copyright (C) 2009       Manuel Sanmartin
   *
   * This program is free software; you can redistribute it and/or modify it
@@@ -85,19 -85,19 +85,19 @@@ typedef struct diskstat
        /* This overflows in roughly 1361 years */
        unsigned int poll_count;
  
 -      counter_t read_sectors;
 -      counter_t write_sectors;
 +      derive_t read_sectors;
 +      derive_t write_sectors;
  
 -      counter_t read_bytes;
 -      counter_t write_bytes;
 +      derive_t read_bytes;
 +      derive_t write_bytes;
  
 -      counter_t read_ops;
 -      counter_t write_ops;
 -      counter_t read_time;
 -      counter_t write_time;
 +      derive_t read_ops;
 +      derive_t write_ops;
 +      derive_t read_time;
 +      derive_t write_time;
  
 -      counter_t avg_read_time;
 -      counter_t avg_write_time;
 +      derive_t avg_read_time;
 +      derive_t avg_write_time;
  
        struct diskstats *next;
  } diskstats_t;
@@@ -212,7 -212,7 +212,7 @@@ static int disk_init (void
  
  static void disk_submit (const char *plugin_instance,
                const char *type,
 -              counter_t read, counter_t write)
 +              derive_t read, derive_t write)
  {
        value_t values[2];
        value_list_t vl = VALUE_LIST_INIT;
        if (ignorelist_match (ignorelist, plugin_instance) != 0)
          return;
  
 -      values[0].counter = read;
 -      values[1].counter = write;
 +      values[0].derive = read;
 +      values[1].derive = write;
  
        vl.values = values;
        vl.values_len = 2;
@@@ -426,18 -426,17 +426,17 @@@ static int disk_read (void
        int numfields;
        int fieldshift = 0;
  
-       int major = 0;
        int minor = 0;
  
 -      counter_t read_sectors  = 0;
 -      counter_t write_sectors = 0;
 +      derive_t read_sectors  = 0;
 +      derive_t write_sectors = 0;
  
 -      counter_t read_ops      = 0;
 -      counter_t read_merged   = 0;
 -      counter_t read_time     = 0;
 -      counter_t write_ops     = 0;
 -      counter_t write_merged  = 0;
 -      counter_t write_time    = 0;
 +      derive_t read_ops      = 0;
 +      derive_t read_merged   = 0;
 +      derive_t read_time     = 0;
 +      derive_t write_ops     = 0;
 +      derive_t write_merged  = 0;
 +      derive_t write_time    = 0;
        int is_disk = 0;
  
        diskstats_t *ds, *pre_ds;
                if ((numfields != (14 + fieldshift)) && (numfields != 7))
                        continue;
  
-               major = atoll (fields[0]);
                minor = atoll (fields[1]);
  
                disk_name = fields[2 + fieldshift];
                }
  
                {
 -                      counter_t diff_read_sectors;
 -                      counter_t diff_write_sectors;
 +                      derive_t diff_read_sectors;
 +                      derive_t diff_write_sectors;
  
                /* If the counter wraps around, it's only 32 bits.. */
                        if (read_sectors < ds->read_sectors)
                /* Calculate the average time an io-op needs to complete */
                if (is_disk)
                {
 -                      counter_t diff_read_ops;
 -                      counter_t diff_write_ops;
 -                      counter_t diff_read_time;
 -                      counter_t diff_write_time;
 +                      derive_t diff_read_ops;
 +                      derive_t diff_write_ops;
 +                      derive_t diff_read_time;
 +                      derive_t diff_write_time;
  
                        if (read_ops < ds->read_ops)
                                diff_read_ops = 1 + read_ops
                                        + (UINT_MAX - ds->read_ops);
                        else
                                diff_read_ops = read_ops - ds->read_ops;
 -                      DEBUG ("disk plugin: disk_name = %s; read_ops = %llu; "
 -                                      "ds->read_ops = %llu; diff_read_ops = %llu;",
 +                      DEBUG ("disk plugin: disk_name = %s; read_ops = %"PRIi64"; "
 +                                      "ds->read_ops = %"PRIi64"; diff_read_ops = %"PRIi64";",
                                        disk_name,
                                        read_ops, ds->read_ops, diff_read_ops);
  
  /* #endif defined(HAVE_LIBSTATGRAB) */
  
  #elif defined(HAVE_PERFSTAT)
 -      counter_t read_sectors;
 -      counter_t write_sectors;
 -      counter_t read_time;
 -      counter_t write_time;
 -      counter_t read_ops;
 -      counter_t write_ops;
 +      derive_t read_sectors;
 +      derive_t write_sectors;
 +      derive_t read_time;
 +      derive_t write_time;
 +      derive_t read_ops;
 +      derive_t write_ops;
        perfstat_id_t firstpath;
        int rnumdisk;
        int i;
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:
@@@ -2256,7 -2255,6 +2256,6 @@@ static int cjni_config_plugin_block (oc
    cjni_callback_info_t *cbi;
    jobject o_ocitem;
    const char *name;
-   int status;
    size_t i;
  
    jclass class;
    method = (*jvm_env)->GetMethodID (jvm_env, class,
        "config", "(Lorg/collectd/api/OConfigItem;)I");
  
-   status = (*jvm_env)->CallIntMethod (jvm_env,
+   (*jvm_env)->CallIntMethod (jvm_env,
        cbi->object, method, o_ocitem);
  
    (*jvm_env)->DeleteLocalRef (jvm_env, o_ocitem);
@@@ -2554,12 -2552,11 +2553,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)
@@@ -3080,9 -3066,8 +3079,8 @@@ static int cjni_init (void) /* {{{ *
  
    if (config_block != NULL)
    {
-     int status;
  
-     status = cjni_config_perform (config_block);
+     cjni_config_perform (config_block);
      oconfig_free (config_block);
      config_block = NULL;
    }
diff --combined src/libvirt.c
@@@ -43,7 -43,6 +43,7 @@@ static const char *config_keys[] = 
      "IgnoreSelected",
  
      "HostnameFormat",
 +    "InterfaceFormat",
  
      NULL
  };
@@@ -90,14 -89,13 +90,14 @@@ static int add_block_device (virDomainP
  struct interface_device {
      virDomainPtr dom;           /* domain */
      char *path;                 /* name of interface device */
 +    char *address;              /* mac address of interface device */
  };
  
  static struct interface_device *interface_devices = NULL;
  static int nr_interface_devices = 0;
  
  static void free_interface_devices (void);
 -static int add_interface_device (virDomainPtr dom, const char *path);
 +static int add_interface_device (virDomainPtr dom, const char *path, const char *address);
  
  /* HostnameFormat. */
  #define HF_MAX_FIELDS 3
@@@ -112,19 -110,22 +112,19 @@@ enum hf_field 
  static enum hf_field hostname_format[HF_MAX_FIELDS] =
      { hf_name };
  
 +/* InterfaceFormat. */
 +enum if_field {
 +    if_address,
 +    if_name
 +};
 +
 +static enum if_field interface_format = if_name;
 +
  /* Time that we last refreshed. */
  static time_t last_refresh = (time_t) 0;
  
  static int refresh_lists (void);
  
 -/* Submit functions. */
 -static void cpu_submit (unsigned long long cpu_time,
 -                        time_t t,
 -                        virDomainPtr dom, const char *type);
 -static void vcpu_submit (unsigned long long cpu_time,
 -                         time_t t,
 -                         virDomainPtr dom, int vcpu_nr, const char *type);
 -static void submit_counter2 (const char *type, counter_t v0, counter_t v1,
 -             time_t t,
 -             virDomainPtr dom, const char *devname);
 -
  /* ERROR(...) macro for virterrors. */
  #define VIRT_ERROR(conn,s) do {                 \
          virErrorPtr err;                        \
          if (err) ERROR ("%s: %s", (s), err->message);                   \
      } while(0)
  
-     char  *host_ptr;
-     size_t host_len;
 +static void
 +init_value_list (value_list_t *vl, virDomainPtr dom)
 +{
 +    int i, n;
 +    const char *name;
 +    char uuid[VIR_UUID_STRING_BUFLEN];
-     host_ptr = vl->host;
-     host_len = sizeof (vl->host);
 +
 +    vl->interval = interval_g;
 +
 +    sstrncpy (vl->plugin, "libvirt", sizeof (vl->plugin));
 +
 +    vl->host[0] = '\0';
 +
 +    /* Construct the hostname field according to HostnameFormat. */
 +    for (i = 0; i < HF_MAX_FIELDS; ++i) {
 +        if (hostname_format[i] == hf_none)
 +            continue;
 +
 +        n = DATA_MAX_NAME_LEN - strlen (vl->host) - 2;
 +
 +        if (i > 0 && n >= 1) {
 +            strncat (vl->host, ":", 1);
 +            n--;
 +        }
 +
 +        switch (hostname_format[i]) {
 +        case hf_none: break;
 +        case hf_hostname:
 +            strncat (vl->host, hostname_g, n);
 +            break;
 +        case hf_name:
 +            name = virDomainGetName (dom);
 +            if (name)
 +                strncat (vl->host, name, n);
 +            break;
 +        case hf_uuid:
 +            if (virDomainGetUUIDString (dom, uuid) == 0)
 +                strncat (vl->host, uuid, n);
 +            break;
 +        }
 +    }
 +
 +    vl->host[sizeof (vl->host) - 1] = '\0';
 +} /* void init_value_list */
 +
 +static void
 +cpu_submit (unsigned long long cpu_time,
 +            virDomainPtr dom, const char *type)
 +{
 +    value_t values[1];
 +    value_list_t vl = VALUE_LIST_INIT;
 +
 +    init_value_list (&vl, dom);
 +
 +    values[0].derive = cpu_time;
 +
 +    vl.values = values;
 +    vl.values_len = 1;
 +
 +    sstrncpy (vl.type, type, sizeof (vl.type));
 +
 +    plugin_dispatch_values (&vl);
 +}
 +
 +static void
 +vcpu_submit (derive_t cpu_time,
 +             virDomainPtr dom, int vcpu_nr, const char *type)
 +{
 +    value_t values[1];
 +    value_list_t vl = VALUE_LIST_INIT;
 +
 +    init_value_list (&vl, dom);
 +
 +    values[0].derive = cpu_time;
 +    vl.values = values;
 +    vl.values_len = 1;
 +
 +    sstrncpy (vl.type, type, sizeof (vl.type));
 +    ssnprintf (vl.type_instance, sizeof (vl.type_instance), "%d", vcpu_nr);
 +
 +    plugin_dispatch_values (&vl);
 +}
 +
 +static void
 +submit_derive2 (const char *type, derive_t v0, derive_t v1,
 +             virDomainPtr dom, const char *devname)
 +{
 +    value_t values[2];
 +    value_list_t vl = VALUE_LIST_INIT;
 +
 +    init_value_list (&vl, dom);
 +
 +    values[0].derive = v0;
 +    values[1].derive = v1;
 +    vl.values = values;
 +    vl.values_len = 2;
 +
 +    sstrncpy (vl.type, type, sizeof (vl.type));
 +    sstrncpy (vl.type_instance, devname, sizeof (vl.type_instance));
 +
 +    plugin_dispatch_values (&vl);
 +} /* void submit_derive2 */
 +
  static int
  lv_init (void)
  {
@@@ -321,7 -215,7 +317,7 @@@ lv_config (const char *key, const char 
  
          n = strsplit (value_copy, fields, HF_MAX_FIELDS);
          if (n < 1) {
 -            free (value_copy);
 +            sfree (value_copy);
              ERROR ("HostnameFormat: no fields");
              return -1;
          }
              else if (strcasecmp (fields[i], "uuid") == 0)
                  hostname_format[i] = hf_uuid;
              else {
 -                free (value_copy);
 +                sfree (value_copy);
                  ERROR ("unknown HostnameFormat field: %s", fields[i]);
                  return -1;
              }
          }
 -        free (value_copy);
 +        sfree (value_copy);
  
          for (i = n; i < HF_MAX_FIELDS; ++i)
              hostname_format[i] = hf_none;
          return 0;
      }
  
 +    if (strcasecmp (key, "InterfaceFormat") == 0) {
 +        if (strcasecmp (value, "name") == 0)
 +            interface_format = if_name;
 +        else if (strcasecmp (value, "address") == 0)
 +            interface_format = if_address;
 +        else {
 +            ERROR ("unknown InterfaceFormat: %s", value);
 +            return -1;
 +        }
 +        return 0;
 +    }
 +
      /* Unrecognised option. */
      return -1;
  }
@@@ -424,7 -306,7 +420,7 @@@ lv_read (void
              continue;
          }
  
 -        cpu_submit (info.cpuTime, t, domains[i], "virt_cpu_total");
 +        cpu_submit (info.cpuTime, domains[i], "virt_cpu_total");
  
          vinfo = malloc (info.nrVirtCpu * sizeof (vinfo[0]));
          if (vinfo == NULL) {
  
          for (j = 0; j < info.nrVirtCpu; ++j)
              vcpu_submit (vinfo[j].cpuTime,
 -                    t, domains[i], vinfo[j].number, "virt_vcpu");
 +                    domains[i], vinfo[j].number, "virt_vcpu");
  
 -        free (vinfo);
 +        sfree (vinfo);
      }
  
      /* Get block device stats for each domain. */
              continue;
  
          if ((stats.rd_req != -1) && (stats.wr_req != -1))
 -            submit_counter2 ("disk_ops",
 -                    (counter_t) stats.rd_req, (counter_t) stats.wr_req,
 -                    t, block_devices[i].dom, block_devices[i].path);
 +            submit_derive2 ("disk_ops",
 +                    (derive_t) stats.rd_req, (derive_t) stats.wr_req,
 +                    block_devices[i].dom, block_devices[i].path);
  
          if ((stats.rd_bytes != -1) && (stats.wr_bytes != -1))
 -            submit_counter2 ("disk_octets",
 -                    (counter_t) stats.rd_bytes, (counter_t) stats.wr_bytes,
 -                    t, block_devices[i].dom, block_devices[i].path);
 +            submit_derive2 ("disk_octets",
 +                    (derive_t) stats.rd_bytes, (derive_t) stats.wr_bytes,
 +                    block_devices[i].dom, block_devices[i].path);
      } /* for (nr_block_devices) */
  
      /* Get interface stats for each domain. */
      for (i = 0; i < nr_interface_devices; ++i) {
          struct _virDomainInterfaceStats stats;
 +        char *display_name = interface_devices[i].path;
 +
 +        if (interface_format == if_address)
 +            display_name = interface_devices[i].address;
  
          if (virDomainInterfaceStats (interface_devices[i].dom,
                      interface_devices[i].path,
              continue;
  
        if ((stats.rx_bytes != -1) && (stats.tx_bytes != -1))
 -          submit_counter2 ("if_octets",
 -                  (counter_t) stats.rx_bytes, (counter_t) stats.tx_bytes,
 -                  t, interface_devices[i].dom, interface_devices[i].path);
 +          submit_derive2 ("if_octets",
 +                  (derive_t) stats.rx_bytes, (derive_t) stats.tx_bytes,
 +                  interface_devices[i].dom, display_name);
  
        if ((stats.rx_packets != -1) && (stats.tx_packets != -1))
 -          submit_counter2 ("if_packets",
 -                  (counter_t) stats.rx_packets, (counter_t) stats.tx_packets,
 -                  t, interface_devices[i].dom, interface_devices[i].path);
 +          submit_derive2 ("if_packets",
 +                  (derive_t) stats.rx_packets, (derive_t) stats.tx_packets,
 +                  interface_devices[i].dom, display_name);
  
        if ((stats.rx_errs != -1) && (stats.tx_errs != -1))
 -          submit_counter2 ("if_errors",
 -                  (counter_t) stats.rx_errs, (counter_t) stats.tx_errs,
 -                  t, interface_devices[i].dom, interface_devices[i].path);
 +          submit_derive2 ("if_errors",
 +                  (derive_t) stats.rx_errs, (derive_t) stats.tx_errs,
 +                  interface_devices[i].dom, display_name);
  
        if ((stats.rx_drop != -1) && (stats.tx_drop != -1))
 -          submit_counter2 ("if_dropped",
 -                  (counter_t) stats.rx_drop, (counter_t) stats.tx_drop,
 -                  t, interface_devices[i].dom, interface_devices[i].path);
 +          submit_derive2 ("if_dropped",
 +                  (derive_t) stats.rx_drop, (derive_t) stats.tx_drop,
 +                  interface_devices[i].dom, display_name);
      } /* for (nr_interface_devices) */
  
      return 0;
@@@ -530,7 -408,7 +526,7 @@@ refresh_lists (void
          n = virConnectListDomains (conn, domids, n);
          if (n < 0) {
              VIRT_ERROR (conn, "reading list of domains");
 -            free (domids);
 +            sfree (domids);
              return -1;
          }
  
  
              /* Network interfaces. */
              xpath_obj = xmlXPathEval
 -                ((xmlChar *) "/domain/devices/interface/target[@dev]",
 +                ((xmlChar *) "/domain/devices/interface[target[@dev]]",
                   xpath_ctx);
              if (xpath_obj == NULL || xpath_obj->type != XPATH_NODESET ||
                  xpath_obj->nodesetval == NULL)
                  goto cont;
  
 -            for (j = 0; j < xpath_obj->nodesetval->nodeNr; ++j) {
 -                xmlNodePtr node;
 +            xmlNodeSetPtr xml_interfaces = xpath_obj->nodesetval;
 +
 +            for (j = 0; j < xml_interfaces->nodeNr; ++j) {
                  char *path = NULL;
 +                char *address = NULL;
 +                xmlNodePtr xml_interface;
  
 -                node = xpath_obj->nodesetval->nodeTab[j];
 -                if (!node) continue;
 -                path = (char *) xmlGetProp (node, (xmlChar *) "dev");
 -                if (!path) continue;
 +                xml_interface = xml_interfaces->nodeTab[j];
 +                if (!xml_interface) continue;
 +                xmlNodePtr child = NULL;
 +
 +                for (child = xml_interface->children; child; child = child->next) {
 +                    if (child->type != XML_ELEMENT_NODE) continue;
 +
 +                    if (xmlStrEqual(child->name, (const xmlChar *) "target")) {
 +                        path = (char *) xmlGetProp (child, (const xmlChar *) "dev");
 +                        if (!path) continue;
 +                    } else if (xmlStrEqual(child->name, (const xmlChar *) "mac")) {
 +                        address = (char *) xmlGetProp (child, (const xmlChar *) "address");
 +                        if (!address) continue;
 +                    }
 +                }
  
                  if (il_interface_devices &&
 -                    ignore_device_match (il_interface_devices, name, path) != 0)
 +                    (ignore_device_match (il_interface_devices, name, path) != 0 ||
 +                     ignore_device_match (il_interface_devices, name, address) != 0))
                      goto cont3;
  
 -                add_interface_device (dom, path);
 -            cont3:
 -                if (path) xmlFree (path);
 +                add_interface_device (dom, path, address);
 +                cont3:
 +                    if (path) xmlFree (path);
 +                    if (address) xmlFree (address);
              }
  
          cont:
              if (xpath_obj) xmlXPathFreeObject (xpath_obj);
              if (xpath_ctx) xmlXPathFreeContext (xpath_ctx);
              if (xml_doc) xmlFreeDoc (xml_doc);
 -            if (xml) free (xml);
 +            sfree (xml);
          }
  
 -        free (domids);
 +        sfree (domids);
      }
  
      return 0;
@@@ -675,7 -537,7 +671,7 @@@ free_domains (
      if (domains) {
          for (i = 0; i < nr_domains; ++i)
              virDomainFree (domains[i]);
 -        free (domains);
 +        sfree (domains);
      }
      domains = NULL;
      nr_domains = 0;
@@@ -707,8 -569,8 +703,8 @@@ free_block_devices (
  
      if (block_devices) {
          for (i = 0; i < nr_block_devices; ++i)
 -            free (block_devices[i].path);
 -        free (block_devices);
 +            sfree (block_devices[i].path);
 +        sfree (block_devices);
      }
      block_devices = NULL;
      nr_block_devices = 0;
@@@ -731,7 -593,7 +727,7 @@@ add_block_device (virDomainPtr dom, con
          new_ptr = malloc (new_size);
  
      if (new_ptr == NULL) {
 -        free (path_copy);
 +        sfree (path_copy);
          return -1;
      }
      block_devices = new_ptr;
@@@ -746,43 -608,36 +742,43 @@@ free_interface_devices (
      int i;
  
      if (interface_devices) {
 -        for (i = 0; i < nr_interface_devices; ++i)
 -            free (interface_devices[i].path);
 -        free (interface_devices);
 +        for (i = 0; i < nr_interface_devices; ++i) {
 +            sfree (interface_devices[i].path);
 +            sfree (interface_devices[i].address);
 +        }
 +        sfree (interface_devices);
      }
      interface_devices = NULL;
      nr_interface_devices = 0;
  }
  
  static int
 -add_interface_device (virDomainPtr dom, const char *path)
 +add_interface_device (virDomainPtr dom, const char *path, const char *address)
  {
      struct interface_device *new_ptr;
      int new_size = sizeof (interface_devices[0]) * (nr_interface_devices+1);
 -    char *path_copy;
 +    char *path_copy, *address_copy;
  
      path_copy = strdup (path);
      if (!path_copy) return -1;
  
 +    address_copy = strdup (address);
 +    if (!address_copy) return -1;
 +
      if (interface_devices)
          new_ptr = realloc (interface_devices, new_size);
      else
          new_ptr = malloc (new_size);
  
      if (new_ptr == NULL) {
 -        free (path_copy);
 +        sfree (path_copy);
 +        sfree (address_copy);
          return -1;
      }
      interface_devices = new_ptr;
      interface_devices[nr_interface_devices].dom = dom;
      interface_devices[nr_interface_devices].path = path_copy;
 +    interface_devices[nr_interface_devices].address = address_copy;
      return nr_interface_devices++;
  }
  
@@@ -800,10 -655,117 +796,10 @@@ ignore_device_match (ignorelist_t *il, 
      }
      ssnprintf (name, n, "%s:%s", domname, devpath);
      r = ignorelist_match (il, name);
 -    free (name);
 +    sfree (name);
      return r;
  }
  
 -static void
 -init_value_list (value_list_t *vl, time_t t, virDomainPtr dom)
 -{
 -    int i, n;
 -    const char *name;
 -    char uuid[VIR_UUID_STRING_BUFLEN];
 -
 -    vl->time = t;
 -    vl->interval = interval_g;
 -
 -    sstrncpy (vl->plugin, "libvirt", sizeof (vl->plugin));
 -
 -    vl->host[0] = '\0';
 -
 -    /* Construct the hostname field according to HostnameFormat. */
 -    for (i = 0; i < HF_MAX_FIELDS; ++i) {
 -        if (hostname_format[i] == hf_none)
 -            continue;
 -
 -        n = DATA_MAX_NAME_LEN - strlen (vl->host) - 2;
 -
 -        if (i > 0 && n >= 1) {
 -            strncat (vl->host, ":", 1);
 -            n--;
 -        }
 -
 -        switch (hostname_format[i]) {
 -        case hf_none: break;
 -        case hf_hostname:
 -            strncat (vl->host, hostname_g, n);
 -            break;
 -        case hf_name:
 -            name = virDomainGetName (dom);
 -            if (name)
 -                strncat (vl->host, name, n);
 -            break;
 -        case hf_uuid:
 -            if (virDomainGetUUIDString (dom, uuid) == 0)
 -                strncat (vl->host, uuid, n);
 -            break;
 -        }
 -    }
 -
 -    vl->host[sizeof (vl->host) - 1] = '\0';
 -} /* void init_value_list */
 -
 -static void
 -cpu_submit (unsigned long long cpu_time,
 -            time_t t,
 -            virDomainPtr dom, const char *type)
 -{
 -    value_t values[1];
 -    value_list_t vl = VALUE_LIST_INIT;
 -
 -    init_value_list (&vl, t, dom);
 -
 -    values[0].counter = cpu_time;
 -
 -    vl.values = values;
 -    vl.values_len = 1;
 -
 -    sstrncpy (vl.type, type, sizeof (vl.type));
 -
 -    plugin_dispatch_values (&vl);
 -}
 -
 -static void
 -vcpu_submit (counter_t cpu_time,
 -             time_t t,
 -             virDomainPtr dom, int vcpu_nr, const char *type)
 -{
 -    value_t values[1];
 -    value_list_t vl = VALUE_LIST_INIT;
 -
 -    init_value_list (&vl, t, dom);
 -
 -    values[0].counter = cpu_time;
 -    vl.values = values;
 -    vl.values_len = 1;
 -
 -    sstrncpy (vl.type, type, sizeof (vl.type));
 -    ssnprintf (vl.type_instance, sizeof (vl.type_instance), "%d", vcpu_nr);
 -
 -    plugin_dispatch_values (&vl);
 -}
 -
 -static void
 -submit_counter2 (const char *type, counter_t v0, counter_t v1,
 -             time_t t,
 -             virDomainPtr dom, const char *devname)
 -{
 -    value_t values[2];
 -    value_list_t vl = VALUE_LIST_INIT;
 -
 -    init_value_list (&vl, t, dom);
 -
 -    values[0].counter = v0;
 -    values[1].counter = v1;
 -    vl.values = values;
 -    vl.values_len = 2;
 -
 -    sstrncpy (vl.type, type, sizeof (vl.type));
 -    sstrncpy (vl.type_instance, devname, sizeof (vl.type_instance));
 -
 -    plugin_dispatch_values (&vl);
 -} /* void submit_counter2 */
 -
  static int
  lv_shutdown (void)
  {
diff --combined src/mysql.c
@@@ -1,6 -1,6 +1,6 @@@
  /**
   * collectd - src/mysql.c
 - * Copyright (C) 2006-2009  Florian octo Forster
 + * Copyright (C) 2006-2010  Florian octo Forster
   * Copyright (C) 2008       Mirko Buffoni
   * Copyright (C) 2009       Doug MacEachern
   * Copyright (C) 2009       Sebastian tokkee Harl
@@@ -20,7 -20,7 +20,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>
   *   Doug MacEachern <dougm at hyperic.com>
   *   Sebastian tokkee Harl <sh at tokkee.org>
@@@ -42,6 -42,7 +42,6 @@@
  
  struct mysql_database_s /* {{{ */
  {
 -      /* instance == NULL  =>  legacy mode */
        char *instance;
        char *host;
        char *user;
        char *socket;
        int   port;
  
 -      int   master_stats;
 -      int   slave_stats;
 +      _Bool master_stats;
 +      _Bool slave_stats;
  
 -      int   slave_notif;
 -      int   slave_io_running;
 -      int   slave_sql_running;
 +      _Bool slave_notif;
 +      _Bool slave_io_running;
 +      _Bool slave_sql_running;
  
        MYSQL *con;
        int    state;
@@@ -97,9 -98,88 +97,9 @@@ static void mysql_database_free (void *
   *   </Database>
   * </Plugin>
   */
 -
 -static int mysql_config_set_string (char **ret_string, /* {{{ */
 -                                  oconfig_item_t *ci)
 -{
 -      char *string;
 -
 -      if ((ci->values_num != 1)
 -          || (ci->values[0].type != OCONFIG_TYPE_STRING))
 -      {
 -              WARNING ("mysql plugin: The `%s' config option "
 -                       "needs exactly one string argument.", ci->key);
 -              return (-1);
 -      }
 -
 -      string = strdup (ci->values[0].value.string);
 -      if (string == NULL)
 -      {
 -              ERROR ("mysql plugin: strdup failed.");
 -              return (-1);
 -      }
 -
 -      if (*ret_string != NULL)
 -              free (*ret_string);
 -      *ret_string = string;
 -
 -      return (0);
 -} /* }}} int mysql_config_set_string */
 -
 -static int mysql_config_set_int (int *ret_int, /* {{{ */
 -                               oconfig_item_t *ci)
 -{
 -      if ((ci->values_num != 1)
 -          || (ci->values[0].type != OCONFIG_TYPE_NUMBER))
 -      {
 -              WARNING ("mysql plugin: The `%s' config option "
 -                       "needs exactly one string argument.", ci->key);
 -              return (-1);
 -      }
 -
 -      *ret_int = ci->values[0].value.number;
 -
 -      return (0);
 -} /* }}} int mysql_config_set_int */
 -
 -static int mysql_config_set_boolean (int *ret_boolean, /* {{{ */
 -                              oconfig_item_t *ci)
 -{
 -      int status = 0;
 -
 -      if (ci->values_num != 1)
 -              status = -1;
 -
 -      if (status == 0)
 -      {
 -              if (ci->values[0].type == OCONFIG_TYPE_BOOLEAN)
 -                      *ret_boolean = ci->values[0].value.boolean;
 -              else if (ci->values[0].type == OCONFIG_TYPE_STRING)
 -              {
 -                      if (IS_TRUE (ci->values[0].value.string))
 -                              *ret_boolean = 1;
 -                      else if (IS_FALSE (ci->values[0].value.string))
 -                              *ret_boolean = 0;
 -                      else
 -                              status = -1;
 -              }
 -              else
 -                      status = -1;
 -      }
 -
 -      if (status != 0)
 -      {
 -              WARNING ("mysql plugin: The `%s' config option "
 -                      "needs exactly one boolean argument.", ci->key);
 -              return (-1);
 -      }
 -      return (0);
 -} /* }}} mysql_config_set_boolean */
 -
 -static int mysql_config (oconfig_item_t *ci) /* {{{ */
 +static int mysql_config_database (oconfig_item_t *ci) /* {{{ */
  {
        mysql_database_t *db;
 -      int plugin_block;
        int status = 0;
        int i;
  
        db->slave_io_running  = 1;
        db->slave_sql_running = 1;
  
 -      plugin_block = 1;
 -      if (strcasecmp ("Plugin", ci->key) == 0)
 -      {
 -              db->instance = NULL;
 -      }
 -      else if (strcasecmp ("Database", ci->key) == 0)
 -      {
 -              plugin_block = 0;
 -              status = mysql_config_set_string (&db->instance, ci);
 -              if (status != 0)
 -              {
 -                      sfree (db);
 -                      return (status);
 -              }
 -              assert (db->instance != NULL);
 -      }
 -      else
 +      status = cf_util_get_string (ci, &db->instance);
 +      if (status != 0)
        {
 -              ERROR ("mysql plugin: mysql_config: "
 -                              "Invalid key: %s", ci->key);
 -              return (-1);
 +              sfree (db);
 +              return (status);
        }
 +      assert (db->instance != NULL);
  
        /* Fill the `mysql_database_t' structure.. */
        for (i = 0; i < ci->children_num; i++)
                oconfig_item_t *child = ci->children + i;
  
                if (strcasecmp ("Host", child->key) == 0)
 -                      status = mysql_config_set_string (&db->host, child);
 +                      status = cf_util_get_string (child, &db->host);
                else if (strcasecmp ("User", child->key) == 0)
 -                      status = mysql_config_set_string (&db->user, child);
 +                      status = cf_util_get_string (child, &db->user);
                else if (strcasecmp ("Password", child->key) == 0)
 -                      status = mysql_config_set_string (&db->pass, child);
 +                      status = cf_util_get_string (child, &db->pass);
                else if (strcasecmp ("Port", child->key) == 0)
 -                      status = mysql_config_set_int (&db->port, child);
 -              else if (strcasecmp ("Socket", child->key) == 0)
 -                      status = mysql_config_set_string (&db->socket, child);
 -              /* Check if we're currently handling the `Plugin' block. If so,
 -               * handle `Database' _blocks_, too. */
 -              else if ((plugin_block != 0)
 -                              && (strcasecmp ("Database", child->key) == 0)
 -                              && (child->children != NULL))
                {
 -                      /* If `plugin_block > 1', there has been at least one
 -                       * `Database' block */
 -                      plugin_block++;
 -                      status = mysql_config (child);
 +                      status = cf_util_get_port_number (child);
 +                      if (status > 0)
 +                      {
 +                              db->port = status;
 +                              status = 0;
 +                      }
                }
 -              /* Now handle ordinary `Database' options (without children) */
 -              else if ((strcasecmp ("Database", child->key) == 0)
 -                              && (child->children == NULL))
 -                      status = mysql_config_set_string (&db->database, child);
 +              else if (strcasecmp ("Socket", child->key) == 0)
 +                      status = cf_util_get_string (child, &db->socket);
 +              else if (strcasecmp ("Database", child->key) == 0)
 +                      status = cf_util_get_string (child, &db->database);
                else if (strcasecmp ("MasterStats", child->key) == 0)
 -                      status = mysql_config_set_boolean (&db->master_stats, child);
 +                      status = cf_util_get_boolean (child, &db->master_stats);
                else if (strcasecmp ("SlaveStats", child->key) == 0)
 -                      status = mysql_config_set_boolean (&db->slave_stats, child);
 +                      status = cf_util_get_boolean (child, &db->slave_stats);
                else if (strcasecmp ("SlaveNotifications", child->key) == 0)
 -                      status = mysql_config_set_boolean (&db->slave_notif, child);
 +                      status = cf_util_get_boolean (child, &db->slave_notif);
                else
                {
                        WARNING ("mysql plugin: Option `%s' not allowed here.", child->key);
                        break;
        }
  
 -      /* Check if there were any `Database' blocks. */
 -      if (plugin_block > 1)
 -      {
 -              /* There were connection blocks. Don't use any legacy stuff. */
 -              if ((db->host != NULL)
 -                      || (db->user != NULL)
 -                      || (db->pass != NULL)
 -                      || (db->database != NULL)
 -                      || (db->socket != NULL)
 -                      || (db->port != 0))
 -              {
 -                      WARNING ("mysql plugin: At least one <Database> "
 -                                      "block has been found. The legacy "
 -                                      "configuration will be ignored.");
 -              }
 -              mysql_database_free (db);
 -              return (0);
 -      }
 -      else if (plugin_block != 0)
 -      {
 -              WARNING ("mysql plugin: You're using the legacy "
 -                              "configuration options. Please consider "
 -                              "updating your configuration!");
 -      }
 -
 -      /* Check that all necessary options have been given. */
 -      while (status == 0)
 -      {
 -              /* Zero is allowed and automatically handled by
 -               * `mysql_real_connect'. */
 -              if ((db->port < 0) || (db->port > 65535))
 -              {
 -                      ERROR ("mysql plugin: Database %s: Port number out "
 -                                      "of range: %i",
 -                                      (db->instance != NULL)
 -                                      ? db->instance
 -                                      : "<legacy>",
 -                                      db->port);
 -                      status = -1;
 -              }
 -              break;
 -      } /* while (status == 0) */
 -
        /* If all went well, register this database for reading */
        if (status == 0)
        {
        }
  
        return (0);
 +} /* }}} int mysql_config_database */
 +
 +static int mysql_config (oconfig_item_t *ci) /* {{{ */
 +{
 +      int i;
 +
 +      if (ci == NULL)
 +              return (EINVAL);
 +
 +      /* Fill the `mysql_database_t' structure.. */
 +      for (i = 0; i < ci->children_num; i++)
 +      {
 +              oconfig_item_t *child = ci->children + i;
 +
 +              if (strcasecmp ("Database", child->key) == 0)
 +                      mysql_config_database (child);
 +              else
 +                      WARNING ("mysql plugin: Option \"%s\" not allowed here.",
 +                                      child->key);
 +      }
 +
 +      return (0);
  } /* }}} int mysql_config */
  
  /* }}} End of configuration handling functions */
@@@ -242,10 -364,10 +242,10 @@@ static MYSQL *getconnection (mysql_data
                int err;
                if ((err = mysql_ping (db->con)) != 0)
                {
 -                      WARNING ("mysql_ping failed for %s: %s",
 -                                      (db->instance != NULL)
 -                                      ? db->instance
 -                                      : "<legacy>",
 +                      /* Assured by "mysql_config_database" */
 +                      assert (db->instance != NULL);
 +                      WARNING ("mysql_ping failed for instance \"%s\": %s",
 +                                      db->instance,
                                        mysql_error (db->con));
                        db->state = 0;
                }
  
  static void set_host (mysql_database_t *db, char *buf, size_t buflen)
  {
 -      /* XXX legacy mode - use hostname_g */
 -      if (db->instance == NULL)
 +      if ((db->host == NULL)
 +                      || (strcmp ("", db->host) == 0)
 +                      || (strcmp ("localhost", db->host) == 0))
                sstrncpy (buf, hostname_g, buflen);
        else
 -      {
 -              if ((db->host == NULL)
 -                              || (strcmp ("", db->host) == 0)
 -                              || (strcmp ("localhost", db->host) == 0))
 -                      sstrncpy (buf, hostname_g, buflen);
 -              else
 -                      sstrncpy (buf, db->host, buflen);
 -      }
 -}
 -
 -static void set_plugin_instance (mysql_database_t *db,
 -              char *buf, size_t buflen)
 -{
 -      /* XXX legacy mode - no plugin_instance */
 -      if (db->instance == NULL)
 -              sstrncpy (buf, "", buflen);
 -      else
 -              sstrncpy (buf, db->instance, buflen);
 -}
 +              sstrncpy (buf, db->host, buflen);
 +} /* void set_host */
  
  static void submit (const char *type, const char *type_instance,
                value_t *values, size_t values_len, mysql_database_t *db)
        set_host (db, vl.host, sizeof (vl.host));
  
        sstrncpy (vl.plugin, "mysql", sizeof (vl.plugin));
 -      set_plugin_instance (db, vl.plugin_instance, sizeof (vl.plugin_instance));
 +
 +      /* Assured by "mysql_config_database" */
 +      assert (db->instance != NULL);
 +      sstrncpy (vl.plugin_instance, db->instance, sizeof (vl.plugin_instance));
  
        sstrncpy (vl.type, type, sizeof (vl.type));
        if (type_instance != NULL)
  } /* submit */
  
  static void counter_submit (const char *type, const char *type_instance,
 -              counter_t value, mysql_database_t *db)
 +              derive_t value, mysql_database_t *db)
  {
        value_t values[1];
  
 -      values[0].counter = value;
 +      values[0].derive = value;
        submit (type, type_instance, values, STATIC_ARRAY_SIZE (values), db);
  } /* void counter_submit */
  
@@@ -338,21 -473,40 +338,21 @@@ static void gauge_submit (const char *t
        submit (type, type_instance, values, STATIC_ARRAY_SIZE (values), db);
  } /* void gauge_submit */
  
 -static void qcache_submit (counter_t hits, counter_t inserts,
 -              counter_t not_cached, counter_t lowmem_prunes,
 -              gauge_t queries_in_cache, mysql_database_t *db)
 +static void derive_submit (const char *type, const char *type_instance,
 +              derive_t value, mysql_database_t *db)
  {
 -      value_t values[5];
 -
 -      values[0].counter = hits;
 -      values[1].counter = inserts;
 -      values[2].counter = not_cached;
 -      values[3].counter = lowmem_prunes;
 -      values[4].gauge   = queries_in_cache;
 -
 -      submit ("mysql_qcache", NULL, values, STATIC_ARRAY_SIZE (values), db);
 -} /* void qcache_submit */
 -
 -static void threads_submit (gauge_t running, gauge_t connected, gauge_t cached,
 -              counter_t created, mysql_database_t *db)
 -{
 -      value_t values[4];
 -
 -      values[0].gauge   = running;
 -      values[1].gauge   = connected;
 -      values[2].gauge   = cached;
 -      values[3].counter = created;
 +      value_t values[1];
  
 -      submit ("mysql_threads", NULL, values, STATIC_ARRAY_SIZE (values), db);
 -} /* void threads_submit */
 +      values[0].derive = value;
 +      submit (type, type_instance, values, STATIC_ARRAY_SIZE (values), db);
 +} /* void derive_submit */
  
 -static void traffic_submit (counter_t rx, counter_t tx, mysql_database_t *db)
 +static void traffic_submit (derive_t rx, derive_t tx, mysql_database_t *db)
  {
        value_t values[2];
  
 -      values[0].counter = rx;
 -      values[1].counter = tx;
 +      values[0].derive = rx;
 +      values[1].derive = tx;
  
        submit ("mysql_octets", NULL, values, STATIC_ARRAY_SIZE (values), db);
  } /* void traffic_submit */
@@@ -485,7 -639,7 +485,7 @@@ static int mysql_read_slave_stats (mysq
  
        if (db->slave_notif)
        {
 -              notification_t n = { 0, time (NULL), "", "",
 +              notification_t n = { 0, cdtime (), "", "",
                        "mysql", "", "time_offset", "", NULL };
  
                char *io, *sql;
                sql = row[SLAVE_SQL_RUNNING_IDX];
  
                set_host (db, n.host, sizeof (n.host));
 -              set_plugin_instance (db,
 -                              n.plugin_instance, sizeof (n.plugin_instance));
 +
 +              /* Assured by "mysql_config_database" */
 +              assert (db->instance != NULL);
 +              sstrncpy (n.plugin_instance, db->instance, sizeof (n.plugin_instance));
  
                if (((io == NULL) || (strcasecmp (io, "yes") != 0))
                                && (db->slave_io_running))
@@@ -555,18 -707,17 +555,17 @@@ static int mysql_read (user_data_t *ud
        MYSQL_RES *res;
        MYSQL_ROW  row;
        char      *query;
-       int        field_num;
  
 -      unsigned long long qcache_hits          = 0ULL;
 -      unsigned long long qcache_inserts       = 0ULL;
 -      unsigned long long qcache_not_cached    = 0ULL;
 -      unsigned long long qcache_lowmem_prunes = 0ULL;
 -      int qcache_queries_in_cache = -1;
 +      derive_t qcache_hits          = 0;
 +      derive_t qcache_inserts       = 0;
 +      derive_t qcache_not_cached    = 0;
 +      derive_t qcache_lowmem_prunes = 0;
 +      gauge_t qcache_queries_in_cache = NAN;
  
 -      int threads_running   = -1;
 -      int threads_connected = -1;
 -      int threads_cached    = -1;
 -      unsigned long long threads_created = 0ULL;
 +      gauge_t threads_running   = NAN;
 +      gauge_t threads_connected = NAN;
 +      gauge_t threads_cached    = NAN;
 +      derive_t threads_created = 0;
  
        unsigned long long traffic_incoming = 0ULL;
        unsigned long long traffic_outgoing = 0ULL;
        if (res == NULL)
                return (-1);
  
-       field_num = mysql_num_fields (res);
        while ((row = mysql_fetch_row (res)))
        {
                char *key;
                                                strlen ("Qcache_")) == 0)
                {
                        if (strcmp (key, "Qcache_hits") == 0)
 -                              qcache_hits = val;
 +                              qcache_hits = (derive_t) val;
                        else if (strcmp (key, "Qcache_inserts") == 0)
 -                              qcache_inserts = val;
 +                              qcache_inserts = (derive_t) val;
                        else if (strcmp (key, "Qcache_not_cached") == 0)
 -                              qcache_not_cached = val;
 +                              qcache_not_cached = (derive_t) val;
                        else if (strcmp (key, "Qcache_lowmem_prunes") == 0)
 -                              qcache_lowmem_prunes = val;
 +                              qcache_lowmem_prunes = (derive_t) val;
                        else if (strcmp (key, "Qcache_queries_in_cache") == 0)
 -                              qcache_queries_in_cache = (int) val;
 +                              qcache_queries_in_cache = (gauge_t) val;
                }
                else if (strncmp (key, "Bytes_", 
                                        strlen ("Bytes_")) == 0)
                                                strlen ("Threads_")) == 0)
                {
                        if (strcmp (key, "Threads_running") == 0)
 -                              threads_running = (int) val;
 +                              threads_running = (gauge_t) val;
                        else if (strcmp (key, "Threads_connected") == 0)
 -                              threads_connected = (int) val;
 +                              threads_connected = (gauge_t) val;
                        else if (strcmp (key, "Threads_cached") == 0)
 -                              threads_cached = (int) val;
 +                              threads_cached = (gauge_t) val;
                        else if (strcmp (key, "Threads_created") == 0)
 -                              threads_created = val;
 +                              threads_created = (derive_t) val;
                }
                else if (strncmp (key, "Table_locks_",
                                        strlen ("Table_locks_")) == 0)
        }
        mysql_free_result (res); res = NULL;
  
 -      if ((qcache_hits != 0ULL)
 -                      || (qcache_inserts != 0ULL)
 -                      || (qcache_not_cached != 0ULL)
 -                      || (qcache_lowmem_prunes != 0ULL))
 -              qcache_submit (qcache_hits, qcache_inserts, qcache_not_cached,
 -                             qcache_lowmem_prunes, qcache_queries_in_cache, db);
 +      if ((qcache_hits != 0)
 +                      || (qcache_inserts != 0)
 +                      || (qcache_not_cached != 0)
 +                      || (qcache_lowmem_prunes != 0))
 +      {
 +              derive_submit ("cache_result", "qcache-hits",
 +                              qcache_hits, db);
 +              derive_submit ("cache_result", "qcache-inserts",
 +                              qcache_inserts, db);
 +              derive_submit ("cache_result", "qcache-not_cached",
 +                              qcache_not_cached, db);
 +              derive_submit ("cache_result", "qcache-prunes",
 +                              qcache_lowmem_prunes, db);
 +
 +              gauge_submit ("cache_size", "qcache",
 +                              qcache_queries_in_cache, db);
 +      }
  
 -      if (threads_created != 0ULL)
 -              threads_submit (threads_running, threads_connected,
 -                              threads_cached, threads_created, db);
 +      if (threads_created != 0)
 +      {
 +              gauge_submit ("threads", "running",
 +                              threads_running, db);
 +              gauge_submit ("threads", "connected",
 +                              threads_connected, db);
 +              gauge_submit ("threads", "cached",
 +                              threads_cached, db);
 +
 +              derive_submit ("total_threads", "created",
 +                              threads_created, db);
 +      }
  
        traffic_submit  (traffic_incoming, traffic_outgoing, db);
  
diff --combined src/network.c
@@@ -1,6 -1,6 +1,6 @@@
  /**
   * collectd - src/network.c
 - * Copyright (C) 2005-2009  Florian octo Forster
 + * Copyright (C) 2005-2010  Florian octo Forster
   * Copyright (C) 2009       Aman Gupta
   *
   * This program is free software; you can redistribute it and/or modify it
@@@ -259,7 -259,7 +259,7 @@@ typedef struct receive_list_entry_s rec
   * Private variables
   */
  static int network_config_ttl = 0;
 -static size_t network_config_packet_size = 1024;
 +static size_t network_config_packet_size = 1452;
  static int network_config_forward = 0;
  static int network_config_stats = 0;
  
@@@ -296,14 -296,14 +296,14 @@@ static pthread_mutex_t  send_buffer_loc
   * example). Only if neither is true, the stats_lock is acquired. The counters
   * are always read without holding a lock in the hope that writing 8 bytes to
   * memory is an atomic operation. */
 -static uint64_t stats_octets_rx  = 0;
 -static uint64_t stats_octets_tx  = 0;
 -static uint64_t stats_packets_rx = 0;
 -static uint64_t stats_packets_tx = 0;
 -static uint64_t stats_values_dispatched = 0;
 -static uint64_t stats_values_not_dispatched = 0;
 -static uint64_t stats_values_sent = 0;
 -static uint64_t stats_values_not_sent = 0;
 +static derive_t stats_octets_rx  = 0;
 +static derive_t stats_octets_tx  = 0;
 +static derive_t stats_packets_rx = 0;
 +static derive_t stats_packets_tx = 0;
 +static derive_t stats_values_dispatched = 0;
 +static derive_t stats_values_not_dispatched = 0;
 +static derive_t stats_values_sent = 0;
 +static derive_t stats_values_not_sent = 0;
  static pthread_mutex_t stats_lock = PTHREAD_MUTEX_INITIALIZER;
  
  /*
@@@ -320,30 -320,30 +320,30 @@@ static _Bool check_receive_okay (const 
    /* This is a value we already sent. Don't allow it to be received again in
     * order to avoid looping. */
    if ((status == 0) && (time_sent >= ((uint64_t) vl->time)))
 -    return (false);
 +    return (0);
  
 -  return (true);
 +  return (1);
  } /* }}} _Bool check_receive_okay */
  
  static _Bool check_send_okay (const value_list_t *vl) /* {{{ */
  {
 -  _Bool received = false;
 +  _Bool received = 0;
    int status;
  
    if (network_config_forward != 0)
 -    return (true);
 +    return (1);
  
    if (vl->meta == NULL)
 -    return (true);
 +    return (1);
  
    status = meta_data_get_boolean (vl->meta, "network:received", &received);
    if (status == -ENOENT)
 -    return (true);
 +    return (1);
    else if (status != 0)
    {
      ERROR ("network plugin: check_send_okay: meta_data_get_boolean failed "
        "with status %i.", status);
 -    return (true);
 +    return (1);
    }
  
    /* By default, only *send* value lists that were not *received* by the
@@@ -384,7 -384,7 +384,7 @@@ static int network_dispatch_values (val
      return (-ENOMEM);
    }
  
 -  status = meta_data_add_boolean (vl->meta, "network:received", true);
 +  status = meta_data_add_boolean (vl->meta, "network:received", 1);
    if (status != 0)
    {
      ERROR ("network plugin: meta_data_add_boolean failed.");
@@@ -788,7 -788,6 +788,6 @@@ static int parse_part_number (void **re
        size_t exp_size = 2 * sizeof (uint16_t) + sizeof (uint64_t);
  
        uint16_t pkg_length;
-       uint16_t pkg_type;
  
        if ((buffer_len < 0) || ((size_t) buffer_len < exp_size))
        {
  
        memcpy ((void *) &tmp16, buffer, sizeof (tmp16));
        buffer += sizeof (tmp16);
-       pkg_type = ntohs (tmp16);
+       /* pkg_type = ntohs (tmp16); */
  
        memcpy ((void *) &tmp16, buffer, sizeof (tmp16));
        buffer += sizeof (tmp16);
@@@ -828,7 -827,6 +827,6 @@@ static int parse_part_string (void **re
        size_t header_size = 2 * sizeof (uint16_t);
  
        uint16_t pkg_length;
-       uint16_t pkg_type;
  
        if ((buffer_len < 0) || (buffer_len < header_size))
        {
  
        memcpy ((void *) &tmp16, buffer, sizeof (tmp16));
        buffer += sizeof (tmp16);
-       pkg_type = ntohs (tmp16);
+       /* pkg_type = ntohs (tmp16); */
  
        memcpy ((void *) &tmp16, buffer, sizeof (tmp16));
        buffer += sizeof (tmp16);
@@@ -1381,19 -1379,8 +1379,19 @@@ static int parse_packet (sockent_t *se
                                        &tmp);
                        if (status == 0)
                        {
 -                              vl.time = (time_t) tmp;
 -                              n.time = (time_t) tmp;
 +                              vl.time = TIME_T_TO_CDTIME_T (tmp);
 +                              n.time  = TIME_T_TO_CDTIME_T (tmp);
 +                      }
 +              }
 +              else if (pkg_type == TYPE_TIME_HR)
 +              {
 +                      uint64_t tmp = 0;
 +                      status = parse_part_number (&buffer, &buffer_size,
 +                                      &tmp);
 +                      if (status == 0)
 +                      {
 +                              vl.time = (cdtime_t) tmp;
 +                              n.time  = (cdtime_t) tmp;
                        }
                }
                else if (pkg_type == TYPE_INTERVAL)
                        status = parse_part_number (&buffer, &buffer_size,
                                        &tmp);
                        if (status == 0)
 -                              vl.interval = (int) tmp;
 +                              vl.interval = TIME_T_TO_CDTIME_T (tmp);
 +              }
 +              else if (pkg_type == TYPE_INTERVAL_HR)
 +              {
 +                      uint64_t tmp = 0;
 +                      status = parse_part_number (&buffer, &buffer_size,
 +                                      &tmp);
 +                      if (status == 0)
 +                              vl.interval = (cdtime_t) tmp;
                }
                else if (pkg_type == TYPE_HOST)
                {
@@@ -2606,7 -2585,7 +2604,7 @@@ static int add_to_buffer (char *buffer
  
        if (vl_def->time != vl->time)
        {
 -              if (write_part_number (&buffer, &buffer_size, TYPE_TIME,
 +              if (write_part_number (&buffer, &buffer_size, TYPE_TIME_HR,
                                        (uint64_t) vl->time))
                        return (-1);
                vl_def->time = vl->time;
  
        if (vl_def->interval != vl->interval)
        {
 -              if (write_part_number (&buffer, &buffer_size, TYPE_INTERVAL,
 +              if (write_part_number (&buffer, &buffer_size, TYPE_INTERVAL_HR,
                                        (uint64_t) vl->interval))
                        return (-1);
                vl_def->interval = vl->interval;
@@@ -3076,6 -3055,8 +3074,6 @@@ static int network_config (oconfig_item
        network_config_set_boolean (child, &network_config_forward);
      else if (strcasecmp ("ReportStats", child->key) == 0)
        network_config_set_boolean (child, &network_config_stats);
 -    else if (strcasecmp ("CacheFlush", child->key) == 0)
 -      /* no op for backwards compatibility only */;
      else
      {
        WARNING ("network plugin: Option `%s' is not allowed here.",
@@@ -3096,7 -3077,8 +3094,7 @@@ static int network_notification (const 
  
    memset (buffer, '\0', sizeof (buffer));
  
 -
 -  status = write_part_number (&buffer_ptr, &buffer_free, TYPE_TIME,
 +  status = write_part_number (&buffer_ptr, &buffer_free, TYPE_TIME_HR,
        (uint64_t) n->time);
    if (status != 0)
      return (-1);
@@@ -3201,15 -3183,15 +3199,15 @@@ static int network_shutdown (void
  
  static int network_stats_read (void) /* {{{ */
  {
 -      uint64_t copy_octets_rx;
 -      uint64_t copy_octets_tx;
 -      uint64_t copy_packets_rx;
 -      uint64_t copy_packets_tx;
 -      uint64_t copy_values_dispatched;
 -      uint64_t copy_values_not_dispatched;
 -      uint64_t copy_values_sent;
 -      uint64_t copy_values_not_sent;
 -      uint64_t copy_receive_list_length;
 +      derive_t copy_octets_rx;
 +      derive_t copy_octets_tx;
 +      derive_t copy_packets_rx;
 +      derive_t copy_packets_tx;
 +      derive_t copy_values_dispatched;
 +      derive_t copy_values_not_dispatched;
 +      derive_t copy_values_sent;
 +      derive_t copy_values_not_sent;
 +      derive_t copy_receive_list_length;
        value_list_t vl = VALUE_LIST_INIT;
        value_t values[2];
  
        sstrncpy (vl.plugin, "network", sizeof (vl.plugin));
  
        /* Octets received / sent */
 -      vl.values[0].counter = (counter_t) copy_octets_rx;
 -      vl.values[1].counter = (counter_t) copy_octets_tx;
 +      vl.values[0].derive = (derive_t) copy_octets_rx;
 +      vl.values[1].derive = (derive_t) copy_octets_tx;
        sstrncpy (vl.type, "if_octets", sizeof (vl.type));
        plugin_dispatch_values (&vl);
  
        /* Packets received / send */
 -      vl.values[0].counter = (counter_t) copy_packets_rx;
 -      vl.values[1].counter = (counter_t) copy_packets_tx;
 +      vl.values[0].derive = (derive_t) copy_packets_rx;
 +      vl.values[1].derive = (derive_t) copy_packets_tx;
        sstrncpy (vl.type, "if_packets", sizeof (vl.type));
        plugin_dispatch_values (&vl);
  
  
  static int network_init (void)
  {
 -      static _Bool have_init = false;
 +      static _Bool have_init = 0;
  
        /* Check if we were already initialized. If so, just return - there's
         * nothing more to do (for now, that is). */
        if (have_init)
                return (0);
 -      have_init = true;
 +      have_init = 1;
  
  #if HAVE_LIBGCRYPT
        gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
   * just send the buffer if `flush'  is called - if the requested value was in
   * there, good. If not, well, then there is nothing to flush.. -octo
   */
 -static int network_flush (int timeout,
 -              const char __attribute__((unused)) *identifier,
 -              user_data_t __attribute__((unused)) *user_data)
 +static int network_flush (__attribute__((unused)) cdtime_t timeout,
 +              __attribute__((unused)) const char *identifier,
 +              __attribute__((unused)) user_data_t *user_data)
  {
        pthread_mutex_lock (&send_buffer_lock);
  
diff --combined src/nginx.c
@@@ -1,6 -1,6 +1,6 @@@
  /**
   * collectd - src/nginx.c
 - * Copyright (C) 2006,2007  Florian octo Forster
 + * Copyright (C) 2006-2010  Florian octo Forster
   * Copyright (C) 2008       Sebastian Harl
   *
   * This program is free software; you can redistribute it and/or modify it
@@@ -18,7 -18,7 +18,7 @@@
   * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
   *
   * Authors:
 - *   Florian octo Forster <octo at verplant.org>
 + *   Florian octo Forster <octo at collectd.org>
   *   Sebastian Harl <sh at tokkee.org>
   **/
  
@@@ -38,9 -38,10 +38,9 @@@ static char *cacert      = NULL
  
  static CURL *curl = NULL;
  
 -#define ABUFFER_SIZE 16384
 -static char nginx_buffer[ABUFFER_SIZE];
 -static int  nginx_buffer_len = 0;
 -static char nginx_curl_error[CURL_ERROR_SIZE];
 +static char   nginx_buffer[16384];
 +static size_t nginx_buffer_len = 0;
 +static char   nginx_curl_error[CURL_ERROR_SIZE];
  
  static const char *config_keys[] =
  {
@@@ -58,19 -59,17 +58,19 @@@ static size_t nginx_curl_callback (voi
  {
    size_t len = size * nmemb;
  
 -  if ((nginx_buffer_len + len) >= ABUFFER_SIZE)
 +  /* Check if the data fits into the memory. If not, truncate it. */
 +  if ((nginx_buffer_len + len) >= sizeof (nginx_buffer))
    {
 -    len = (ABUFFER_SIZE - 1) - nginx_buffer_len;
 +    assert (sizeof (nginx_buffer) > nginx_buffer_len);
 +    len = (sizeof (nginx_buffer) - 1) - nginx_buffer_len;
    }
  
    if (len <= 0)
      return (len);
  
 -  memcpy (nginx_buffer + nginx_buffer_len, (char *) buf, len);
 +  memcpy (&nginx_buffer[nginx_buffer_len], buf, len);
    nginx_buffer_len += len;
 -  nginx_buffer[nginx_buffer_len] = '\0';
 +  nginx_buffer[nginx_buffer_len] = 0;
  
    return (len);
  }
@@@ -120,6 -119,7 +120,7 @@@ static int init (void
      return (-1);
    }
  
+   curl_easy_setopt (curl, CURLOPT_NOSIGNAL, 1);
    curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, nginx_curl_callback);
    curl_easy_setopt (curl, CURLOPT_USERAGENT, PACKAGE_NAME"/"PACKAGE_VERSION);
    curl_easy_setopt (curl, CURLOPT_ERRORBUFFER, nginx_curl_error);
@@@ -178,7 -178,7 +179,7 @@@ static void submit (char *type, char *i
    if (strcmp (type, "nginx_connections") == 0)
      values[0].gauge = value;
    else if (strcmp (type, "nginx_requests") == 0)
 -    values[0].counter = value;
 +    values[0].derive = value;
    else
      return;
  
diff --combined src/notify_email.c
@@@ -228,9 -228,7 +228,8 @@@ static int notify_email_config (const c
  static int notify_email_notification (const notification_t *n,
      user_data_t __attribute__((unused)) *user_data)
  {
-   smtp_recipient_t recipient;
  
 +  time_t tt;
    struct tm timestamp_tm;
    char timestamp_str[64];
  
        (email_subject == NULL) ? DEFAULT_SMTP_SUBJECT : email_subject,
        severity, n->host);
  
 -  localtime_r (&n->time, &timestamp_tm);
 +  tt = CDTIME_T_TO_TIME_T (n->time);
 +  localtime_r (&tt, &timestamp_tm);
    strftime (timestamp_str, sizeof (timestamp_str), "%Y-%m-%d %H:%M:%S",
        &timestamp_tm);
    timestamp_str[sizeof (timestamp_str) - 1] = '\0';
    smtp_set_message_str (message, buf);
  
    for (i = 0; i < recipients_len; i++)
-     recipient = smtp_add_recipient (message, recipients[i]);
+     smtp_add_recipient (message, recipients[i]);
  
    /* Initiate a connection to the SMTP server and transfer the message. */
    if (!smtp_start_session (session)) {
      pthread_mutex_unlock (&session_lock);
      return (-1);
    } else {
+     #if COLLECT_DEBUG
      const smtp_status_t *status;
      /* Report on the success or otherwise of the mail transfer. */
      status = smtp_message_transfer_status (message);
      DEBUG ("notify_email plugin: SMTP server report: %d %s",
-         status->code, (status->text != NULL) ? status->text : "\n");
+       status->code, (status->text != NULL) ? status->text : "\n");
+     #endif
      smtp_enumerate_recipients (message, print_recipient_status, NULL);
    }
  
diff --combined src/processes.c
@@@ -1,7 -1,7 +1,7 @@@
  /**
   * collectd - src/processes.c
   * Copyright (C) 2005       Lyonel Vincent
 - * Copyright (C) 2006-2008  Florian octo Forster
 + * Copyright (C) 2006-2010  Florian octo Forster
   * Copyright (C) 2008       Oleg King
   * Copyright (C) 2009       Sebastian Harl
   * Copyright (C) 2009       Andrés J. Díaz
@@@ -143,13 -143,13 +143,13 @@@ typedef struct procstat_entry_
  
        unsigned long vmem_minflt;
        unsigned long vmem_majflt;
 -      unsigned long vmem_minflt_counter;
 -      unsigned long vmem_majflt_counter;
 +      derive_t      vmem_minflt_counter;
 +      derive_t      vmem_majflt_counter;
  
        unsigned long cpu_user;
        unsigned long cpu_system;
 -      unsigned long cpu_user_counter;
 -      unsigned long cpu_system_counter;
 +      derive_t      cpu_user_counter;
 +      derive_t      cpu_system_counter;
  
        /* io data */
        derive_t io_rchar;
@@@ -176,11 -176,11 +176,11 @@@ typedef struct procsta
        unsigned long vmem_code;
        unsigned long stack_size;
  
 -      unsigned long vmem_minflt_counter;
 -      unsigned long vmem_majflt_counter;
 +      derive_t vmem_minflt_counter;
 +      derive_t vmem_majflt_counter;
  
 -      unsigned long cpu_user_counter;
 -      unsigned long cpu_system_counter;
 +      derive_t cpu_user_counter;
 +      derive_t cpu_system_counter;
  
        /* io data */
        derive_t io_rchar;
@@@ -664,8 -664,8 +664,8 @@@ static void ps_submit_proc_list (procst
        plugin_dispatch_values (&vl);
  
        sstrncpy (vl.type, "ps_cputime", sizeof (vl.type));
 -      vl.values[0].counter = ps->cpu_user_counter;
 -      vl.values[1].counter = ps->cpu_system_counter;
 +      vl.values[0].derive = ps->cpu_user_counter;
 +      vl.values[1].derive = ps->cpu_system_counter;
        vl.values_len = 2;
        plugin_dispatch_values (&vl);
  
        plugin_dispatch_values (&vl);
  
        sstrncpy (vl.type, "ps_pagefaults", sizeof (vl.type));
 -      vl.values[0].counter = ps->vmem_minflt_counter;
 -      vl.values[1].counter = ps->vmem_majflt_counter;
 +      vl.values[0].derive = ps->vmem_minflt_counter;
 +      vl.values[1].derive = ps->vmem_majflt_counter;
        vl.values_len = 2;
        plugin_dispatch_values (&vl);
  
        DEBUG ("name = %s; num_proc = %lu; num_lwp = %lu; "
                          "vmem_size = %lu; vmem_rss = %lu; vmem_data = %lu; "
                        "vmem_code = %lu; "
 -                      "vmem_minflt_counter = %lu; vmem_majflt_counter = %lu; "
 -                      "cpu_user_counter = %lu; cpu_system_counter = %lu; "
 +                      "vmem_minflt_counter = %"PRIi64"; vmem_majflt_counter = %"PRIi64"; "
 +                      "cpu_user_counter = %"PRIi64"; cpu_system_counter = %"PRIi64"; "
                        "io_rchar = %"PRIi64"; io_wchar = %"PRIi64"; "
                        "io_syscr = %"PRIi64"; io_syscw = %"PRIi64";",
                        ps->name, ps->num_proc, ps->num_lwp,
@@@ -871,11 -871,10 +871,10 @@@ int ps_read_process (int pid, procstat_
  
        int   i;
  
-       int   ppid;
        int   name_len;
  
 -      long long unsigned cpu_user_counter;
 -      long long unsigned cpu_system_counter;
 +      derive_t cpu_user_counter;
 +      derive_t cpu_system_counter;
        long long unsigned vmem_size;
        long long unsigned vmem_rss;
        long long unsigned stack_size;
        fields[1][name_len] = '\0';
        strncpy (ps->name, fields[1], PROCSTAT_NAME_LEN);
  
-       ppid = atoi (fields[3]);
  
        *state = fields[2][0];
  
        cpu_system_counter = atoll (fields[14]);
        vmem_size          = atoll (fields[22]);
        vmem_rss           = atoll (fields[23]);
 -      ps->vmem_minflt_counter = atol (fields[9]);
 -      ps->vmem_majflt_counter = atol (fields[11]);
 +      ps->vmem_minflt_counter = atoll (fields[9]);
 +      ps->vmem_majflt_counter = atoll (fields[11]);
  
        {
                unsigned long long stack_start = atoll (fields[27]);
                DEBUG("ps_read_process: did not get vmem data for pid %i",pid);
        }
  
 -      ps->cpu_user_counter = (unsigned long) cpu_user_counter;
 -      ps->cpu_system_counter = (unsigned long) cpu_system_counter;
 +      ps->cpu_user_counter = cpu_user_counter;
 +      ps->cpu_system_counter = cpu_system_counter;
        ps->vmem_size = (unsigned long) vmem_size;
        ps->vmem_rss = (unsigned long) vmem_rss;
        ps->stack_size = (unsigned long) stack_size;
diff --combined src/teamspeak2.c
@@@ -25,8 -25,8 +25,8 @@@
  #include "common.h"
  #include "plugin.h"
  
 -#include <arpa/inet.h>
  #include <netinet/in.h>
 +#include <arpa/inet.h>
  #include <sys/types.h>
  #include <sys/socket.h>
  #include <netdb.h>
@@@ -146,7 -146,7 +146,7 @@@ static void tss2_submit_gauge (const ch
  } /* void tss2_submit_gauge */
  
  static void tss2_submit_io (const char *plugin_instance, const char *type,
 -              counter_t rx, counter_t tx)
 +              derive_t rx, derive_t tx)
  {
        /*
         * Submits the io rx/tx tuple to the collectd daemon
        value_t values[2];
        value_list_t vl = VALUE_LIST_INIT;
  
 -      values[0].counter = rx;
 -      values[1].counter = tx;
 +      values[0].derive = rx;
 +      values[1].derive = tx;
  
        vl.values     = values;
        vl.values_len = 2;
@@@ -299,6 -299,13 +299,13 @@@ static int tss2_get_socket (FILE **ret_
                char *buffer_ptr;
  
                buffer_ptr = fgets (buffer, sizeof (buffer), global_read_fh);
+               if (buffer_ptr == NULL)
+               {
+                       WARNING ("teamspeak2 plugin: Unexpected EOF received "
+                                       "from remote host %s:%s.",
+                                       config_host ? config_host : DEFAULT_HOST,
+                                       config_port ? config_port : DEFAULT_PORT);
+               }
                buffer[sizeof (buffer) - 1] = 0;
  
                if (memcmp ("[TS]\r\n", buffer, 6) != 0)
@@@ -498,10 -505,10 +505,10 @@@ static int tss2_read_vserver (vserver_l
        gauge_t users = NAN;
        gauge_t channels = NAN;
        gauge_t servers = NAN;
 -      counter_t rx_octets = 0;
 -      counter_t tx_octets = 0;
 -      counter_t rx_packets = 0;
 -      counter_t tx_packets = 0;
 +      derive_t rx_octets = 0;
 +      derive_t tx_octets = 0;
 +      derive_t rx_packets = 0;
 +      derive_t tx_packets = 0;
        gauge_t packet_loss = NAN;
        int valid = 0;
  
diff --combined src/utils_dns.c
@@@ -291,18 -291,13 +291,18 @@@ rfc1035NameUnpack(const char *buf, size
      off_t no = 0;
      unsigned char c;
      size_t len;
 -    assert(ns > 0);
 +    static int loop_detect = 0;
 +    if (loop_detect > 2)
 +      return 4;               /* compression loop */
 +    if (ns <= 0)
 +      return 4;               /* probably compression loop */
      do {
        if ((*off) >= sz)
            break;
        c = *(buf + (*off));
        if (c > 191) {
            /* blasted compression */
 +          int rc;
            unsigned short s;
            off_t ptr;
            memcpy(&s, buf + (*off), sizeof(s));
            (*off) += sizeof(s);
            /* Sanity check */
            if ((*off) >= sz)
 -              return 1;
 +              return 1;       /* message too short */
            ptr = s & 0x3FFF;
            /* Make sure the pointer is inside this message */
            if (ptr >= sz)
 -              return 2;
 -          return rfc1035NameUnpack(buf, sz, &ptr, name + no, ns - no);
 +              return 2;       /* bad compression ptr */
 +          if (ptr < DNS_MSG_HDR_SZ)
 +              return 2;       /* bad compression ptr */
 +          loop_detect++;
 +          rc = rfc1035NameUnpack(buf, sz, &ptr, name + no, ns - no);
 +          loop_detect--;
 +          return rc;
        } else if (c > RFC1035_MAXLABELSZ) {
            /*
             * "(The 10 and 01 combinations are reserved for future use.)"
             */
 +          return 3;           /* reserved label/compression flags */
            break;
 -          return 3;
        } else {
            (*off)++;
            len = (size_t) c;
                break;
            if (len > (ns - 1))
                len = ns - 1;
 -          if ((*off) + len > sz)      /* message is too short */
 -              return 4;
 +          if ((*off) + len > sz)
 +              return 4;       /* message is too short */
 +          if (no + len + 1 > ns)
 +              return 5;       /* qname would overflow name buffer */
            memcpy(name + no, buf + (*off), len);
            (*off) += len;
            no += len;
            *(name + (no++)) = '.';
        }
      } while (c > 0);
 -    *(name + no - 1) = '\0';
 +    if (no > 0)
 +      *(name + no - 1) = '\0';
      /* make sure we didn't allow someone to overflow the name buffer */
      assert(no <= ns);
      return 0;
@@@ -358,10 -345,10 +358,10 @@@ handle_dns(const char *buf, int len
      uint16_t us;
      off_t offset;
      char *t;
 -    int x;
 +    int status;
  
      /* The DNS header is 12 bytes long */
 -    if (len < 12)
 +    if (len < DNS_MSG_HDR_SZ)
        return 0;
  
      memcpy(&us, buf + 0, 2);
      memcpy(&us, buf + 10, 2);
      qh.arcount = ntohs(us);
  
 -    offset = 12;
 +    offset = DNS_MSG_HDR_SZ;
      memset(qh.qname, '\0', MAX_QNAME_SZ);
 -    x = rfc1035NameUnpack(buf, len, &offset, qh.qname, MAX_QNAME_SZ);
 -    if (0 != x)
 +    status = rfc1035NameUnpack(buf, len, &offset, qh.qname, MAX_QNAME_SZ);
 +    if (status != 0)
 +    {
 +      INFO ("utils_dns: handle_dns: rfc1035NameUnpack failed "
 +              "with status %i.", status);
        return 0;
 +    }
      if ('\0' == qh.qname[0])
        sstrncpy (qh.qname, ".", sizeof (qh.qname));
      while ((t = strchr(qh.qname, '\n')))
@@@ -441,7 -424,6 +441,7 @@@ handle_udp(const struct udphdr *udp, in
      return 1;
  }
  
 +#if HAVE_NETINET_IP6_H
  static int
  handle_ipv6 (struct ip6_hdr *ipv6, int len)
  {
      int nexthdr;
  
      struct in6_addr s_addr;
-     struct in6_addr d_addr;
      uint16_t payload_len;
  
      if (0 > len)
      offset = sizeof (struct ip6_hdr);
      nexthdr = ipv6->ip6_nxt;
      s_addr = ipv6->ip6_src;
-     d_addr = ipv6->ip6_dst;
      payload_len = ntohs (ipv6->ip6_plen);
  
      if (ignore_list_match (&s_addr))
  
      return (1); /* Success */
  } /* int handle_ipv6 */
 +/* #endif HAVE_NETINET_IP6_H */
 +
 +#else /* if !HAVE_NETINET_IP6_H */
 +static int
 +handle_ipv6 (__attribute__((unused)) void *pkg,
 +      __attribute__((unused)) int len)
 +{
 +    return (0);
 +}
 +#endif /* !HAVE_NETINET_IP6_H */
  
  static int
  handle_ip(const struct ip *ip, int len)
      struct in6_addr d_addr;
  
      if (ip->ip_v == 6)
 -      return (handle_ipv6 ((struct ip6_hdr *) ip, len));
 +      return (handle_ipv6 ((void *) ip, len));
  
      in6_addr_from_buffer (&s_addr, &ip->ip_src.s_addr, sizeof (ip->ip_src.s_addr), AF_INET);
      in6_addr_from_buffer (&d_addr, &ip->ip_dst.s_addr, sizeof (ip->ip_dst.s_addr), AF_INET);
@@@ -631,7 -601,7 +629,7 @@@ handle_ether(const u_char * pkt, int le
        return 0;
      memcpy(buf, pkt, len);
      if (ETHERTYPE_IPV6 == etype)
 -      return (handle_ipv6 ((struct ip6_hdr *) buf, len));
 +      return (handle_ipv6 ((void *) buf, len));
      else
        return handle_ip((struct ip *) buf, len);
  }
@@@ -664,7 -634,7 +662,7 @@@ handle_linux_sll (const u_char *pkt, in
        return 0;
  
      if (ETHERTYPE_IPV6 == etype)
 -      return (handle_ipv6 ((struct ip6_hdr *) pkt, len));
 +      return (handle_ipv6 ((void *) pkt, len));
      else
        return handle_ip((struct ip *) pkt, len);
  }
@@@ -675,6 -645,10 +673,6 @@@ void handle_pcap(u_char *udata, const s
  {
      int status;
  
 -    DEBUG ("handle_pcap (udata = %p, hdr = %p, pkt = %p): hdr->caplen = %i\n",
 -                  (void *) udata, (void *) hdr, (void *) pkt,
 -                  hdr->caplen);
 -
      if (hdr->caplen < ETHER_HDR_LEN)
        return;
  
            break;
  
        default:
 -          ERROR ("handle_pcap: unsupported data link type %d\n",
 +          ERROR ("handle_pcap: unsupported data link type %d",
                    pcap_datalink(pcap_obj));
            status = 0;
            break;
diff --combined src/write_http.c
@@@ -61,7 -61,7 +61,7 @@@ struct wh_callback_
          char   send_buffer[4096];
          size_t send_buffer_free;
          size_t send_buffer_fill;
 -        time_t send_buffer_init_time;
 +        cdtime_t send_buffer_init_time;
  
          pthread_mutex_t send_lock;
  };
@@@ -72,7 -72,7 +72,7 @@@ static void wh_reset_buffer (wh_callbac
          memset (cb->send_buffer, 0, sizeof (cb->send_buffer));
          cb->send_buffer_free = sizeof (cb->send_buffer);
          cb->send_buffer_fill = 0;
 -        cb->send_buffer_init_time = time (NULL);
 +        cb->send_buffer_init_time = cdtime ();
  
          if (cb->format == WH_FORMAT_JSON)
          {
@@@ -111,6 -111,7 +111,7 @@@ static int wh_callback_init (wh_callbac
                  return (-1);
          }
  
+         curl_easy_setopt (cb->curl, CURLOPT_NOSIGNAL, 1);
          curl_easy_setopt (cb->curl, CURLOPT_USERAGENT, PACKAGE_NAME"/"PACKAGE_VERSION);
  
          headers = NULL;
          return (0);
  } /* }}} int wh_callback_init */
  
 -static int wh_flush_nolock (int timeout, wh_callback_t *cb) /* {{{ */
 +static int wh_flush_nolock (cdtime_t timeout, wh_callback_t *cb) /* {{{ */
  {
          int status;
  
 -        DEBUG ("write_http plugin: wh_flush_nolock: timeout = %i; "
 +        DEBUG ("write_http plugin: wh_flush_nolock: timeout = %.3f; "
                          "send_buffer_fill = %zu;",
 -                        timeout, cb->send_buffer_fill);
 +                        CDTIME_T_TO_DOUBLE (timeout),
 +                        cb->send_buffer_fill);
  
 +        /* timeout == 0  => flush unconditionally */
          if (timeout > 0)
          {
 -                time_t now;
 +                cdtime_t now;
  
 -                now = time (NULL);
 +                now = cdtime ();
                  if ((cb->send_buffer_init_time + timeout) > now)
                          return (0);
          }
          {
                  if (cb->send_buffer_fill <= 0)
                  {
 -                        cb->send_buffer_init_time = time (NULL);
 +                        cb->send_buffer_init_time = cdtime ();
                          return (0);
                  }
  
          {
                  if (cb->send_buffer_fill <= 2)
                  {
 -                        cb->send_buffer_init_time = time (NULL);
 +                        cb->send_buffer_init_time = cdtime ();
                          return (0);
                  }
  
          return (status);
  } /* }}} wh_flush_nolock */
  
 -static int wh_flush (int timeout, /* {{{ */
 +static int wh_flush (cdtime_t timeout, /* {{{ */
                  const char *identifier __attribute__((unused)),
                  user_data_t *user_data)
  {
@@@ -260,7 -259,7 +261,7 @@@ static void wh_callback_free (void *dat
  
          cb = data;
  
 -        wh_flush_nolock (/* timeout = */ -1, cb);
 +        wh_flush_nolock (/* timeout = */ 0, cb);
  
          curl_easy_cleanup (cb->curl);
          sfree (cb->location);
          sfree (cb);
  } /* }}} void wh_callback_free */
  
 -static int wh_value_list_to_string (char *buffer, /* {{{ */
 -                size_t buffer_size,
 -                const data_set_t *ds, const value_list_t *vl,
 -                wh_callback_t *cb)
 -{
 -        size_t offset = 0;
 -        int status;
 -        int i;
 -        gauge_t *rates = NULL;
 -
 -        assert (0 == strcmp (ds->type, vl->type));
 -
 -        memset (buffer, 0, buffer_size);
 -
 -#define BUFFER_ADD(...) do { \
 -        status = ssnprintf (buffer + offset, buffer_size - offset, \
 -                        __VA_ARGS__); \
 -        if (status < 1) \
 -        { \
 -                sfree (rates); \
 -                return (-1); \
 -        } \
 -        else if (((size_t) status) >= (buffer_size - offset)) \
 -        { \
 -                sfree (rates); \
 -                return (-1); \
 -        } \
 -        else \
 -                offset += ((size_t) status); \
 -} while (0)
 -
 -        BUFFER_ADD ("%lu", (unsigned long) vl->time);
 -
 -        for (i = 0; i < ds->ds_num; i++)
 -        {
 -                if (ds->ds[i].type == DS_TYPE_GAUGE)
 -                        BUFFER_ADD (":%f", vl->values[i].gauge);
 -                else if (cb->store_rates)
 -                {
 -                        if (rates == NULL)
 -                                rates = uc_get_rate (ds, vl);
 -                        if (rates == NULL)
 -                        {
 -                                WARNING ("write_http plugin: "
 -                                                "uc_get_rate failed.");
 -                                return (-1);
 -                        }
 -                        BUFFER_ADD (":%g", rates[i]);
 -                }
 -                else if (ds->ds[i].type == DS_TYPE_COUNTER)
 -                        BUFFER_ADD (":%llu", vl->values[i].counter);
 -                else if (ds->ds[i].type == DS_TYPE_DERIVE)
 -                        BUFFER_ADD (":%"PRIi64, vl->values[i].derive);
 -                else if (ds->ds[i].type == DS_TYPE_ABSOLUTE)
 -                        BUFFER_ADD (":%"PRIu64, vl->values[i].absolute);
 -                else
 -                {
 -                        ERROR ("write_http plugin: Unknown data source type: %i",
 -                                        ds->ds[i].type);
 -                        sfree (rates);
 -                        return (-1);
 -                }
 -        } /* for ds->ds_num */
 -
 -#undef BUFFER_ADD
 -
 -        sfree (rates);
 -        return (0);
 -} /* }}} int wh_value_list_to_string */
 -
  static int wh_write_command (const data_set_t *ds, const value_list_t *vl, /* {{{ */
                  wh_callback_t *cb)
  {
  
          /* Convert the values to an ASCII representation and put that into
           * `values'. */
 -        status = wh_value_list_to_string (values, sizeof (values), ds, vl, cb);
 +        status = format_values (values, sizeof (values), ds, vl, cb->store_rates);
          if (status != 0) {
                  ERROR ("write_http plugin: error with "
                                  "wh_value_list_to_string");
          }
  
          command_len = (size_t) ssnprintf (command, sizeof (command),
 -                        "PUTVAL %s interval=%i %s\r\n",
 -                        key, vl->interval, values);
 +                        "PUTVAL %s interval=%.3f %s\r\n",
 +                        key,
 +                        CDTIME_T_TO_DOUBLE (vl->interval),
 +                        values);
          if (command_len >= sizeof (command)) {
                  ERROR ("write_http plugin: Command buffer too small: "
                                  "Need %zu bytes.", command_len + 1);
  
          if (command_len >= cb->send_buffer_free)
          {
 -                status = wh_flush_nolock (/* timeout = */ -1, cb);
 +                status = wh_flush_nolock (/* timeout = */ 0, cb);
                  if (status != 0)
                  {
                          pthread_mutex_unlock (&cb->send_lock);
@@@ -383,7 -450,7 +384,7 @@@ static int wh_write_json (const data_se
                          ds, vl, cb->store_rates);
          if (status == (-ENOMEM))
          {
 -                status = wh_flush_nolock (/* timeout = */ -1, cb);
 +                status = wh_flush_nolock (/* timeout = */ 0, cb);
                  if (status != 0)
                  {
                          wh_reset_buffer (cb);