Merge branch 'collectd-4.10' into collectd-5.1
authorFlorian Forster <octo@collectd.org>
Sun, 7 Apr 2013 03:44:38 +0000 (05:44 +0200)
committerFlorian Forster <octo@collectd.org>
Sun, 7 Apr 2013 03:44:38 +0000 (05:44 +0200)
Conflicts:
configure.in
src/mysql.c
src/network.c
src/thermal.c

1  2 
configure.in
src/mysql.c
src/network.c
src/thermal.c

diff --combined configure.in
@@@ -1,5 -1,5 +1,5 @@@
  dnl Process this file with autoconf to produce a configure script.
 -AC_INIT(collectd, m4_esyscmd(./version-gen.sh))
 +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])
@@@ -24,7 -24,7 +24,7 @@@ m4_ifdef([LT_PACKAGE_VERSION]
        ]
  )
  
 -AM_INIT_AUTOMAKE(dist-bzip2)
 +AM_INIT_AUTOMAKE([tar-pax dist-bzip2])
  AC_LANG(C)
  
  AC_PREFIX_DEFAULT("/opt/collectd")
@@@ -91,7 -91,6 +91,7 @@@ f
  if test "x$ac_system" = "xSolaris"
  then
        AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1, [Define to enforce POSIX thread semantics under Solaris.])
 +      AC_DEFINE(_REENTRANT,               1, [Define to enable reentrancy interfaces.])
  fi
  if test "x$ac_system" = "xAIX"
  then
@@@ -110,13 -109,9 +110,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")
  
  # For hddtemp module
  AC_CHECK_HEADERS(linux/major.h libgen.h)
  
 +# For md module (Linux only)
 +if test "x$ac_system" = "xLinux"
 +then
 +      AC_CHECK_HEADERS(linux/raid/md_u.h,
 +                       [have_linux_raid_md_u_h="yes"],
 +                       [have_linux_raid_md_u_h="no"],
 +[
 +#include <sys/ioctl.h>
 +#include <linux/major.h>
 +#include <linux/types.h>
 +])
 +else
 +      have_linux_raid_md_u_h="no"
 +fi
 +
  # For the battery plugin
  AC_CHECK_HEADERS(IOKit/ps/IOPowerSources.h, [], [],
  [
@@@ -404,33 -384,6 +404,33 @@@ AC_CHECK_HEADERS(linux/netdevice.h, []
  #endif
  ])
  
 +# For ethstat module
 +AC_CHECK_HEADERS(linux/sockios.h,
 +    [have_linux_sockios_h="yes"],
 +    [have_linux_sockios_h="no"],
 +    [
 +#if HAVE_SYS_IOCTL_H
 +# include <sys/ioctl.h>
 +#endif
 +#if HAVE_NET_IF_H
 +# include <net/if.h>
 +#endif
 +    ])
 +AC_CHECK_HEADERS(linux/ethtool.h,
 +    [have_linux_ethtool_h="yes"],
 +    [have_linux_ethtool_h="no"],
 +    [
 +#if HAVE_SYS_IOCTL_H
 +# include <sys/ioctl.h>
 +#endif
 +#if HAVE_NET_IF_H
 +# include <net/if.h>
 +#endif
 +#if HAVE_LINUX_SOCKIOS_H
 +# include <linux/sockios.h>
 +#endif
 +    ])
 +
  # For ipvs module
  have_linux_ip_vs_h="no"
  have_net_ip_vs_h="no"
@@@ -533,8 -486,6 +533,8 @@@ AC_CHECK_HEADERS(netinet/if_ether.h, []
  #endif
  ])
  
 +AC_CHECK_HEADERS(netinet/ip_compat.h)
 +
  # For the multimeter plugin
  have_termios_h="no"
  AC_CHECK_HEADERS(termios.h, [have_termios_h="yes"])
@@@ -567,12 -518,12 +567,12 @@@ AC_CACHE_CHECK([for strtok_r]
    [c_cv_have_strtok_r_default],
    AC_LINK_IFELSE(
      [AC_LANG_PROGRAM(
 -    [[[
 +[[[
  #include <stdlib.h>
  #include <stdio.h>
  #include <string.h>
 -    ]]],
 -    [[[
 +]]],
 +[[[
        char buffer[] = "foo,bar,baz";
        char *token;
        char *dummy;
        saveptr = NULL;
        while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
        {
-       dummy = NULL;
+         dummy = NULL;
          printf ("token = %s;\n", token);
        }
 -    ]]])],
 +]]]
 +    )],
      [c_cv_have_strtok_r_default="yes"],
      [c_cv_have_strtok_r_default="no"]
    )
