Merge branch 'master' into collectd-4
authorFlorian Forster <octo@huhu.verplant.org>
Tue, 15 May 2007 17:27:31 +0000 (19:27 +0200)
committerFlorian Forster <octo@huhu.verplant.org>
Tue, 15 May 2007 17:27:31 +0000 (19:27 +0200)
Conflicts:

src/multimeter.c
src/network.c
src/utils_debug.c

1  2 
configure.in
src/collectd.h
src/common.c
src/utils_ignorelist.c
src/utils_mount.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, 3.11.4)
 +AC_INIT(collectd, 4.0.0-rc9)
  AC_CONFIG_SRCDIR(src/collectd.c)
  AC_CONFIG_HEADERS(src/config.h)
  AM_INIT_AUTOMAKE(dist-bzip2)
@@@ -7,6 -7,8 +7,8 @@@ AC_LANG(C
  
  AC_PREFIX_DEFAULT("/opt/collectd")
  
+ AC_SYS_LARGEFILE
  #
  # Checks for programs.
  #
@@@ -24,8 -26,7 +26,8 @@@ AC_SUBST(LTDLINCL
  AC_SUBST(LIBLTDL)
  AC_LIBTOOL_DLOPEN
  AC_PROG_LIBTOOL
 -#AC_PROG_RANLIB
 +AC_PROG_LEX
 +AC_PROG_YACC
  AC_CONFIG_SUBDIRS(libltdl)
  
  #
@@@ -45,12 -46,11 +47,12 @@@ AC_CHECK_HEADERS(assert.h
  AC_CHECK_HEADERS(sys/types.h)
  AC_CHECK_HEADERS(sys/socket.h)
  AC_CHECK_HEADERS(sys/select.h)
 -AC_CHECK_HEADERS(sys/poll.h)
 +AC_CHECK_HEADERS(poll.h)
  AC_CHECK_HEADERS(netdb.h)
  AC_CHECK_HEADERS(arpa/inet.h)
  AC_CHECK_HEADERS(sys/resource.h)
  AC_CHECK_HEADERS(sys/param.h)
 +AC_CHECK_HEADERS(kstat.h)
  
  # For ping library
  AC_CHECK_HEADERS(netinet/in_systm.h, [], [],
@@@ -151,23 -151,6 +153,23 @@@ AC_CHECK_HEADERS(netinet/icmp6.h, [], [
  # include <netinet/ip6.h>
  #endif
  ])
 +AC_CHECK_HEADERS(netinet/tcp.h, [], [],
 +[#if HAVE_STDINT_H
 +# include <stdint.h>
 +#endif
 +#if HAVE_SYS_TYPES_H
 +# include <sys/types.h>
 +#endif
 +#if HAVE_NETINET_IN_SYSTM_H
 +# include <netinet/in_systm.h>
 +#endif
 +#if HAVE_NETINET_IN_H
 +# include <netinet/in.h>
 +#endif
 +#if HAVE_NETINET_IP_H
 +# include <netinet/ip.h>
 +#endif
 +])
  AC_CHECK_HEADERS(netinet/udp.h, [], [],
  [#if HAVE_STDINT_H
  # include <stdint.h>
@@@ -208,7 -191,6 +210,7 @@@ AC_CHECK_HEADERS(mach/kern_return.h
  
  # For hddtemp module
  AC_CHECK_HEADERS(linux/major.h)
 +AC_CHECK_HEADERS(libgen.h)
  
  # For the apple_sensors module
  AC_CHECK_HEADERS(CoreFoundation/CoreFoundation.h)
@@@ -244,7 -226,7 +246,7 @@@ AC_CHECK_HEADERS(sys/swap.h
  AC_CHECK_HEADERS(utmp.h)
  AC_CHECK_HEADERS(utmpx.h)
  
 -# For traffic plugin
 +# For interface plugin
  AC_CHECK_HEADERS(ifaddrs.h)
  AC_CHECK_HEADERS(net/if.h, [], [],
  [
@@@ -349,10 -331,6 +351,10 @@@ AC_CHECK_HEADERS(netinet/if_ether.h, []
  #endif
  ])
  
 +# For the multimeter plugin
 +AC_CHECK_HEADERS(termios.h)
 +AC_CHECK_HEADERS(sys/ioctl.h)
 +
  #
  # Checking for libraries
  #
@@@ -407,104 -385,9 +409,104 @@@ AC_CHECK_FUNCS(getutent getutxent
  AC_CHECK_FUNCS(quotactl)
  AC_CHECK_FUNCS(getgrgid getpwuid)
  
 -# For traffic module
 +# For interface module
  AC_CHECK_FUNCS(getifaddrs)
  
 +# Check for NAN
 +nan_type="none"
 +if test "x$nan_type" = "xnone"; then
 +  AC_CACHE_CHECK([whether NAN is defined by default],
 +    [have_nan_default],
 +    AC_COMPILE_IFELSE(
 +      AC_LANG_PROGRAM(
 +      [[
 +#include <stdlib.h>
 +#include <math.h>
 +static float foo = NAN;
 +      ]],
 +      [[
 +       if (isnan (foo))
 +        return 0;
 +       else
 +      return 1;
 +      ]]),
 +      [have_nan_default="yes"],
 +      [have_nan_default="no"]
 +    )
 +  )
 +  if test "x$have_nan_default" = "xyes"
 +  then
 +   nan_type="default"
 +   AC_DEFINE(NAN_STATIC_DEFAULT, 1,
 +     [Define if NAN is defined by default and can initialize static variables.])
 +  fi
 +fi
 +if test "x$nan_type" = "xnone"; then
 +  AC_CACHE_CHECK([whether NAN is defined by __USE_ISOC99],
 +    [have_nan_isoc],
 +    AC_COMPILE_IFELSE(
 +      AC_LANG_PROGRAM(
 +      [[
 +#include <stdlib.h>
 +#define __USE_ISOC99 1
 +#include <math.h>
 +static float foo = NAN;
 +      ]],
 +      [[
 +       if (isnan (foo))
 +        return 0;
 +       else
 +      return 1;
 +      ]]),
 +      [have_nan_isoc="yes"],
 +      [have_nan_isoc="no"]
 +    )
 +  )
 +  if test "x$have_nan_isoc" = "xyes"
 +  then
 +   nan_type="isoc99"
 +   AC_DEFINE(NAN_STATIC_ISOC, 1,
 +     [Define if NAN is defined by __USE_ISOC99 and can initialize static variables.])
 +  fi
 +fi
 +if test "x$nan_type" = "xnone"; then
 +  AC_CACHE_CHECK([whether NAN can be defined by 0/0],
 +    [have_nan_zero],
 +    AC_RUN_IFELSE(
 +      AC_LANG_PROGRAM(
 +      [[
 +#include <stdlib.h>
 +#include <math.h>
 +#ifdef NAN
 +# undef NAN
 +#endif
 +#define NAN (0.0 / 0.0)
 +#ifndef isnan
 +# define isnan(f) ((f) != (f))
 +#endif
 +static float foo = NAN;
 +      ]],
 +      [[
 +       if (isnan (foo))
 +        return 0;
 +       else
 +      return 1;
 +      ]]),
 +      [have_nan_zero="yes"],
 +      [have_nan_zero="no"]
 +    )
 +  )
 +  if test "x$have_nan_zero" = "xyes"
 +  then
 +   nan_type="zero"
 +   AC_DEFINE(NAN_ZERO_ZERO, 1,
 +     [Define if NAN can be defined as (0.0 / 0.0)])
 +  fi
 +fi
 +if test "x$nan_type" = "xnone"; then
 +  AC_MSG_ERROR([Didn't find out how to statically initialize variables to NAN. Sorry.])
 +fi
 +
  # For mount interface
  #AC_CHECK_FUNCS(getfsent getvfsent)
  
@@@ -650,15 -533,6 +652,15 @@@ AC_CHECK_MEMBERS([struct udphdr.dest, s
  #endif
  ])
  
 +AC_CHECK_MEMBERS([kstat_io_t.nwritten, kstat_io_t.writes, kstat_io_t.nwrites, kstat_io_t.wtime],
 +      [],
 +      [],
 +      [
 +#if HAVE_KSTAT_H
 +# include <kstat.h>
 +#endif
 +      ])
 +
  AC_MSG_CHECKING([for kernel type ($host_os)])
  case $host_os in
        *linux*)
@@@ -985,53 -859,6 +987,53 @@@ AC_DEFINE_UNQUOTED(COLLECT_LIBMYSQL, [$
        [Wether or not to use mysql library])
  AM_CONDITIONAL(BUILD_WITH_LIBMYSQL, test "x$with_libmysql" = "xyes")
  
 +with_own_liboconfig="no"
 +liboconfig_LDFLAGS="$LDFLAGS"
 +liboconfig_CPPFLAGS="$CPPFLAGS"
 +AC_ARG_WITH(liboconfig, [AS_HELP_STRING([--with-liboconfig@<:@=PREFIX@:>@], [Path to liboconfig.])],
 +[
 +      if test "x$withval" != "xno" && test "x$withval" != "xyes"
 +      then
 +              if test -d "$withval/lib"
 +              then
 +                      liboconfig_LDFLAGS="$LDFLAGS -L$withval/lib"
 +              fi
 +              if test -d "$withval/include"
 +              then
 +                      liboconfig_CPPFLAGS="$CPPFLAGS -I$withval/include"
 +              fi
 +      fi
 +      if test "x$withval" = "xno"
 +      then
 +              AC_MSG_ERROR("liboconfig is required")
 +      fi
 +],
 +[
 +      with_liboconfig="yes"
 +])
 +
 +save_LDFLAGS="$LDFLAGS"
 +save_CPPFLAGS="$CPPFLAGS"
 +LDFLAGS="$liboconfig_LDFLAGS"
 +CPPFLAGS="$liboconfig_CPPFLAGS"
 +AC_CHECK_LIB(oconfig, oconfig_parse_fh,
 +[
 +      with_liboconfig="yes"
 +      with_own_liboconfig="no"
 +],
 +[
 +      with_liboconfig="yes"
 +      with_own_liboconfig="yes"
 +      LDFLAGS="$save_LDFLAGS"
 +      CPPFLAGS="$save_CPPFLAGS"
 +])
 +
 +AM_CONDITIONAL(BUILD_WITH_OWN_LIBOCONFIG, test "x$with_own_liboconfig" = "xyes")
 +if test "x$with_own_liboconfig" = "xyes"
 +then
 +      with_liboconfig="yes (shipped version)"
 +fi
 +
  #with_liboping="yes"
  with_own_liboping="no"
  liboping_LDFLAGS="$LDFLAGS"
@@@ -1121,63 -948,6 +1123,63 @@@ AC_DEFINE_UNQUOTED(COLLECT_LIBPCAP, [$c
        [Wether or not to use the pcap library])
  AM_CONDITIONAL(BUILD_WITH_LIBPCAP, test "x$with_libpcap" = "xyes")
  
 +perl_interpreter="perl"
 +AC_ARG_WITH(libperl, [AS_HELP_STRING([--with-libperl@<:@=PREFIX@:>@], [Path to libperl.])],
 +[
 +      if test "x$withval" != "xno" && test "x$withval" != "xyes"
 +      then
 +              LDFLAGS="$LDFLAGS -L$withval/lib"
 +              CPPFLAGS="$CPPFLAGS -I$withval/include"
 +              perl_interpreter="$withval/bin/perl"
 +              with_libperl="yes"
 +      fi
 +],
 +[
 +      with_libperl="yes"
 +])
 +if test "x$with_libperl" = "xyes"
 +then
 +  SAVE_CFLAGS=$CFLAGS
 +  SAVE_LDFLAGS=$LDFLAGS
 +  PERL_CFLAGS=`$perl_interpreter -MExtUtils::Embed -e ccopts`
 +  PERL_LDFLAGS=`$perl_interpreter -MExtUtils::Embed -e ldopts`
 +  CFLAGS="$CFLAGS $PERL_CFLAGS"
 +  LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
 +
 +  AC_CACHE_CHECK([for libperl],
 +    [have_libperl],
 +    AC_LINK_IFELSE(
 +      AC_LANG_PROGRAM(
 +      [[
 +#include <EXTERN.h>
 +#include <perl.h>
 +#include <XSUB.h>
 +      ]],
 +      [[
 +       PerlInterpreter *perl = NULL;
 +       Perl_load_module (perl, PERL_LOADMOD_NOIMPORT,
 +                       newSVpv ("Collectd::Plugin::FooBar", 24),
 +                       Nullsv);
 +      ]]),
 +      [have_libperl="yes"],
 +      [have_libperl="no"]
 +    )
 +  )
 +
 +  if test "x$have_libperl" = "xyes"
 +  then
 +        AC_DEFINE(HAVE_LIBPERL, 1, [Define if libperl is present and usable.])
 +        AC_SUBST(PERL_CFLAGS)
 +        AC_SUBST(PERL_LDFLAGS)
 +  else
 +        with_libperl="no"
 +  fi
 +
 +  CFLAGS=$SAVE_CFLAGS
 +  LDFLAGS=$SAVE_LDFLAGS
 +fi
 +AM_CONDITIONAL(BUILD_WITH_LIBPERL, test "x$with_libperl" = "xyes")
 +
  AC_ARG_WITH(libiptc, [AS_HELP_STRING([--with-libiptc@<:@=PREFIX@:>@], [Path to libiptc.])],
  [
        if test "x$withval" != "xno" && test "x$withval" != "xyes"
  fi
  AM_CONDITIONAL(BUILD_WITH_LIBIPTC, test "x$with_libiptc" = "xyes")
  
 -# Define `step' and `hearbeat' values..
 -declare -i collectd_step=10
 -declare -i collectd_heartbeat=25
 -AC_ARG_WITH(step, [AS_HELP_STRING([--with-step=SECONDS], [Interval in which plugins are queried.])],
 +AC_ARG_WITH(libupsclient, [AS_HELP_STRING([--with-libupsclient@<:@=PREFIX@:>@], [Path to libupsclient.])],
  [
 -      if test "x$withval" != "xno" -a "x$withval" != "xyes"
 +      if test "x$withval" != "xno" && test "x$withval" != "xyes"
        then
 -              declare -i tmp_collectd_step="$withval"
 -              if test $tmp_collectd_step -gt 0
 -              then
 -                      collectd_step=$tmp_collectd_step
 -                      let "collectd_heartbeat=$collectd_step*2"
 -              fi
 +              LDFLAGS="$LDFLAGS -L$withval/lib"
 +              CPPFLAGS="$CPPFLAGS -I$withval/include"
 +              with_libupsclient="yes"
        fi
 -], [])
 -AC_ARG_WITH(heartbeat, [AS_HELP_STRING([--with-heartbeat=SECONDS], [Heartbeat of the DS in generated RRD files.])],
 +],
  [
 -      if test "x$withval" != "xno" -a "x$withval" != "xyes"
 -      then
 -              declare -i tmp_collectd_heartbeat="$withval"
 -              if test $tmp_collectd_heartbeat -gt 0
 -              then
 -                      collectd_heartbeat=$tmp_collectd_heartbeat
 -              fi
 -      fi
 -], [])
 -
 -if test $collectd_step -ne 10
 +      with_libupsclient="yes"
 +])
 +if test "x$with_libupsclient" = "xyes"
  then
 -      AC_DEFINE_UNQUOTED(COLLECTD_STEP, "$collectd_step", [Interval in which plugins are queried.])
 +      AC_CHECK_LIB(upsclient, upscli_connect,
 +      [
 +              AC_DEFINE(HAVE_LIBUPSCLIENT, 1, [Define to 1 if you have the upsclient library (-lupsclient).])
 +      ], [with_libupsclient="no (libupsclient not found)"])
  fi
 -if test $collectd_heartbeat -ne 25
 +if test "x$with_libupsclient" = "xyes"
  then
 -      AC_DEFINE_UNQUOTED(COLLECTD_HEARTBEAT, "$collectd_heartbeat", [Interval in which plugins are queried.])
 +      AC_CHECK_HEADERS(upsclient.h,
 +      [
 +              AC_DEFINE(HAVE_UPSCLIENT_H, 1, [Define to 1 if you have the <upsclient.h> header file.])
 +      ], [with_libupsclient="no (upsclient.h not found)"])
  fi
 +AM_CONDITIONAL(BUILD_WITH_LIBUPSCLIENT, test "x$with_libupsclient" = "xyes")
  
  # Check for enabled/disabled features
  #
@@@ -1323,14 -1101,11 +1325,14 @@@ AC_COLLECTD([battery],   [disable], [mo
  AC_COLLECTD([cpu],       [disable], [module], [cpu usage statistics])
  AC_COLLECTD([cpufreq],   [disable], [module], [system cpu frequency statistics])
  AC_COLLECTD([disk],      [disable], [module], [disk/partition statistics])
 +AC_COLLECTD([csv],       [disable], [module], [csv output plugin])
  AC_COLLECTD([df],        [disable], [module], [df statistics])
  AC_COLLECTD([dns],       [disable], [module], [dns statistics])
  AC_COLLECTD([email],     [disable], [module], [email statistics])
 -AC_COLLECTD([quota],     [enable],  [module], [quota statistics (experimental)])
 +AC_COLLECTD([entropy],   [disable], [module], [entropy statistics])
 +AC_COLLECTD([exec],      [disable], [module], [exec of external programs])
  AC_COLLECTD([hddtemp],   [disable], [module], [hdd temperature statistics])
 +AC_COLLECTD([interface], [disable], [module], [interface statistics])
  AC_COLLECTD([iptables],  [disable], [module], [IPtables statistics])
  AC_COLLECTD([irq],       [disable], [module], [irq statistics])
  AC_COLLECTD([load],      [disable], [module], [system load statistics])
@@@ -1338,32 -1113,20 +1340,32 @@@ AC_COLLECTD([mbmon],     [disable], [mo
  AC_COLLECTD([memory],    [disable], [module], [memory statistics])
  AC_COLLECTD([multimeter],[disable], [module], [multimeter statistics])
  AC_COLLECTD([mysql],     [disable], [module], [mysql statistics])
 +AC_COLLECTD([network],   [disable], [module], [network functionality])
  AC_COLLECTD([nfs],       [disable], [module], [nfs statistics])
  AC_COLLECTD([ntpd],      [disable], [module], [ntpd statistics])
 +AC_COLLECTD([nut],       [disable], [module], [network UPS tools statistics])
 +AC_COLLECTD([perl],      [disable], [module], [embedded perl interpreter])
  AC_COLLECTD([ping],      [disable], [module], [ping statistics])
  AC_COLLECTD([processes], [disable], [module], [processes statistics])
  AC_COLLECTD([sensors],   [disable], [module], [lm_sensors statistics])
  AC_COLLECTD([serial],    [disable], [module], [serial statistics])
 +AC_COLLECTD([logfile],   [disable], [module], [logfile log facility])
  AC_COLLECTD([swap],      [disable], [module], [swap statistics])
 +AC_COLLECTD([syslog],    [disable], [module], [syslog log facility])
  AC_COLLECTD([tape],      [disable], [module], [tape statistics])
 -AC_COLLECTD([traffic],   [disable], [module], [system traffic statistics])
 +AC_COLLECTD([unixsock],  [disable], [module], [UNIX socket plugin])
  AC_COLLECTD([users],     [disable], [module], [user count statistics])
  AC_COLLECTD([vserver],   [disable], [module], [vserver statistics])
  AC_COLLECTD([wireless],  [disable], [module], [wireless link statistics])
  
 -AC_OUTPUT(Makefile src/Makefile src/collectd.conf src/libconfig/Makefile src/liboping/Makefile)
 +AC_OUTPUT(Makefile src/Makefile src/collectd.conf src/liboconfig/Makefile src/liboping/Makefile)
 +
 +if test "x$with_libperl" = "xyes"
 +then
 +      with_libperl="yes (version `perl -MConfig -e 'print $Config{version};'`)"
 +else
 +      enable_perl="no (needs libperl)"
 +fi
  
  cat <<EOF;
  
@@@ -1371,22 -1134,21 +1373,22 @@@ Configuration
    Libraries:
      libcurl . . . . . . $with_libcurl
      libiokit  . . . . . $with_libiokit
 -    liboping  . . . . . $with_liboping
 -    librrd  . . . . . . $with_rrdtool
 -    lm_sensors  . . . . $with_lm_sensors
 -    libstatgrab . . . . $with_libstatgrab
 +    libiptc . . . . . . $with_libiptc
      libkstat  . . . . . $with_kstat
      libmysql  . . . . . $with_libmysql
 +    liboconfig  . . . . $with_liboconfig
 +    liboping  . . . . . $with_liboping
      libpcap . . . . . . $with_libpcap
 -    libiptc . . . . . . $with_libiptc
 +    libperl . . . . . . $with_libperl
      libpthread  . . . . $with_libpthread
 +    librrd  . . . . . . $with_rrdtool
 +    libsensors  . . . . $with_lm_sensors
 +    libstatgrab . . . . $with_libstatgrab
 +    libupsclient  . . . $with_libupsclient
  
    Features:
 -    debug . . . . . . . $enable_debug
      daemon mode . . . . $enable_daemon
 -    step  . . . . . . . $collectd_step seconds
 -    heartbeat . . . . . $collectd_heartbeat seconds
 +    debug . . . . . . . $enable_debug
  
    Modules:
      apache  . . . . . . $enable_apache
      battery . . . . . . $enable_battery
      cpu . . . . . . . . $enable_cpu
      cpufreq . . . . . . $enable_cpufreq
 +    csv . . . . . . . . $enable_csv
      df  . . . . . . . . $enable_df
      disk  . . . . . . . $enable_disk
      dns . . . . . . . . $enable_dns
      email . . . . . . . $enable_email
 +    entropy . . . . . . $enable_entropy
 +    exec  . . . . . . . $enable_exec
      hddtemp . . . . . . $enable_hddtemp
 -    irq . . . . . . . . $enable_irq
 +    interface . . . . . $enable_interface
      iptables  . . . . . $enable_iptables
 +    irq . . . . . . . . $enable_irq
      load  . . . . . . . $enable_load
 +    logfile . . . . . . $enable_logfile
      mbmon . . . . . . . $enable_mbmon
      memory  . . . . . . $enable_memory
      multimeter  . . . . $enable_multimeter
      mysql . . . . . . . $enable_mysql
 +    network . . . . . . $enable_network
      nfs . . . . . . . . $enable_nfs
      ntpd  . . . . . . . $enable_ntpd
 +    nut . . . . . . . . $enable_nut
 +    perl  . . . . . . . $enable_perl
      ping  . . . . . . . $enable_ping
      processes . . . . . $enable_processes
      sensors . . . . . . $enable_sensors
      serial  . . . . . . $enable_serial
      swap  . . . . . . . $enable_swap
 +    syslog  . . . . . . $enable_syslog
      tape  . . . . . . . $enable_tape
 -    traffic . . . . . . $enable_traffic
 +    unixsock  . . . . . $enable_unixsock
      users . . . . . . . $enable_users
      vserver . . . . . . $enable_vserver
      wireless  . . . . . $enable_wireless
diff --combined src/collectd.h
@@@ -4,7 -4,8 +4,7 @@@
   *
   * This program is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License as published by the
 - * Free Software Foundation; either version 2 of the License, or (at your
 - * option) any later version.
 + * Free Software Foundation; only version 2 of the License is applicable.
   *
   * This program is distributed in the hope that it will be useful, but
   * WITHOUT ANY WARRANTY; without even the implied warranty of
@@@ -23,7 -24,7 +23,7 @@@
  #define COLLECTD_H
  
  #if HAVE_CONFIG_H
- # include <config.h>
+ # include "config.h"
  #endif
  
  #include <stdio.h>
@@@ -77,6 -78,9 +77,6 @@@
  #if HAVE_ERRNO_H
  # include <errno.h>
  #endif
 -#if HAVE_SYSLOG_H
 -# include <syslog.h>
 -#endif
  #if HAVE_LIMITS_H
  # include <limits.h>
  #endif
  # define assert(...) /* nop */
  #endif
  
 +#if NAN_STATIC_DEFAULT
 +# include <math.h>
 +/* #endif NAN_STATIC_DEFAULT*/
 +#elif NAN_STATIC_ISOC
 +# ifndef __USE_ISOC99
 +#  define DISABLE_ISOC99 1
 +#  define __USE_ISOC99 1
 +# endif /* !defined(__USE_ISOC99) */
 +# include <math.h>
 +# if DISABLE_ISOC99
 +#  undef DISABLE_ISOC99
 +#  undef __USE_ISOC99
 +# endif /* DISABLE_ISOC99 */
 +/* #endif NAN_STATIC_ISOC */
 +#elif NAN_ZERO_ZERO
 +# include <math.h>
 +# ifdef NAN
 +#  undef NAN
 +# endif
 +# define NAN (0.0 / 0.0)
 +# ifndef isnan
 +#  define isnan(f) ((f) != (f))
 +# endif /* !defined(isnan) */
 +#endif /* NAN_ZERO_ZERO */
 +
  #if HAVE_DIRENT_H
  # include <dirent.h>
  # define NAMLEN(dirent) strlen((dirent)->d_name)
  # include <sys/param.h>
  #endif
  
 -#if !HAVE_SYSLOG
 -# define syslog(...) /**/
 -# define openlog(...) /**/
 -# define closelog(...) /**/
 -#endif
 -
  #if HAVE_KSTAT_H
  # include <kstat.h>
  #endif
  #define PIDFILE PREFIX "/var/run/" PACKAGE_NAME ".pid"
  #endif
  
 -#ifndef LOGFILE
 -#define LOGFILE PREFIX"/var/log/"PACKAGE_NAME"/"PACKAGE_NAME".log"
 -#endif
 -
  #ifndef PLUGINDIR
  #define PLUGINDIR PREFIX "/lib/" PACKAGE_NAME
  #endif
  # define COLLECTD_GRP_NAME "collectd"
  #endif
  
 -#ifndef COLLECTD_STEP
 -#  define COLLECTD_STEP "10"
 -#endif
 -
 -#ifndef COLLECTD_HEARTBEAT
 -#  define COLLECTD_HEARTBEAT "25"
 -#endif
 -
 -#ifndef COLLECTD_ROWS
 -#  define COLLECTD_ROWS "1200"
 -#endif
 -
 -#ifndef COLLECTD_XFF
 -#  define COLLECTD_XFF 0.1
 -#endif
 -
 -extern time_t curtime;
 -
 -#ifdef HAVE_LIBRRD
 -extern int operating_mode;
 -#endif
 +#define STATIC_ARRAY_LEN(array) (sizeof (array) / sizeof ((array)[0]))
  
 -/* int main (int argc, char **argv); */
 +extern char hostname_g[];
 +extern int  interval_g;
  
  #endif /* COLLECTD_H */
diff --combined src/common.c
@@@ -1,41 -1,86 +1,45 @@@
  /**
   * collectd - src/common.c
 - * Copyright (C) 2005,2006  Florian octo Forster
 + * Copyright (C) 2005-2007  Florian octo Forster
   *
 - * This program is free software; you can redistribute it and/
 - * or modify it under the terms of the GNU General Public Li-
 - * cence as published by the Free Software Foundation; either
 - * version 2 of the Licence, or any later version.
 + * This program is free software; you can redistribute it and/or modify it
 + * under the terms of the GNU General Public License as published by the
 + * Free Software Foundation; only version 2 of the License is applicable.
   *
 - * This program is distributed in the hope that it will be use-
 - * ful, but WITHOUT ANY WARRANTY; without even the implied war-
 - * ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 - * See the GNU General Public Licence for more details.
 + * This program is distributed in the hope that it will be useful, but
 + * WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * General Public License for more details.
   *
 - * You should have received a copy of the GNU General Public
 - * Licence along with this program; if not, write to the Free
 - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
 - * USA.
 + * You should have received a copy of the GNU General Public License along
 + * with this program; if not, write to the Free Software Foundation, Inc.,
 + * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
   *
   * Authors:
   *   Florian octo Forster <octo at verplant.org>
   *   Niki W. Waibel <niki.waibel@gmx.net>
  **/
  
+ #if HAVE_CONFIG_H
+ # include "config.h"
+ #endif
  #include "common.h"
 -#include "utils_debug.h"
 +#include "plugin.h"
  
  #ifdef HAVE_MATH_H
  #  include <math.h>
  #endif
  
 -extern int operating_mode;
 +/* for ntohl and htonl */
 +#if HAVE_ARPA_INET_H
 +# include <arpa/inet.h>
 +#endif
  
  #ifdef HAVE_LIBKSTAT
  extern kstat_ctl_t *kc;
  #endif
  
 -#ifdef HAVE_LIBRRD
 -#if 0
 -static char *rra_def[] =
 -{
 -              "RRA:AVERAGE:0.0:1:1500",
 -              "RRA:AVERAGE:0.2:6:1500",
 -              "RRA:AVERAGE:0.1:180:1680",
 -              "RRA:AVERAGE:0.1:2160:1520",
 -              "RRA:MIN:0.0:1:1500",
 -              "RRA:MIN:0.2:6:1500",
 -              "RRA:MIN:0.1:180:1680",
 -              "RRA:MIN:0.1:2160:1520",
 -              "RRA:MAX:0.0:1:1500",
 -              "RRA:MAX:0.2:6:1500",
 -              "RRA:MAX:0.1:180:1680",
 -              "RRA:MAX:0.1:2160:1520",
 -              NULL
 -};
 -static int rra_num = 12;
 -#endif
 -
 -static int rra_timespans[] =
 -{
 -      3600,
 -      86400,
 -      604800,
 -      2678400,
 -      31622400,
 -      0
 -};
 -static int rra_timespans_num = 5;
 -
 -static char *rra_types[] =
 -{
 -      "AVERAGE",
 -      "MIN",
 -      "MAX",
 -      NULL
 -};
 -static int rra_types_num = 3;
 -#endif /* HAVE_LIBRRD */
 -
  void sstrncpy (char *d, const char *s, int len)
  {
        strncpy (d, s, len);
@@@ -51,29 -96,20 +55,29 @@@ char *sstrdup (const char *s
  
        if((r = strdup (s)) == NULL)
        {
 -              DBG ("Not enough memory.");
 +              DEBUG ("Not enough memory.");
                exit(3);
        }
  
        return (r);
  }
  
 +/* Don't use the return value of `strerror_r', because the GNU-people got
 + * inventive there.. -octo */
 +char *sstrerror (int errnum, char *buf, size_t buflen)
 +{
 +      buf[0] = '\0';
 +      strerror_r (errnum, buf, buflen);
 +      return (buf);
 +} /* char *sstrerror */
 +
  void *smalloc (size_t size)
  {
        void *r;
  
        if ((r = malloc (size)) == NULL)
        {
 -              DBG("Not enough memory.");
 +              DEBUG("Not enough memory.");
                exit(3);
        }
  
@@@ -114,7 -150,7 +118,7 @@@ ssize_t sread (int fd, void *buf, size_
  
                if (status == 0)
                {
 -                      DBG ("Received EOF from fd %i. "
 +                      DEBUG ("Received EOF from fd %i. "
                                        "Closing fd and returning error.",
                                        fd);
                        close (fd);
@@@ -161,12 -197,10 +165,12 @@@ int strsplit (char *string, char **fiel
  {
        size_t i;
        char *ptr;
 +      char *saveptr;
  
        i = 0;
        ptr = string;
 -      while ((fields[i] = strtok (ptr, " \t")) != NULL)
 +      saveptr = NULL;
 +      while ((fields[i] = strtok_r (ptr, " \t", &saveptr)) != NULL)
        {
                ptr = NULL;
                i++;
@@@ -290,7 -324,7 +294,7 @@@ int timeval_sub_timespec (struct timeva
        return (0);
  }
  
 -static int check_create_dir (const char *file_orig)
 +int check_create_dir (const char *file_orig)
  {
        struct stat statbuf;
  
        char *fields[16];
        int   fields_num;
        char *ptr;
 +      char *saveptr;
        int   last_is_file = 1;
 +      int   path_is_absolute = 0;
        int   len;
        int   i;
  
         */
        if (file_orig[len - 1] == '/')
                last_is_file = 0;
 +      if (file_orig[0] == '/')
 +              path_is_absolute = 1;
  
        /*
 -       * Create a copy for `strtok' to destroy
 +       * Create a copy for `strtok_r' to destroy
         */
        strncpy (file_copy, file_orig, 512);
        file_copy[511] = '\0';
         * remove leading and trailing slashes..
         */
        ptr = file_copy;
 +      saveptr = NULL;
        fields_num = 0;
 -      while ((fields[fields_num] = strtok (ptr, "/")) != NULL)
 +      while ((fields[fields_num] = strtok_r (ptr, "/", &saveptr)) != NULL)
        {
                ptr = NULL;
                fields_num++;
                 */
                if (fields[i][0] == '.')
                {
 -                      syslog (LOG_ERR, "Cowardly refusing to create a directory that begins with a `.' (dot): `%s'", file_orig);
 +                      ERROR ("Cowardly refusing to create a directory that begins with a `.' (dot): `%s'", file_orig);
                        return (-2);
                }
  
                /*
                 * Join the components together again
                 */
 -              if (strjoin (dir, dir_len, fields, i + 1, "/") < 0)
 +              dir[0] = '/';
 +              if (strjoin (dir + path_is_absolute, dir_len - path_is_absolute,
 +                                      fields, i + 1, "/") < 0)
                {
 -                      syslog (LOG_ERR, "strjoin failed: `%s', component #%i", file_orig, i);
 +                      ERROR ("strjoin failed: `%s', component #%i", file_orig, i);
                        return (-1);
                }
  
                        {
                                if (mkdir (dir, 0755) == -1)
                                {
 -                                      syslog (LOG_ERR, "mkdir (%s): %s", dir, strerror (errno));
 +                                      char errbuf[1024];
 +                                      ERROR ("mkdir (%s): %s", dir,
 +                                                      sstrerror (errno,
 +                                                              errbuf, sizeof (errbuf)));
                                        return (-1);
                                }
                        }
                        else
                        {
 -                              syslog (LOG_ERR, "stat (%s): %s", dir, strerror (errno));
 +                              char errbuf[1024];
 +                              ERROR ("stat (%s): %s", dir,
 +                                              sstrerror (errno, errbuf,
 +                                                      sizeof (errbuf)));
                                return (-1);
                        }
                }
                else if (!S_ISDIR (statbuf.st_mode))
                {
 -                      syslog (LOG_ERR, "stat (%s): Not a directory!", dir);
 +                      ERROR ("stat (%s): Not a directory!", dir);
                        return (-1);
                }
        }
        return (0);
  }
  
 -/* * * * *
 - * Magic *
 - * * * * */
 -#if HAVE_LIBRRD
 -static int rra_get (char ***ret)
 -{
 -      static char **rra_def = NULL;
 -      static int rra_num = 0;
 -
 -      int rra_max = rra_timespans_num * rra_types_num;
 -
 -      int step;
 -      int rows;
 -      int span;
 -
 -      int cdp_num;
 -      int cdp_len;
 -      int i, j;
 -
 -      char buffer[64];
 -
 -      if ((rra_num != 0) && (rra_def != NULL))
 -      {
 -              *ret = rra_def;
 -              return (rra_num);
 -      }
 -
 -      if ((rra_def = (char **) malloc ((rra_max + 1) * sizeof (char *))) == NULL)
 -              return (-1);
 -      memset (rra_def, '\0', (rra_max + 1) * sizeof (char *));
 -
 -      step = atoi (COLLECTD_STEP);
 -      rows = atoi (COLLECTD_ROWS);
 -
 -      if ((step <= 0) || (rows <= 0))
 -      {
 -              *ret = NULL;
 -              return (-1);
 -      }
 -
 -      cdp_len = 0;
 -      for (i = 0; i < rra_timespans_num; i++)
 -      {
 -              span = rra_timespans[i];
 -
 -              if ((span / step) < rows)
 -                      continue;
 -
 -              if (cdp_len == 0)
 -                      cdp_len = 1;
 -              else
 -                      cdp_len = (int) floor (((double) span) / ((double) (rows * step)));
 -
 -              cdp_num = (int) ceil (((double) span) / ((double) (cdp_len * step)));
 -
 -              for (j = 0; j < rra_types_num; j++)
 -              {
 -                      if (rra_num >= rra_max)
 -                              break;
 -
 -                      if (snprintf (buffer, sizeof(buffer), "RRA:%s:%3.1f:%u:%u",
 -                                              rra_types[j], COLLECTD_XFF,
 -                                              cdp_len, cdp_num) >= sizeof (buffer))
 -                      {
 -                              syslog (LOG_ERR, "rra_get: Buffer would have been truncated.");
 -                              continue;
 -                      }
 -
 -                      rra_def[rra_num++] = sstrdup (buffer);
 -              }
 -      }
 -
 -#if COLLECT_DEBUG
 -      DBG ("rra_num = %i", rra_num);
 -      for (i = 0; i < rra_num; i++)
 -              DBG ("  %s", rra_def[i]);
 -#endif
 -
 -      *ret = rra_def;
 -      return (rra_num);
 -}
 -#endif /* HAVE_LIBRRD */
 -
 -static int log_create_file (char *filename, char **ds_def, int ds_num)
 -{
 -      FILE *log;
 -      int i;
 -
 -      if (check_create_dir (filename))
 -              return (-1);
 -
 -      log = fopen (filename, "w");
 -      if (log == NULL)
 -      {
 -              syslog (LOG_WARNING, "Failed to create %s: %s", filename,
 -                              strerror(errno));
 -              return (-1);
 -      }
 -
 -      fprintf (log, "epoch");
 -      for (i = 0; i < ds_num; i++)
 -      {
 -              char *name;
 -              char *tmp;
 -
 -              name = strchr (ds_def[i], ':');
 -              if (name == NULL)
 -              {
 -                      syslog (LOG_WARNING, "Invalid DS definition '%s' for %s",
 -                                      ds_def[i], filename);
 -                      fclose(log);
 -                      remove(filename);
 -                      return (-1);
 -              }
 -
 -              name += 1;
 -              tmp = strchr (name, ':');
 -              if (tmp == NULL)
 -              {
 -                      syslog (LOG_WARNING, "Invalid DS definition '%s' for %s",
 -                                      ds_def[i], filename);
 -                      fclose(log);
 -                      remove(filename);
 -                      return (-1);
 -              }
 -
 -              /* The `%.*s' is needed because there is no null-byte behind
 -               * the name. */
 -              fprintf(log, ",%.*s", (int) (tmp - name), name);
 -      }
 -      fprintf(log, "\n");
 -      fclose(log);
 -
 -      return 0;
 -}
 -
 -static int log_update_file (char *host, char *file, char *values,
 -              char **ds_def, int ds_num)
 -{
 -      char *tmp;
 -      FILE *fp;
 -      struct stat statbuf;
 -      char full_file[1024];
 -
 -      /* Cook the values a bit: Substitute colons with commas */
 -      strsubstitute (values, ':', ',');
 -
 -      /* host == NULL => local mode */
 -      if (host != NULL)
 -      {
 -              if (snprintf (full_file, 1024, "%s/%s", host, file) >= 1024)
 -                      return (-1);
 -      }
 -      else
 -      {
 -              if (snprintf (full_file, 1024, "%s", file) >= 1024)
 -                      return (-1);
 -      }
 -
 -      strncpy (full_file, file, 1024);
 -
 -      tmp = full_file + strlen (full_file) - 4;
 -      assert ((tmp != NULL) && (tmp > full_file));
 -
 -      /* Change the filename for logfiles. */
 -      if (strncmp (tmp, ".rrd", 4) == 0)
 -      {
 -              time_t now;
 -              struct tm *tm;
 -
 -              /* TODO: Find a way to minimize the calls to `localtime', since
 -               * they are pretty expensive.. */
 -              now = time (NULL);
 -              tm = localtime (&now);
 -
 -              strftime (tmp, 1024 - (tmp - full_file), "-%Y-%m-%d", tm);
 -
 -              /* `localtime(3)' returns a pointer to static data,
 -               * therefore the pointer may not be free'd. */
 -      }
 -      else
 -              DBG ("The filename ends with `%s' which is unexpected.", tmp);
 -
 -      if (stat (full_file, &statbuf) == -1)
 -      {
 -              if (errno == ENOENT)
 -              {
 -                      if (log_create_file (full_file, ds_def, ds_num))
 -                              return (-1);
 -              }
 -              else
 -              {
 -                      syslog (LOG_ERR, "stat %s: %s", full_file, strerror (errno));
 -                      return (-1);
 -              }
 -      }
 -      else if (!S_ISREG (statbuf.st_mode))
 -      {
 -              syslog (LOG_ERR, "stat %s: Not a regular file!", full_file);
 -              return (-1);
 -      }
 -
 -
 -      fp = fopen (full_file, "a");
 -      if (fp == NULL)
 -      {
 -              syslog (LOG_WARNING, "Failed to append to %s: %s", full_file,
 -                              strerror(errno));
 -              return (-1);
 -      }
 -      fprintf(fp, "%s\n", values);
 -      fclose(fp);
 -
 -      return (0);
 -} /* int log_update_file */
 -
 -#if HAVE_LIBRRD
 -static int rrd_create_file (char *filename, char **ds_def, int ds_num)
 -{
 -      char **argv;
 -      int argc;
 -      char **rra_def;
 -      int rra_num;
 -      int i, j;
 -      int status = 0;
 -
 -      if (check_create_dir (filename))
 -              return (-1);
 -
 -      if ((rra_num = rra_get (&rra_def)) < 1)
 -      {
 -              syslog (LOG_ERR, "rra_create failed: Could not calculate RRAs");
 -              return (-1);
 -      }
 -
 -      argc = ds_num + rra_num + 4;
 -
 -      if ((argv = (char **) malloc (sizeof (char *) * (argc + 1))) == NULL)
 -      {
 -              syslog (LOG_ERR, "rrd_create failed: %s", strerror (errno));
 -              return (-1);
 -      }
 -
 -      argv[0] = "create";
 -      argv[1] = filename;
 -      argv[2] = "-s";
 -      argv[3] = COLLECTD_STEP;
 -
 -      j = 4;
 -      for (i = 0; i < ds_num; i++)
 -              argv[j++] = ds_def[i];
 -      for (i = 0; i < rra_num; i++)
 -              argv[j++] = rra_def[i];
 -      argv[j] = NULL;
 -
 -      optind = 0; /* bug in librrd? */
 -      rrd_clear_error ();
 -      if (rrd_create (argc, argv) == -1)
 -      {
 -              syslog (LOG_ERR, "rrd_create failed: %s: %s", filename, rrd_get_error ());
 -              status = -1;
 -      }
 -
 -      free (argv);
 -
 -      return (status);
 -}
 -#endif /* HAVE_LIBRRD */
 -
 -int rrd_update_file (char *host, char *file, char *values,
 -              char **ds_def, int ds_num)
 -{
 -#if HAVE_LIBRRD
 -      struct stat statbuf;
 -      char full_file[1024];
 -      char *argv[4] = { "update", full_file, values, NULL };
 -#endif /* HAVE_LIBRRD */
 -
 -      /* I'd rather have a function `common_update_file' to make this
 -       * decission, but for that we'd need to touch all plugins.. */
 -      if (operating_mode == MODE_LOG)
 -              return (log_update_file (host, file, values,
 -                                      ds_def, ds_num));
 -
 -#if HAVE_LIBRRD
 -      /* host == NULL => local mode */
 -      if (host != NULL)
 -      {
 -              if (snprintf (full_file, 1024, "%s/%s", host, file) >= 1024)
 -                      return (-1);
 -      }
 -      else
 -      {
 -              if (snprintf (full_file, 1024, "%s", file) >= 1024)
 -                      return (-1);
 -      }
 -
 -      if (stat (full_file, &statbuf) == -1)
 -      {
 -              if (errno == ENOENT)
 -              {
 -                      if (rrd_create_file (full_file, ds_def, ds_num))
 -                              return (-1);
 -              }
 -              else
 -              {
 -                      syslog (LOG_ERR, "stat %s: %s", full_file, strerror (errno));
 -                      return (-1);
 -              }
 -      }
 -      else if (!S_ISREG (statbuf.st_mode))
 -      {
 -              syslog (LOG_ERR, "stat %s: Not a regular file!", full_file);
 -              return (-1);
 -      }
 -
 -      optind = 0; /* bug in librrd? */
 -      rrd_clear_error ();
 -      if (rrd_update (3, argv) == -1)
 -      {
 -              syslog (LOG_WARNING, "rrd_update failed: %s: %s", full_file, rrd_get_error ());
 -              return (-1);
 -      }
 -      return (0);
 -/* #endif HAVE_LIBRRD */
 -
 -#else
 -      syslog (LOG_ERR, "`rrd_update_file' was called, but collectd isn't linked against librrd!");
 -      return (-1);
 -#endif
 -}
 -
  #ifdef HAVE_LIBKSTAT
  int get_kstat (kstat_t **ksp_ptr, char *module, int instance, char *name)
  {
        {
                if ((*ksp_ptr = kstat_lookup (kc, module, instance, name)) == NULL)
                {
 -                      syslog (LOG_ERR, "Cound not find kstat %s", ident);
 +                      ERROR ("Cound not find kstat %s", ident);
                        return (-1);
                }
  
                if ((*ksp_ptr)->ks_type != KSTAT_TYPE_NAMED)
                {
 -                      syslog (LOG_WARNING, "kstat %s has wrong type", ident);
 +                      WARNING ("kstat %s has wrong type", ident);
                        *ksp_ptr = NULL;
                        return (-1);
                }
  
        if (kstat_read (kc, *ksp_ptr, NULL) == -1)
        {
 -              syslog (LOG_WARNING, "kstat %s could not be read", ident);
 +              WARNING ("kstat %s could not be read", ident);
                return (-1);
        }
  
        if ((*ksp_ptr)->ks_type != KSTAT_TYPE_NAMED)
        {
 -              syslog (LOG_WARNING, "kstat %s has wrong type", ident);
 +              WARNING ("kstat %s has wrong type", ident);
                return (-1);
        }
  
@@@ -487,63 -840,8 +491,63 @@@ long long get_kstat_value (kstat_t *ksp
        else if (kn->data_type == KSTAT_DATA_UINT64)
                retval = (long long) kn->value.ui64; /* XXX: Might overflow! */
        else
 -              syslog (LOG_WARNING, "get_kstat_value: Not a numeric value: %s", name);
 +              WARNING ("get_kstat_value: Not a numeric value: %s", name);
                 
        return (retval);
  }
  #endif /* HAVE_LIBKSTAT */
 +
 +unsigned long long ntohll (unsigned long long n)
 +{
 +#if __BYTE_ORDER == __BIG_ENDIAN
 +      return (n);
 +#else
 +      return (((unsigned long long) ntohl (n)) << 32) + ntohl (n >> 32);
 +#endif
 +} /* unsigned long long ntohll */
 +
 +unsigned long long htonll (unsigned long long n)
 +{
 +#if __BYTE_ORDER == __BIG_ENDIAN
 +      return (n);
 +#else
 +      return (((unsigned long long) htonl (n)) << 32) + htonl (n >> 32);
 +#endif
 +} /* unsigned long long htonll */
 +
 +int format_name (char *ret, int ret_len,
 +              const char *hostname,
 +              const char *plugin, const char *plugin_instance,
 +              const char *type, const char *type_instance)
 +{
 +      int  status;
 +
 +      assert (plugin != NULL);
 +      assert (type != NULL);
 +
 +      if ((plugin_instance == NULL) || (strlen (plugin_instance) == 0))
 +      {
 +              if ((type_instance == NULL) || (strlen (type_instance) == 0))
 +                      status = snprintf (ret, ret_len, "%s/%s/%s",
 +                                      hostname, plugin, type);
 +              else
 +                      status = snprintf (ret, ret_len, "%s/%s/%s-%s",
 +                                      hostname, plugin, type,
 +                                      type_instance);
 +      }
 +      else
 +      {
 +              if ((type_instance == NULL) || (strlen (type_instance) == 0))
 +                      status = snprintf (ret, ret_len, "%s/%s-%s/%s",
 +                                      hostname, plugin, plugin_instance,
 +                                      type);
 +              else
 +                      status = snprintf (ret, ret_len, "%s/%s-%s/%s-%s",
 +                                      hostname, plugin, plugin_instance,
 +                                      type, type_instance);
 +      }
 +
 +      if ((status < 1) || (status >= ret_len))
 +              return (-1);
 +      return (0);
 +} /* int format_name */
diff --combined src/utils_ignorelist.c
   *     return;
   **/
  
+ #if HAVE_CONFIG_H
+ # include "config.h"
+ #endif
  #include "common.h"
 -#include "utils_debug.h"
 +#include "plugin.h"
  #include "utils_ignorelist.h"
  
  /*
@@@ -94,7 -98,7 +98,7 @@@ static int ignorelist_append_regex(igno
        /* create buffer */
        if ((regtemp = malloc(sizeof(regex_t))) == NULL)
        {
 -              syslog (LOG_ERR, "cannot allocate new config entry");
 +              ERROR ("cannot allocate new config entry");
                return (1);
        }
        memset (regtemp, '\0', sizeof(regex_t));
                {
                        fprintf (stderr, "Cannot compile regex %s: %i/%s",
                                        entry, rcompile, regerr);
 -                      syslog (LOG_ERR, "Cannot compile regex %s: %i/%s",
 +                      ERROR ("Cannot compile regex %s: %i/%s",
                                        entry, rcompile, regerr);
                }
                else
                {
                        fprintf (stderr, "Cannot compile regex %s: %i",
                                        entry, rcompile);
 -                      syslog (LOG_ERR, "Cannot compile regex %s: %i",
 +                      ERROR ("Cannot compile regex %s: %i",
                                        entry, rcompile);
                }
  
                regfree (regtemp);
                return (1);
        }
 -      DBG("regex compiled: %s - %i", entry, rcompile);
 +      DEBUG("regex compiled: %s - %i", entry, rcompile);
  
        /* create new entry */
        if ((new = malloc(sizeof(ignorelist_item_t))) == NULL)
        {
 -              syslog (LOG_ERR, "cannot allocate new config entry");
 +              ERROR ("cannot allocate new config entry");
                regfree (regtemp);
                return (1);
        }
@@@ -153,7 -157,7 +157,7 @@@ static int ignorelist_append_string(ign
        /* create new entry */
        if ((new = malloc(sizeof(ignorelist_item_t))) == NULL )
        {
 -              syslog (LOG_ERR, "cannot allocate new entry");
 +              ERROR ("cannot allocate new entry");
                return (1);
        }
        memset (new, '\0', sizeof(ignorelist_item_t));
@@@ -213,7 -217,7 +217,7 @@@ ignorelist_t *ignorelist_create (int in
  
        /* smalloc exits if it failes */
        il = (ignorelist_t *) smalloc (sizeof (ignorelist_t));
 -      DBG("Ignorelist created 0x%p, default is %s",
 +      DEBUG("Ignorelist created 0x%p, default is %s",
                        (void *) il,
                        invert ? "collect" : "ignore");
  
@@@ -236,7 -240,7 +240,7 @@@ void ignorelist_free (ignorelist_t *il
        ignorelist_item_t *this;
        ignorelist_item_t *next;
  
 -      DBG ("(il = 0x%p)", (void *) il);
 +      DEBUG ("(il = 0x%p)", (void *) il);
  
        if (il == NULL)
                return;
@@@ -270,7 -274,7 +274,7 @@@ void ignorelist_set_invert (ignorelist_
  {
        if (il == NULL)
        {
 -              DBG("ignore call with ignorelist_t == NULL");
 +              DEBUG("ignore call with ignorelist_t == NULL");
                return;
        }
  
@@@ -288,7 -292,7 +292,7 @@@ int ignorelist_add (ignorelist_t *il, c
  
        if (il == NULL)
        {
 -              DBG ("add called with ignorelist_t == NULL");
 +              DEBUG ("add called with ignorelist_t == NULL");
                return (1);
        }
  
        /* append nothing */
        if (entry_len == 0)
        {
 -              DBG("not appending: empty entry");
 +              DEBUG("not appending: empty entry");
                return (1);
        }
  
                memset (entry_copy, '\0', entry_len);
                strncpy (entry_copy, entry + 1, entry_len - 2);
  
 -              DBG("I'm about to add regex entry: %s", entry_copy);
 +              DEBUG("I'm about to add regex entry: %s", entry_copy);
                ret = ignorelist_append_regex(il, entry_copy);
                sfree (entry_copy);
        }
        else
  #endif
        {
 -              DBG("to add entry: %s", entry);
 +              DEBUG("to add entry: %s", entry);
                ret = ignorelist_append_string(il, entry);
        }
  
diff --combined src/utils_mount.c
@@@ -21,7 -21,9 +21,9 @@@
   *   Niki W. Waibel <niki.waibel@gmx.net>
  **/
  
+ #if HAVE_CONFIG_H
+ # include "config.h"
+ #endif
  
  #include "common.h"
  #if HAVE_XFS_XQM_H
@@@ -30,7 -32,7 +32,7 @@@
  #define XFS_SUPER_MAGIC2_STR "BSFX"
  #endif
  
 -#include "utils_debug.h"
 +#include "plugin.h"
  #include "utils_mount.h"
  
  #if HAVE_GETVFSSTAT
@@@ -332,7 -334,7 +334,7 @@@ get_spec_by_uuid(const char *s
        return get_spec_by_x(UUID, uuid);
  
        bad_uuid:
 -              DBG("Found an invalid UUID: %s", s);
 +              DEBUG("Found an invalid UUID: %s", s);
        return NULL;
  }
  
@@@ -351,12 -353,12 +353,12 @@@ static char *get_device_name(const cha
        }
        else if (strncmp (optstr, "UUID=", 5) == 0)
        {
 -              DBG ("TODO: check UUID= code!");
 +              DEBUG ("TODO: check UUID= code!");
                rc = get_spec_by_uuid (optstr + 5);
        }
        else if (strncmp (optstr, "LABEL=", 6) == 0)
        {
 -              DBG ("TODO: check LABEL= code!");
 +              DEBUG ("TODO: check LABEL= code!");
                rc = get_spec_by_volume_label (optstr + 6);
        }
        else
  
        if(!rc)
        {
 -              DBG ("Error checking device name: optstr = %s", optstr);
 +              DEBUG ("Error checking device name: optstr = %s", optstr);
        }
        return rc;
  }
@@@ -381,9 -383,7 +383,9 @@@ static cu_mount_t *cu_mount_listmntent 
  
        struct tabmntent *mntlist;
        if(listmntent(&mntlist, COLLECTD_MNTTAB, NULL, NULL) < 0) {
 -              DBG("calling listmntent() failed: %s", strerror(errno));
 +              char errbuf[1024];
 +              DEBUG("calling listmntent() failed: %s",
 +                              sstrerror (errno, errbuf, sizeof (errbuf)));
        }
  
        for(p = mntlist; p; p = p->next) {
                if(loop == NULL) {   /* no loop= mount */
                        device = get_device_name(mnt->mnt_fsname);
                        if(device == NULL) {
 -                              DBG("can't get devicename for fs (%s) %s (%s)"
 +                              DEBUG("can't get devicename for fs (%s) %s (%s)"
                                        ": ignored", mnt->mnt_type,
                                        mnt->mnt_dir, mnt->mnt_fsname);
                                continue;
@@@ -452,9 -452,7 +454,9 @@@ static cu_mount_t *cu_mount_getfsstat (
        /* Get the number of mounted file systems */
        if ((bufsize = CMD_STATFS (NULL, 0, FLAGS_STATFS)) < 1)
        {
 -              DBG ("getv?fsstat failed: %s", strerror (errno));
 +              char errbuf[1024];
 +              DEBUG ("getv?fsstat failed: %s",
 +                              sstrerror (errno, errbuf, sizeof (errbuf)));
                return (NULL);
        }
  
         * manpage.. -octo */
        if ((num = CMD_STATFS (buf, bufsize * sizeof (STRUCT_STATFS), FLAGS_STATFS)) < 1)
        {
 -              DBG ("getv?fsstat failed: %s", strerror (errno));
 +              char errbuf[1024];
 +              DEBUG ("getv?fsstat failed: %s",
 +                              sstrerror (errno, errbuf, sizeof (errbuf)));
                free (buf);
                return (NULL);
        }
@@@ -518,13 -514,11 +520,13 @@@ static cu_mount_t *cu_mount_gen_getmnte
        cu_mount_t *last  = NULL;
        cu_mount_t *new   = NULL;
  
 -      DBG ("(void); COLLECTD_MNTTAB = %s", COLLECTD_MNTTAB);
 +      DEBUG ("(void); COLLECTD_MNTTAB = %s", COLLECTD_MNTTAB);
  
        if ((fp = fopen (COLLECTD_MNTTAB, "r")) == NULL)
        {
 -              syslog (LOG_ERR, "fopen (%s): %s", COLLECTD_MNTTAB, strerror (errno));
 +              char errbuf[1024];
 +              ERROR ("fopen (%s): %s", COLLECTD_MNTTAB,
 +                              sstrerror (errno, errbuf, sizeof (errbuf)));
                return (NULL);
        }
  
@@@ -575,13 -569,11 +577,13 @@@ static cu_mount_t *cu_mount_getmntent (
        cu_mount_t *last  = NULL;
        cu_mount_t *new   = NULL;
  
 -      DBG ("(void); COLLECTD_MNTTAB = %s", COLLECTD_MNTTAB);
 +      DEBUG ("(void); COLLECTD_MNTTAB = %s", COLLECTD_MNTTAB);
  
        if ((fp = setmntent (COLLECTD_MNTTAB, "r")) == NULL)
        {
 -              syslog (LOG_ERR, "setmntent (%s): %s", COLLECTD_MNTTAB, strerror (errno));
 +              char errbuf[1024];
 +              ERROR ("setmntent (%s): %s", COLLECTD_MNTTAB,
 +                              sstrerror (errno, errbuf, sizeof (errbuf)));
                return (NULL);
        }
  
                new->device      = get_device_name (new->options);
                new->next        = NULL;
  
 -              DBG ("new = {dir = %s, spec_device = %s, type = %s, options = %s, device = %s}",
 +              DEBUG ("new = {dir = %s, spec_device = %s, type = %s, options = %s, device = %s}",
                                new->dir, new->spec_device, new->type, new->options, new->device);
  
                /* Append to list */
  
        endmntent (fp);
  
 -      DBG ("return (0x%p)", (void *) first);
 +      DEBUG ("return (0x%p)", (void *) first);
  
        return (first);
  }
@@@ -680,7 -672,7 +682,7 @@@ void cu_mount_freelist (cu_mount_t *lis
        cu_mount_t *this;
        cu_mount_t *next;
  
 -      DBG ("(list = 0x%p)", (void *) list);
 +      DEBUG ("(list = 0x%p)", (void *) list);
  
        for (this = list; this != NULL; this = next)
        {