@@@ -600,12 -550,12 +600,12 @@@ the
      [c_cv_have_strtok_r_reentrant],
      AC_LINK_IFELSE(
        [AC_LANG_PROGRAM(
 -      [[[
 +[[[
  #include <stdlib.h>
  #include <stdio.h>
  #include <string.h>
 -      ]]],
 -      [[[
 +]]],
 +[[[
          char buffer[] = "foo,bar,baz";
          char *token;
          char *dummy;
          saveptr = NULL;
          while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
          {
-         dummy = NULL;
+           dummy = NULL;
            printf ("token = %s;\n", token);
          }
 -      ]]])],
 +]]]
 +      )],
        [c_cv_have_strtok_r_reentrant="yes"],
        [AC_MSG_FAILURE([strtok_r isn't available. Please file a bugreport!])]
      )
@@@ -638,27 -587,6 +638,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"])
@@@ -680,127 -607,13 +680,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(
 +[[[
 +#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
 +#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(
 +[[[
 +#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(
 +[[[
 +#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.])],
  if test "x$nan_type" = "xnone"; then
    AC_CACHE_CHECK([whether NAN is defined by default],
      [c_cv_have_nan_default],
 -    AC_COMPILE_IFELSE(
 -      [AC_LANG_PROGRAM(
 -      [[[
 +    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
 +[[[
  #include <stdlib.h>
  #include <math.h>
  static double foo = NAN;
 -      ]]],
 -      [[[
 +]]],
 +[[[
         if (isnan (foo))
          return 0;
         else
        return 1;
 -      ]]])],
 +]]]
 +      )],
        [c_cv_have_nan_default="yes"],
        [c_cv_have_nan_default="no"]
      )
  if test "x$nan_type" = "xnone"; then
    AC_CACHE_CHECK([whether NAN is defined by __USE_ISOC99],
      [c_cv_have_nan_isoc],
 -    AC_COMPILE_IFELSE(
 -      [AC_LANG_PROGRAM(
 -      [[[
 +    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
 +[[[
  #include <stdlib.h>
  #define __USE_ISOC99 1
  #include <math.h>
  static double foo = NAN;
 -      ]]],
 -      [[[
 +]]],
 +[[[
         if (isnan (foo))
          return 0;
         else
        return 1;
 -      ]]])],
 +]]]
 +      )],
        [c_cv_have_nan_isoc="yes"],
        [c_cv_have_nan_isoc="no"]
      )
@@@ -870,8 -683,9 +870,8 @@@ if test "x$nan_type" = "xnone"; the
    LDFLAGS="$LDFLAGS -lm"
    AC_CACHE_CHECK([whether NAN can be defined by 0/0],
      [c_cv_have_nan_zero],
 -    AC_RUN_IFELSE(
 -      [AC_LANG_PROGRAM(
 -      [[[
 +    AC_RUN_IFELSE([AC_LANG_PROGRAM(
 +[[[
  #include <stdlib.h>
  #include <math.h>
  #ifdef NAN
  # define isnan(f) ((f) != (f))
  #endif
  static double foo = NAN;
 -      ]]],
 -      [[[
 +]]],
 +[[[
         if (isnan (foo))
          return 0;
         else
        return 1;
 -      ]]])],
 +]]]
 +      )],
        [c_cv_have_nan_zero="yes"],
        [c_cv_have_nan_zero="no"]
      )
@@@ -931,8 -744,9 +931,8 @@@ fi; fi; f
  if test "x$fp_layout_type" = "xunknown"; then
    AC_CACHE_CHECK([if doubles are stored in x86 representation],
      [c_cv_fp_layout_need_nothing],
 -    AC_RUN_IFELSE(
 -      [AC_LANG_PROGRAM(
 -      [[[
 +    AC_RUN_IFELSE([AC_LANG_PROGRAM(
 +[[[
  #include <stdlib.h>
  #include <stdio.h>
  #include <string.h>
  #if HAVE_STDBOOL_H
  # include <stdbool.h>
  #endif
 -      ]]],
 -      [[[
 +]]],
 +[[[
        uint64_t i0;
        uint64_t i1;
        uint8_t c[8];
                return (0);
        else
                return (1);
 -      ]]])],
 +]]]
 +      )],
        [c_cv_fp_layout_need_nothing="yes"],
        [c_cv_fp_layout_need_nothing="no"]
      )
@@@ -978,8 -791,9 +978,8 @@@ f
  if test "x$fp_layout_type" = "xunknown"; then
    AC_CACHE_CHECK([if endianflip converts to x86 representation],
      [c_cv_fp_layout_need_endianflip],
 -    AC_RUN_IFELSE(
 -      [AC_LANG_PROGRAM(
 -      [[[
 +    AC_RUN_IFELSE([AC_LANG_PROGRAM(
 +[[[
  #include <stdlib.h>
  #include <stdio.h>
  #include <string.h>
                         (((uint64_t)(A) & 0x0000000000ff0000LL) << 24) | \
                         (((uint64_t)(A) & 0x000000000000ff00LL) << 40) | \
                         (((uint64_t)(A) & 0x00000000000000ffLL) << 56))
 -      ]]],
 -      [[[
 +]]],
 +[[[
        uint64_t i0;
        uint64_t i1;
        uint8_t c[8];
                return (0);
        else
                return (1);
 -      ]]])],
 +]]]
 +      )],
        [c_cv_fp_layout_need_endianflip="yes"],
        [c_cv_fp_layout_need_endianflip="no"]
      )
  if test "x$fp_layout_type" = "xunknown"; then
    AC_CACHE_CHECK([if intswap converts to x86 representation],
      [c_cv_fp_layout_need_intswap],
 -    AC_RUN_IFELSE(
 -      [AC_LANG_PROGRAM(
 -      [[[
 +    AC_RUN_IFELSE([AC_LANG_PROGRAM(
 +[[[
  #include <stdlib.h>
  #include <stdio.h>
  #include <string.h>
  #endif
  #define intswap(A)    ((((uint64_t)(A) & 0xffffffff00000000LL) >> 32) | \
                         (((uint64_t)(A) & 0x00000000ffffffffLL) << 32))
 -      ]]],
 -      [[[
 +]]],
 +[[[
        uint64_t i0;
        uint64_t i1;
        uint8_t c[8];
                return (0);
        else
                return (1);
 -      ]]])],
 +]]]
 +      )],
        [c_cv_fp_layout_need_intswap="yes"],
        [c_cv_fp_layout_need_intswap="no"]
      )
@@@ -1116,16 -929,14 +1116,16 @@@ if test "x$have_getmntent" = "xc"; the
        AC_CACHE_CHECK([whether getmntent takes one argument],
                [c_cv_have_one_getmntent],
                AC_COMPILE_IFELSE(
 -                      [AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
 -#include "$srcdir/src/utils_mount.h"]],
 -                              [[[
 -                               FILE *fh;
 -                               struct mntent *me;
 -                               fh = setmntent ("/etc/mtab", "r");
 -                               me = getmntent (fh);
 -                              ]]]
 +                      [AC_LANG_PROGRAM(
 +[[[
 +#include "$srcdir/src/utils_mount.h"
 +]]],
 +[[[
 +FILE *fh;
 +struct mntent *me;
 +fh = setmntent ("/etc/mtab", "r");
 +me = getmntent (fh);
 +]]]
                        )],
                        [c_cv_have_one_getmntent="yes"],
                        [c_cv_have_one_getmntent="no"]
        AC_CACHE_CHECK([whether getmntent takes two arguments],
                [c_cv_have_two_getmntent],
                AC_COMPILE_IFELSE(
 -                      [AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
 -#include "$srcdir/src/utils_mount.h"]],
 -                              [[[
 +                      [AC_LANG_PROGRAM(
 +[[[
 +#include "$srcdir/src/utils_mount.h"
 +]]],
 +[[[
                                 FILE *fh;
                                 struct mnttab mt;
                                 int status;
                                 fh = fopen ("/etc/mnttab", "r");
                                 status = getmntent (fh, &mt);
 -                              ]]]
 +]]]
                        )],
                        [c_cv_have_two_getmntent="yes"],
                        [c_cv_have_two_getmntent="no"]
  AC_MSG_CHECKING([if have htonll defined])
  
      have_htonll="no"
 -    AC_LINK_IFELSE([
 -       AC_LANG_PROGRAM([[[
 +    AC_LINK_IFELSE([AC_LANG_PROGRAM(
 +[[[
  #include <sys/types.h>
  #include <netinet/in.h>
  #if HAVE_INTTYPES_H
  # include <inttypes.h>
  #endif
 -       ]]], [[[
 +]]],
 +[[[
            return htonll(0);
 -       ]]])
 -    ], [
 +]]]
 +    )],
 +    [
        have_htonll="yes"
        AC_DEFINE(HAVE_HTONLL, 1, [Define if the function htonll exists.])
      ])
@@@ -1236,6 -1043,7 +1236,6 @@@ AC_CHECK_MEMBERS([struct kinfo_proc.ki_
                have_struct_kinfo_proc_freebsd="no"
        ],
        [
 -AC_INCLUDES_DEFAULT
  #include <kvm.h>
  #include <sys/param.h>
  #include <sys/sysctl.h>
@@@ -1252,6 -1060,7 +1252,6 @@@ AC_CHECK_MEMBERS([struct kinfo_proc.kp_
                have_struct_kinfo_proc_openbsd="no"
        ],
        [
 -AC_INCLUDES_DEFAULT
  #include <sys/param.h>
  #include <sys/sysctl.h>
  #include <kvm.h>
@@@ -1312,7 -1121,6 +1312,7 @@@ AC_CHECK_MEMBERS([kstat_io_t.nwritten, 
  #
  # Checks for libraries begin here
  #
 +
  with_libresolv="yes"
  AC_CHECK_LIB(resolv, res_search,
  [
  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=""
        if test -d "$with_java_home"
        then
                AC_MSG_CHECKING([for jni.h])
-               TMPDIR=`find "$with_java_home" -name jni.h -type f -exec 'dirname' '{}' ';' | head -n 1`
-               if test "x$TMPDIR" != "x"
+               TMPVAR=`find "$with_java_home" -name jni.h -type f -exec 'dirname' '{}' ';' | head -n 1`
+               if test "x$TMPVAR" != "x"
                then
-                       AC_MSG_RESULT([found in $TMPDIR])
-                       JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPDIR"
+                       AC_MSG_RESULT([found in $TMPVAR])
+                       JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPVAR"
                else
                        AC_MSG_RESULT([not found])
                fi
  
                AC_MSG_CHECKING([for jni_md.h])
-               TMPDIR=`find "$with_java_home" -name jni_md.h -type f -exec 'dirname' '{}' ';' | head -n 1`
-               if test "x$TMPDIR" != "x"
+               TMPVAR=`find "$with_java_home" -name jni_md.h -type f -exec 'dirname' '{}' ';' | head -n 1`
+               if test "x$TMPVAR" != "x"
                then
-                       AC_MSG_RESULT([found in $TMPDIR])
-                       JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPDIR"
+                       AC_MSG_RESULT([found in $TMPVAR])
+                       JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPVAR"
                else
                        AC_MSG_RESULT([not found])
                fi
  
                AC_MSG_CHECKING([for libjvm.so])
-               TMPDIR=`find "$with_java_home" -name libjvm.so -type f -exec 'dirname' '{}' ';' | head -n 1`
-               if test "x$TMPDIR" != "x"
+               TMPVAR=`find "$with_java_home" -name libjvm.so -type f -exec 'dirname' '{}' ';' | head -n 1`
+               if test "x$TMPVAR" != "x"
                then
-                       AC_MSG_RESULT([found in $TMPDIR])
-                       JAVA_LDFLAGS="$JAVA_LDFLAGS -L$TMPDIR -Wl,-rpath -Wl,$TMPDIR"
+                       AC_MSG_RESULT([found in $TMPVAR])
+                       JAVA_LDFLAGS="$JAVA_LDFLAGS -L$TMPVAR -Wl,-rpath -Wl,$TMPVAR"
                else
                        AC_MSG_RESULT([not found])
                fi
                if test "x$JAVAC" = "x"
                then
                        AC_MSG_CHECKING([for javac])
-                       TMPDIR=`find "$with_java_home" -name javac -type f | head -n 1`
-                       if test "x$TMPDIR" != "x"
+                       TMPVAR=`find "$with_java_home" -name javac -type f | head -n 1`
+                       if test "x$TMPVAR" != "x"
                        then
-                               JAVAC="$TMPDIR"
+                               JAVAC="$TMPVAR"
                                AC_MSG_RESULT([$JAVAC])
                        else
                                AC_MSG_RESULT([not found])
                if test "x$JAR" = "x"
                then
                        AC_MSG_CHECKING([for jar])
-                       TMPDIR=`find "$with_java_home" -name jar -type f | head -n 1`
-                       if test "x$TMPDIR" != "x"
+                       TMPVAR=`find "$with_java_home" -name jar -type f | head -n 1`
+                       if test "x$TMPVAR" != "x"
                        then
-                               JAR="$TMPDIR"
+                               JAR="$TMPVAR"
                                AC_MSG_RESULT([$JAR])
                        else
                                AC_MSG_RESULT([not found])
  fi
  if test "x$with_libmodbus" = "xuse_pkgconfig"
  then
 -      AC_MSG_NOTICE([Checking for modbus using $PKG_CONFIG])
 -      $PKG_CONFIG --exists 'modbus' 2>/dev/null
 +      AC_MSG_NOTICE([Checking for libmodbus using $PKG_CONFIG])
 +      $PKG_CONFIG --exists 'libmodbus' 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 libmodbus)"
        fi
  fi
  if test "x$with_libmodbus" = "xuse_pkgconfig"
  then
 -      with_libmodbus_cflags="`$PKG_CONFIG --cflags 'modbus'`"
 +      with_libmodbus_cflags="`$PKG_CONFIG --cflags 'libmodbus'`"
        if test $? -ne 0
        then
                with_libmodbus="no ($PKG_CONFIG failed)"
        fi
 -      with_libmodbus_libs="`$PKG_CONFIG --libs 'modbus'`"
 +      with_libmodbus_libs="`$PKG_CONFIG --libs 'libmodbus'`"
        if test $? -ne 0
        then
                with_libmodbus="no ($PKG_CONFIG failed)"
@@@ -2253,9 -1997,9 +2253,9 @@@ the
        CPPFLAGS="$CPPFLAGS $with_libmodbus_cflags"
        LDFLAGS="$LDFLAGS $with_libmodbus_libs"
  
 -      AC_CHECK_LIB(modbus, modbus_init_tcp,
 +      AC_CHECK_LIB(modbus, modbus_connect,
                     [with_libmodbus="yes"],
 -                   [with_libmodbus="no (symbol modbus_init_tcp not found)"])
 +                   [with_libmodbus="no (symbol modbus_connect not found)"])
  
        CPPFLAGS="$SAVE_CPPFLAGS"
        LDFLAGS="$SAVE_LDFLAGS"
  fi
  # }}}
  
 +# --with-libmongoc {{{
 +AC_ARG_WITH(libmongoc, [AS_HELP_STRING([--with-libmongoc@<:@=PREFIX@:>@], [Path to libmongoc.])],
 +[
 + if test "x$withval" = "xyes"
 + then
 +       with_libmongoc="yes"
 + else if test "x$withval" = "xno"
 + then
 +       with_libmongoc="no"
 + else
 +       with_libmongoc="yes"
 +       LIBMONGOC_CPPFLAGS="$LIBMONGOC_CPPFLAGS -I$withval/include"
 +       LIBMONGOC_LDFLAGS="$LIBMONGOC_LDFLAGS -L$withval/lib"
 + fi; fi
 +],
 +[with_libmongoc="yes"])
 +
 +SAVE_CPPFLAGS="$CPPFLAGS"
 +SAVE_LDFLAGS="$LDFLAGS"
 +
 +CPPFLAGS="$CPPFLAGS $LIBMONGOC_CPPFLAGS"
 +LDFLAGS="$LDFLAGS $LIBMONGOC_LDFLAGS"
 +
 +if test "x$with_libmongoc" = "xyes"
 +then
 +      if test "x$LIBMONGOC_CPPFLAGS" != "x"
 +      then
 +              AC_MSG_NOTICE([libmongoc CPPFLAGS: $LIBMONGOC_CPPFLAGS])
 +      fi
 +      AC_CHECK_HEADERS(mongo.h,
 +      [with_libmongoc="yes"],
 +      [with_libmongoc="no ('mongo.h' not found)"],
 +[#if HAVE_STDINT_H
 +# define MONGO_HAVE_STDINT 1
 +#else
 +# define MONGO_USE_LONG_LONG_INT 1
 +#endif
 +])
 +fi
 +if test "x$with_libmongoc" = "xyes"
 +then
 +      if test "x$LIBMONGOC_LDFLAGS" != "x"
 +      then
 +              AC_MSG_NOTICE([libmongoc LDFLAGS: $LIBMONGOC_LDFLAGS])
 +      fi
 +      AC_CHECK_LIB(mongoc, mongo_run_command,
 +      [with_libmongoc="yes"],
 +      [with_libmongoc="no (symbol 'mongo_run_command' not found)"])
 +fi
 +
 +CPPFLAGS="$SAVE_CPPFLAGS"
 +LDFLAGS="$SAVE_LDFLAGS"
 +
 +if test "x$with_libmongoc" = "xyes"
 +then
 +      BUILD_WITH_LIBMONGOC_CPPFLAGS="$LIBMONGOC_CPPFLAGS"
 +      BUILD_WITH_LIBMONGOC_LDFLAGS="$LIBMONGOC_LDFLAGS"
 +      AC_SUBST(BUILD_WITH_LIBMONGOC_CPPFLAGS)
 +      AC_SUBST(BUILD_WITH_LIBMONGOC_LDFLAGS)
 +fi
 +AM_CONDITIONAL(BUILD_WITH_LIBMONGOC, test "x$with_libmongoc" = "xyes")
 +# }}}
 +
  # --with-libmysql {{{
  with_mysql_config="mysql_config"
  with_mysql_cflags=""
  #include <sys/socket.h>])
  
          AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
 -                           [[[
 -                            #include <stdio.h>
 -                            #include <sys/types.h>
 -                            #include <asm/types.h>
 -                            #include <sys/socket.h>
 -                            #include <linux/netlink.h>
 -                            #include <linux/rtnetlink.h>
 -                            ]]], [[[
 -                                int retval = TCA_STATS2;
 -                                return (retval);
 -                                ]]]
 -                            )],
 -                            [AC_DEFINE([HAVE_TCA_STATS2], [1], [True if the enum-member TCA_STATS2 exists])])
 +[[[
 +#include <stdio.h>
 +#include <sys/types.h>
 +#include <asm/types.h>
 +#include <sys/socket.h>
 +#include <linux/netlink.h>
 +#include <linux/rtnetlink.h>
 +]]],
 +[[[
 +int retval = TCA_STATS2;
 +return (retval);
 +]]]
 +      )],
 +      [AC_DEFINE([HAVE_TCA_STATS2], [1], [True if the enum-member TCA_STATS2 exists])])
  
        AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
 -[[[#include <stdio.h>
 +[[[
 +#include <stdio.h>
  #include <sys/types.h>
  #include <asm/types.h>
  #include <sys/socket.h>
  #include <linux/netlink.h>
  #include <linux/rtnetlink.h>
 -]]], [[[
 -int main (void)
 -{
 -      int retval = TCA_STATS;
 -      return (retval);
 -}]]])],
 -      [AC_DEFINE([HAVE_TCA_STATS], 1, [True if the enum-member TCA_STATS exists])]
 -      []);
 +]]],
 +[[[
 +int retval = TCA_STATS;
 +return (retval);
 +]]]
 +      )],
 +      [AC_DEFINE([HAVE_TCA_STATS], 1, [True if the enum-member TCA_STATS exists])])
  
        CFLAGS="$SAVE_CFLAGS"
  fi
        AC_CACHE_CHECK(
                [if function 'rtnl_dump_filter' expects five arguments],
                [c_cv_rtnl_dump_filter_five_args],
 -              AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 -AC_INCLUDES_DEFAULT
 +              AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
 +[[[
 +#include <stdio.h>
 +#include <sys/types.h>
  #include <asm/types.h>
  #include <sys/socket.h>
  #if HAVE_LIBNETLINK_H
  #elif HAVE_LINUX_LIBNETLINK_H
  # include <linux/libnetlink.h>
  #endif
 -                              ]], [[[
 +]]],
 +[[[
  if (rtnl_dump_filter(NULL, NULL, NULL, NULL, NULL))
        return 1;
  return 0;
 -                              ]]]
 -                      )],
 -                      [c_cv_rtnl_dump_filter_five_args="yes"],
 -                      [c_cv_rtnl_dump_filter_five_args="no"]
 -              )
 +]]]
 +      )],
 +      [c_cv_rtnl_dump_filter_five_args="yes"],
 +      [c_cv_rtnl_dump_filter_five_args="no"]
        )
 +)
  
        AC_CACHE_CHECK(
                [if function 'rtnl_dump_filter' expects three arguments],
                [c_cv_rtnl_dump_filter_three_args],
                AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
 -                              [[
 -AC_INCLUDES_DEFAULT
 +[[[
 +#include <stdio.h>
 +#include <sys/types.h>
  #include <asm/types.h>
  #include <sys/socket.h>
  #if HAVE_LIBNETLINK_H
  #elif HAVE_LINUX_LIBNETLINK_H
  # include <linux/libnetlink.h>
  #endif
 -                              ]], [[[
 +]]],
 +[[[
  if (rtnl_dump_filter(NULL, NULL, NULL))
        return 1;
  return 0;
 -                              ]]]
 -                      )],
 -                      [c_cv_rtnl_dump_filter_three_args="yes"],
 -                      [c_cv_rtnl_dump_filter_three_args="no"]
 -              )
 +]]]
 +      )],
 +      [c_cv_rtnl_dump_filter_three_args="yes"],
 +      [c_cv_rtnl_dump_filter_three_args="no"]
        )
 +)
  
        CFLAGS="$SAVE_CFLAGS"
  
@@@ -2813,7 -2488,7 +2813,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
@@@ -2984,8 -2659,7 +2984,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")
  # }}}
@@@ -3037,20 -2711,20 +3037,20 @@@ dnl ARCHFLAGS="" -> disable multi -arc
  
    AC_CACHE_CHECK([for libperl],
      [c_cv_have_libperl],
 -    AC_LINK_IFELSE(
 -      [AC_LANG_PROGRAM(
 -      [[[
 +    AC_LINK_IFELSE([AC_LANG_PROGRAM(
 +[[[
  #define PERL_NO_GET_CONTEXT
  #include <EXTERN.h>
  #include <perl.h>
  #include <XSUB.h>
 -      ]]],
 -      [[[
 +]]],
 +[[[
         dTHX;
         load_module (PERL_LOADMOD_NOIMPORT,
                         newSVpv ("Collectd::Plugin::FooBar", 24),
                         Nullsv);
 -      ]]])],
 +]]]
 +      )],
        [c_cv_have_libperl="yes"],
        [c_cv_have_libperl="no"]
      )
@@@ -3082,8 -2756,9 +3082,8 @@@ the
  
        AC_CACHE_CHECK([if perl supports ithreads],
                [c_cv_have_perl_ithreads],
 -              AC_LINK_IFELSE(
 -                      [AC_LANG_PROGRAM(
 -                      [[[
 +              AC_LINK_IFELSE([AC_LANG_PROGRAM(
 +[[[
  #include <EXTERN.h>
  #include <perl.h>
  #include <XSUB.h>
  #if !defined(USE_ITHREADS)
  # error "Perl does not support ithreads!"
  #endif /* !defined(USE_ITHREADS) */
 -                      ]]],
 -                      [[[ ]]])],
 +]]],
 +[[[ ]]]
 +                      )],
                        [c_cv_have_perl_ithreads="yes"],
                        [c_cv_have_perl_ithreads="no"]
                )
  
        AC_CACHE_CHECK([for broken Perl_load_module()],
                [c_cv_have_broken_perl_load_module],
 -              AC_LINK_IFELSE(
 -                      [AC_LANG_PROGRAM(
 -                      [[[
 +              AC_LINK_IFELSE([AC_LANG_PROGRAM(
 +[[[
  #define PERL_NO_GET_CONTEXT
  #include <EXTERN.h>
  #include <perl.h>
  #include <XSUB.h>
 -                      ]]],
 -                      [[[
 +]]],
 +[[[
                         dTHX;
                         load_module (PERL_LOADMOD_NOIMPORT,
                             newSVpv ("Collectd::Plugin::FooBar", 24),
                             Nullsv);
 -                      ]]])],
 +]]]
 +                      )],
                        [c_cv_have_broken_perl_load_module="no"],
                        [c_cv_have_broken_perl_load_module="yes"]
                )
  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"
 +])
 +SAVE_CPPFLAGS="$CPPFLAGS"
 +SAVE_LDFLAGS="$LDFLAGS"
 +CPPFLAGS="$CPPFLAGS $with_librabbitmq_cppflags"
 +LDFLAGS="$LDFLAGS $with_librabbitmq_ldflags"
 +if test "x$with_librabbitmq" = "xyes"
 +then
 +      AC_CHECK_HEADERS(amqp.h, [with_librabbitmq="yes"], [with_librabbitmq="no (amqp.h not found)"])
 +fi
 +if test "x$with_librabbitmq" = "xyes"
 +then
 +      # librabbitmq up to version 0.9.1 provides "library_errno", later
 +      # versions use "library_error". The library does not provide a version
 +      # macro :( Use "AC_CHECK_MEMBERS" (plural) for automatic defines.
 +      AC_CHECK_MEMBERS([amqp_rpc_reply_t.library_errno],,,
 +                       [
 +#if HAVE_STDLIB_H
 +# include <stdlib.h>
 +#endif
 +#if HAVE_STDIO_H
 +# include <stdio.h>
 +#endif
 +#if HAVE_STDINT_H
 +# include <stdint.h>
 +#endif
 +#if HAVE_INTTYPES_H
 +# include <inttypes.h>
 +#endif
 +#include <amqp.h>
 +                         ])
 +fi
 +if test "x$with_librabbitmq" = "xyes"
 +then
 +      AC_CHECK_LIB(rabbitmq, amqp_basic_publish, [with_librabbitmq="yes"], [with_librabbitmq="no (Symbol 'amqp_basic_publish' not found)"])
 +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
 +CPPFLAGS="$SAVE_CPPFLAGS"
 +LDFLAGS="$SAVE_LDFLAGS"
 +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.])],
  [
@@@ -3517,7 -3125,7 +3517,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
@@@ -3716,7 -3324,7 +3716,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])
@@@ -3936,7 -3544,7 +3936,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"
  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 -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_HEADERS(varnish/vsc.h,
 +        [AC_DEFINE([HAVE_VARNISH_V3], [1], [Varnish 3 API support])],
 +        [AC_DEFINE([HAVE_VARNISH_V2], [1], [Varnish 2 API support])])
 +
 +      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=""
@@@ -4231,7 -3748,7 +4231,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"
@@@ -4356,7 -3873,7 +4356,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
  #
@@@ -4561,8 -4074,6 +4561,8 @@@ plugin_curl_xml="no
  plugin_df="no"
  plugin_disk="no"
  plugin_entropy="no"
 +plugin_ethstat="no"
 +plugin_fscache="no"
  plugin_interface="no"
  plugin_ipmi="no"
  plugin_ipvs="no"
@@@ -4572,7 -4083,7 +4572,7 @@@ plugin_load="no
  plugin_memory="no"
  plugin_multimeter="no"
  plugin_nfs="no"
 -plugin_fscache="no"
 +plugin_numa="no"
  plugin_perl="no"
  plugin_processes="no"
  plugin_protocols="no"
        plugin_cpufreq="yes"
        plugin_disk="yes"
        plugin_entropy="yes"
 +      plugin_fscache="yes"
        plugin_interface="yes"
        plugin_irq="yes"
        plugin_load="yes"
        plugin_memory="yes"
        plugin_nfs="yes"
 -      plugin_fscache="yes"
 +      plugin_numa="yes"
        plugin_processes="yes"
        plugin_protocols="yes"
        plugin_serial="yes"
  fi
  
  # AIX
 +
 +if test "x$ac_system" = "xAIX"
 +then
 +        plugin_tcpconns="yes"
 +fi
 +
  if test "x$with_perfstat" = "xyes"
  then
        plugin_cpu="yes"
  # Solaris
  if test "x$with_kstat" = "xyes"
  then
 +      plugin_nfs="yes"
        plugin_uptime="yes"
        plugin_zfs_arc="yes"
  fi
@@@ -4674,6 -4177,11 +4674,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"
@@@ -4718,15 -4223,11 +4718,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"
        fi
  fi
  
 +if test "x$have_linux_sockios_h$have_linux_ethtool_h" = "xyesyes"
 +then
 +      plugin_ethstat="yes"
 +fi
 +
  if test "x$have_getifaddrs" = "xyes"
  then
        plugin_interface="yes"
@@@ -4819,7 -4315,7 +4819,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
@@@ -4859,7 -4355,6 +4859,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])
@@@ -4880,7 -4375,6 +4880,7 @@@ AC_PLUGIN([disk],        [$plugin_disk]
  AC_PLUGIN([dns],         [$with_libpcap],      [DNS traffic analysis])
  AC_PLUGIN([email],       [yes],                [EMail statistics])
  AC_PLUGIN([entropy],     [$plugin_entropy],    [Entropy statistics])
 +AC_PLUGIN([ethstat],     [$plugin_ethstat],    [Stats from NIC driver])
  AC_PLUGIN([exec],        [yes],                [Execution of external programs])
  AC_PLUGIN([filecount],   [yes],                [Count files in directories])
  AC_PLUGIN([fscache],     [$plugin_fscache],    [fscache statistics])
@@@ -4895,7 -4389,6 +4895,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])
@@@ -4903,7 -4396,6 +4903,7 @@@ AC_PLUGIN([match_regex], [yes]
  AC_PLUGIN([match_timediff], [yes],             [The timediff match])
  AC_PLUGIN([match_value], [yes],                [The value match])
  AC_PLUGIN([mbmon],       [yes],                [Query mbmond])
 +AC_PLUGIN([md],          [$have_linux_raid_md_u_h], [md (Linux software RAID) devices])
  AC_PLUGIN([memcachec],   [$with_libmemcached], [memcachec statistics])
  AC_PLUGIN([memcached],   [yes],                [memcached statistics])
  AC_PLUGIN([memory],      [$plugin_memory],     [Memory usage])
@@@ -4918,7 -4410,6 +4918,7 @@@ AC_PLUGIN([nginx],       [$with_libcurl
  AC_PLUGIN([notify_desktop], [$with_libnotify], [Desktop notifications])
  AC_PLUGIN([notify_email], [$with_libesmtp],    [Email notifier])
  AC_PLUGIN([ntpd],        [yes],                [NTPd statistics])
 +AC_PLUGIN([numa],        [$plugin_numa],       [NUMA virtual memory statistics])
  AC_PLUGIN([nut],         [$with_libupsclient], [Network UPS tools statistics])
  AC_PLUGIN([olsrd],       [yes],                [olsrd statistics])
  AC_PLUGIN([onewire],     [$with_libowcapi],    [OneWire sensor statistics])
@@@ -4933,7 -4424,6 +4933,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])
@@@ -4949,25 -4439,19 +4949,25 @@@ 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_graphite], [yes],             [Graphite / Carbon output plugin])
  AC_PLUGIN([write_http],  [$with_libcurl],      [HTTP output plugin])
 +AC_PLUGIN([write_redis], [$with_libcredis],    [Redis output plugin])
 +AC_PLUGIN([write_mongodb], [$with_libmongoc],  [MongoDB output plugin])
  AC_PLUGIN([xmms],        [$with_libxmms],      [XMMS statistics])
  AC_PLUGIN([zfs_arc],     [$plugin_zfs_arc],    [ZFS ARC statistics])
  
@@@ -5110,7 -4594,7 +5110,7 @@@ AC_SUBST(LCC_VERSION_STRING
  
  AC_CONFIG_FILES(src/libcollectdclient/lcc_features.h)
  
 -AC_OUTPUT(Makefile src/Makefile src/collectd.conf src/owniptc/Makefile src/libcollectdclient/Makefile src/libcollectdclient/libcollectdclient.pc src/liboconfig/Makefile bindings/Makefile bindings/java/Makefile)
 +AC_OUTPUT(Makefile src/Makefile src/collectd.conf src/libcollectdclient/Makefile src/libcollectdclient/libcollectdclient.pc src/liboconfig/Makefile bindings/Makefile bindings/java/Makefile)
  
  if test "x$with_librrd" = "xyes" \
        && test "x$librrd_threadsafe" != "xyes"
@@@ -5142,7 -4626,6 +5142,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
      dns . . . . . . . . . $enable_dns
      email . . . . . . . . $enable_email
      entropy . . . . . . . $enable_entropy
 +    ethstat . . . . . . . $enable_ethstat
      exec  . . . . . . . . $enable_exec
      filecount . . . . . . $enable_filecount
      fscache . . . . . . . $enable_fscache
      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
      match_timediff  . . . $enable_match_timediff
      match_value . . . . . $enable_match_value
      mbmon . . . . . . . . $enable_mbmon
 +    md  . . . . . . . . . $enable_md
      memcachec . . . . . . $enable_memcachec
      memcached . . . . . . $enable_memcached
      memory  . . . . . . . $enable_memory
      notify_desktop  . . . $enable_notify_desktop
      notify_email  . . . . $enable_notify_email
      ntpd  . . . . . . . . $enable_ntpd
 +    numa  . . . . . . . . $enable_numa
      nut . . . . . . . . . $enable_nut
      olsrd . . . . . . . . $enable_olsrd
      onewire . . . . . . . $enable_onewire
      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_graphite  . . . $enable_write_graphite
      write_http  . . . . . $enable_write_http
 +    write_redis . . . . . $enable_write_redis
 +    write_mongodb . . . . $enable_write_mongodb
      xmms  . . . . . . . . $enable_xmms
      zfs_arc . . . . . . . $enable_zfs_arc
  
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;
+       _Bool  is_connected;
  };
  typedef struct mysql_database_s mysql_database_t; /* }}} */
  
@@@ -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)
        {
                ud.data = (void *) db;
                ud.free_func = mysql_database_free;
  
 -              if (db->database != NULL)
 +              if (db->instance != NULL)
                        ssnprintf (cb_name, sizeof (cb_name), "mysql-%s",
 -                                      db->database);
 +                                      db->instance);
                else
                        sstrncpy (cb_name, "mysql", sizeof (cb_name));
  
        }
  
        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 */
  
  static MYSQL *getconnection (mysql_database_t *db)
  {
-       if (db->state != 0)
+       if (db->is_connected)
        {
-               int err;
-               if ((err = mysql_ping (db->con)) != 0)
-               {
-                       /* 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;
-               }
-               else
-               {
-                       db->state = 1;
+               int status;
+               status = mysql_ping (db->con);
+               if (status == 0)
                        return (db->con);
-               }
+               WARNING ("mysql plugin: Lost connection to instance \"%s\": %s",
 -                              (db->instance != NULL)
 -                              ? db->instance
 -                              : "<legacy>",
 -                              mysql_error (db->con));
++                              db->instance, mysql_error (db->con));
        }
+       db->is_connected = 0;
  
-       if ((db->con = mysql_init (db->con)) == NULL)
+       if (db->con == NULL)
        {
-               ERROR ("mysql_init failed: %s", mysql_error (db->con));
-               db->state = 0;
-               return (NULL);
+               db->con = mysql_init (NULL);
+               if (db->con == NULL)
+               {
+                       ERROR ("mysql plugin: mysql_init failed: %s",
+                                       mysql_error (db->con));
+                       return (NULL);
+               }
        }
  
        if (mysql_real_connect (db->con, db->host, db->user, db->pass,
                                (db->database != NULL) ? db->database : "<none>",
                                (db->host != NULL) ? db->host : "localhost",
                                mysql_error (db->con));
-               db->state = 0;
                return (NULL);
        }
-       else
-       {
-               INFO ("mysql plugin: Successfully connected to database %s "
-                               "at server %s (server version: %s, protocol version: %d)",
-                               (db->database != NULL) ? db->database : "<none>",
-                               mysql_get_host_info (db->con),
-                               mysql_get_server_info (db->con),
-                               mysql_get_proto_info (db->con));
-               db->state = 1;
-               return (db->con);
-       }
+       INFO ("mysql plugin: Successfully connected to database %s "
+                       "at server %s (server version: %s, protocol version: %d)",
+                       (db->database != NULL) ? db->database : "<none>",
+                       mysql_get_host_info (db->con),
+                       mysql_get_server_info (db->con),
+                       mysql_get_proto_info (db->con));
+       db->is_connected = 1;
+       return (db->con);
  } /* static MYSQL *getconnection (mysql_database_t *db) */
  
  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 -472,40 +334,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 */
@@@ -489,7 -642,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))
@@@ -560,16 -711,16 +556,16 @@@ static int mysql_read (user_data_t *ud
        MYSQL_ROW  row;
        char      *query;
  
 -      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;
                                                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-2010  Florian octo Forster
+  * Copyright (C) 2005-2013  Florian octo Forster
   * Copyright (C) 2009       Aman Gupta
   *
   * This program is free software; you can redistribute it and/or modify it
@@@ -18,7 -18,7 +18,7 @@@
   * Inc., 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>
   *   Aman Gupta <aman at tmm1.net>
   **/
  
@@@ -276,8 -276,7 +276,8 @@@ typedef struct receive_list_entry_s rec
   * Private variables
   */
  static int network_config_ttl = 0;
 -static size_t network_config_packet_size = 1024;
 +/* Ethernet - (IPv6 + UDP) = 1500 - (40 + 8) = 1452 */
 +static size_t network_config_packet_size = 1452;
  static int network_config_forward = 0;
  static int network_config_stats = 0;
  
@@@ -314,14 -313,14 +314,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;
  
  /*
@@@ -338,30 -337,30 +338,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
@@@ -439,7 -438,7 +439,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.");
@@@ -493,6 -492,20 +493,20 @@@ static int network_dispatch_notificatio
  } /* }}} int network_dispatch_notification */
  
  #if HAVE_LIBGCRYPT
+ static void network_init_gcrypt (void) /* {{{ */
+ {
+   /* http://lists.gnupg.org/pipermail/gcrypt-devel/2003-August/000458.html
+    * Because you can't know in a library whether another library has
+    * already initialized the library */
+   if (gcry_control (GCRYCTL_ANY_INITIALIZATION_P))
+     return;
+   gcry_check_version (NULL); /* before calling any other functions */
+   gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
+   gcry_control (GCRYCTL_INIT_SECMEM, 32768);
+   gcry_control (GCRYCTL_INITIALIZATION_FINISHED);
+ } /* }}} void network_init_gcrypt */
  static gcry_cipher_hd_t network_get_aes256_cypher (sockent_t *se, /* {{{ */
      const void *iv, size_t iv_size, const char *username)
  {
@@@ -1457,19 -1470,8 +1471,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)
                {
@@@ -2029,6 -2023,8 +2043,8 @@@ static int sockent_open (sockent_t *se
        {
                if (se->data.client.security_level > SECURITY_LEVEL_NONE)
                {
+                       network_init_gcrypt ();
                        if ((se->data.client.username == NULL)
                                        || (se->data.client.password == NULL))
                        {
        {
                if (se->data.server.security_level > SECURITY_LEVEL_NONE)
                {
+                       network_init_gcrypt ();
                        if (se->data.server.auth_file == NULL)
                        {
                                ERROR ("network plugin: Server socket with "
@@@ -2687,7 -2685,7 +2705,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;
@@@ -3157,6 -3155,8 +3175,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.",
@@@ -3180,7 -3180,7 +3198,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);
@@@ -3285,15 -3285,15 +3303,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_secure (&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_secure (&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
-     /* http://lists.gnupg.org/pipermail/gcrypt-devel/2003-August/000458.html
-      * Because you can't know in a library whether another library has
-      * already initialized the library
-      */
-     if (!gcry_control (GCRYCTL_ANY_INITIALIZATION_P))
-     {
-         gcry_check_version(NULL); /* before calling any other functions */
-         gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
-         gcry_control (GCRYCTL_INIT_SECMEM, 32768, 0);
-         gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
-     }
+       network_init_gcrypt ();
  #endif
  
        if (network_config_stats != 0)
   * 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/thermal.c
  # error "This module is for Linux only."
  #endif
  
 +static const char *config_keys[] = {
 +      "Device",
 +      "IgnoreSelected",
 +      "ForceUseProcfs"
 +};
 +
  const char *const dirname_sysfs = "/sys/class/thermal";
  const char *const dirname_procfs = "/proc/acpi/thermal_zone";
  
 -static char force_procfs = 0;
 +static _Bool force_procfs = 0;
  static ignorelist_t *device_list;
 -static value_list_t vl_temp_template = VALUE_LIST_STATIC;
 -static value_list_t vl_state_template = VALUE_LIST_STATIC;
  
  enum dev_type {
        TEMP = 0,
  static void thermal_submit (const char *plugin_instance, enum dev_type dt,
                gauge_t value)
  {
 -      value_list_t vl = (dt == TEMP) ? vl_temp_template : vl_state_template;
 -      value_t vt;
 +      value_list_t vl = VALUE_LIST_INIT;
 +      value_t v;
  
 -      vt.gauge = value;
 +      v.gauge = value;
 +      vl.values = &v;
  
 -      vl.values = &vt;
+       vl.values_len = 1;
+       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
        sstrncpy (vl.plugin, "thermal", sizeof(vl.plugin));
 -      sstrncpy (vl.plugin_instance, plugin_instance,
 -                      sizeof(vl.plugin_instance));
 -      sstrncpy (vl.type, (dt == TEMP) ? "temperature" : "gauge",
 +      if (plugin_instance != NULL)
 +              sstrncpy (vl.plugin_instance, plugin_instance,
 +                              sizeof (vl.plugin_instance));
 +      sstrncpy (vl.type,
 +                      (dt == TEMP) ? "temperature" : "gauge",
                        sizeof (vl.type));
  
        plugin_dispatch_values (&vl);
@@@ -72,7 -69,7 +75,7 @@@ static int thermal_sysfs_device_read (c
        char filename[256];
        char data[1024];
        int len;
 -      int ok = 0;
 +      _Bool success = 0;
  
        if (device_list && ignorelist_match (device_list, name))
                return -1;
@@@ -93,7 -90,7 +96,7 @@@
  
                if (endptr == data + len && errno == 0) {
                        thermal_submit(name, TEMP, temp);
 -                      ++ok;
 +                      success = 1;
                }
        }
  
  
                if (endptr == data + len && errno == 0) {
                        thermal_submit(name, COOLING_DEV, state);
 -                      ++ok;
 +                      success = 1;
                }
        }
  
 -      return ok ? 0 : -1;
 +      return (success ? 0 : -1);
  }
  
  static int thermal_procfs_device_read (const char __attribute__((unused)) *dir,
                        && (! strncmp(data, str_temp, sizeof(str_temp)-1))) {
                char *endptr = NULL;
                double temp;
 -              double celsius, add;
 +              double factor, add;
                
                if (data[--len] == 'C') {
                        add = 0;
 -                      celsius = 1;
 +                      factor = 1.0;
                } else if (data[len] == 'F') {
                        add = -32;
 -                      celsius = 5/9;
 +                      factor = 5.0/9.0;
                } else if (data[len] == 'K') {
                        add = -273.15;
 -                      celsius = 1;
 +                      factor = 1.0;
                } else
                        return -1;
  
                ++len;
  
                errno = 0;
 -              temp = (strtod (data + len, &endptr) + add) * celsius;
 +              temp = (strtod (data + len, &endptr) + add) * factor;
  
                if (endptr != data + len && errno == 0) {
                        thermal_submit(name, TEMP, temp);
        return -1;
  }
  
 -static const char *config_keys[] = {
 -      "Device",
 -      "IgnoreSelected",
 -      "ForceUseProcfs"
 -};
 -
  static int thermal_config (const char *key, const char *value)
  {
        if (device_list == NULL)
@@@ -237,6 -240,21 +240,6 @@@ static int thermal_init (void
                ret = plugin_register_read ("thermal", thermal_procfs_read);
        }
  
 -      if (!ret) {
 -              vl_temp_template.values_len = 1;
 -              vl_temp_template.interval = interval_g;
 -              sstrncpy (vl_temp_template.host, hostname_g,
 -                      sizeof(vl_temp_template.host));
 -              sstrncpy (vl_temp_template.plugin, "thermal",
 -                      sizeof(vl_temp_template.plugin));
 -              sstrncpy (vl_temp_template.type_instance, "temperature",
 -                      sizeof(vl_temp_template.type_instance));
 -
 -              vl_state_template = vl_temp_template;
 -              sstrncpy (vl_state_template.type_instance, "cooling_state",
 -                      sizeof(vl_state_template.type_instance));
 -      }
 -
        return ret;
  }