Merge branch 'collectd-3.10'
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Thu, 21 Dec 2006 19:40:49 +0000 (20:40 +0100)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Thu, 21 Dec 2006 19:40:49 +0000 (20:40 +0100)
Conflicts:

ChangeLog

1  2 
ChangeLog
configure.in
src/collectd.c

diff --combined ChangeLog
+++ b/ChangeLog
@@@ -1,27 -1,8 +1,32 @@@
 +pending, Version 3.11.0
 +      * collectd: The new command line option `-P' makes it easier for
 +        distributors to change the location of PID-files.
 +      * collectd: The daemon shuts down faster now which makes it easier to
 +        write init.d-scripts for it.
 +      * apache plugin: Increase the buffersize to 16k, because the 4k buffer
 +        caused problems every now and then.
 +      * df plugin: New config options allow to ignore certain mountpoints,
 +        filesystem types or devices.
 +      * dns plugin: The new dns plugin uses `libpcap' to capture DNS traffic
 +        and interprets it. It collects traffic as well as qtype, opcode and
 +        rcode counts.
 +      * email plugin: Sebastian Harl has contributed this plugin which
 +        counts received mails in categories (e. g. ham, spam, virus), spam
 +        score (as given by SpamAssassin) and check types.
 +      * processes plugin: Collect detailed statistics for configured
 +        processes, that's process and thread count, CPU usage, resident
 +        segment size and pagefaults.
 +      * multimeter plugin: Peter Holik contributed a new plugin which
 +        queries multimeters.
 +      * sensors plugin: Lubos Stanek has put much effort into improving this
 +        plugin, including `extended naming', collection of voltage values
 +        and the possibility to ignore certain values.
 +
+ 2006-12-21, Version 3.10.4
+       * Max Kellermann has identified a bug in the server routine: When
+         opening a socket fails the daemon will (re)try opening the socket in
+         an endless loop, ultimately leading to a `EMFILE' error.
  2006-11-04, Version 3.10.3
        * Lubos Stanek has identified a bug in the ntpd-plugin: When the
          ntpd's reply was sent in more than one packet, the buffer size was
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.10.3)
+ AC_INIT(collectd, 3.10.4)
  AC_CONFIG_SRCDIR(src/collectd.c)
  AC_CONFIG_HEADERS(src/config.h)
  AM_INIT_AUTOMAKE(dist-bzip2)
@@@ -25,7 -25,7 +25,7 @@@ AC_SUBST(LIBLTDL
  AC_LIBTOOL_DLOPEN
  AC_PROG_LIBTOOL
  #AC_PROG_RANLIB
 -AC_CONFIG_SUBDIRS(libltdl src/libconfig)
 +AC_CONFIG_SUBDIRS(libltdl)
  
  #
  # Checks for header files.
@@@ -197,9 -197,6 +197,9 @@@ AC_CHECK_HEADERS(IOKit/storage/IOBlockS
  # For load module
  AC_CHECK_HEADERS(sys/loadavg.h)
  
 +# For the processes plugin
 +AC_CHECK_HEADERS(linux/config.h)
 +
  # For the swap module
  AC_CHECK_HEADERS(sys/swap.h)
  
@@@ -269,30 -266,9 +269,30 @@@ AC_CHECK_HEADERS(sys/vfstab.h
  # For the swap plugin, FreeBSD
  AC_CHECK_HEADERS(kvm.h)
  
 +# For the email plugin
 +AC_CHECK_HEADERS(linux/un.h, [], [],
 +[
 +#if HAVE_SYS_SOCKET_H
 +#     include <sys/socket.h>
 +#endif
 +])
 +AC_CHECK_HEADERS(sys/un.h)
 +AC_CHECK_HEADERS(grp.h)
 +
  # For debugging interface (variable number of arguments)
  AC_CHECK_HEADERS(stdarg.h)
  
 +# Regular expressions for the ignorelist.
 +AC_CHECK_HEADERS(regex.h)
 +
 +# For the dns plugin
 +AC_CHECK_HEADERS(arpa/nameser.h arpa/nameser_compat.h)
 +
 +AC_CHECK_HEADERS(net/if_arp.h)
 +AC_CHECK_HEADERS(net/if_ppp.h)
 +AC_CHECK_HEADERS(netinet/if_ether.h)
 +AC_CHECK_HEADERS(netinet/udp.h)
 +
  dnl Checking for libraries
  AC_CHECK_LIB(m, ext)
  
@@@ -323,9 -299,6 +323,9 @@@ nanosleep_needs_rt="no
  AC_CHECK_FUNCS(nanosleep, [], AC_CHECK_LIB(rt, nanosleep, [nanosleep_needs_rt="yes"], AC_MSG_ERROR(cannot find nanosleep)))
  AM_CONDITIONAL(BUILD_WITH_LIBRT, test "x$nanosleep_needs_rt" = "xyes")
  
 +# Regular expressions for the ignorelist.
 +AC_CHECK_FUNCS(regcomp regerror regexec regfree)
 +
  # For cpu module
  AC_CHECK_FUNCS(sysctlbyname, [have_sysctlbyname="yes"], [have_sysctlbyname="no"])
  
@@@ -510,36 -483,31 +510,36 @@@ AC_DEFINE_UNQUOTED(COLLECT_RRDTOOL, [$c
        [Wether or not to use rrdtool library])
  AM_CONDITIONAL(BUILD_WITH_RRDTOOL, test "x$with_rrdtool" = "xyes")
  
 -#AC_ARG_WITH(pth, [AS_HELP_STRING([--with-pth=@<:@=PREFIX@:>@], [Path to pth (experimental).]),
 -#[    if test "x$withval" != "xno" && test "x$withval" != "xyes"
 -#     then
 -#             LDFLAGS="$LDFLAGS -L$withval/lib"
 -#             CPPFLAGS="$CPPFLAGS -I$withval/include"
 -#             with_pth="yes"
 -#     fi
 -#], [with_pth="no"])
 -#if test "x$with_pth" = "xyes"
 -#then
 -#     AC_CHECK_LIB(pth, pth_init,, [with_pth="no (libpth not found)"], [])
 -#fi
 -#if test "x$with_pth" = "xyes"
 -#then
 -#     AC_CHECK_HEADERS(pth.h,, [with_pth="no (pth.h not found)"])
 -#fi
 -#if test "x$with_pth" = "xyes"
 -#then
 -#     collect_pth=1
 -#else
 -#     collect_pth=0
 -#fi
 -#AC_DEFINE_UNQUOTED(COLLECT_PTH, [$collect_pth],
 -#     [Wether or not to use pth (portable threads) library])
 -#AM_CONDITIONAL(BUILD_WITH_PTH, test "x$with_pth" = "xyes")
 +AC_ARG_WITH(libpthread, [AS_HELP_STRING([--with-libpthread=@<:@=PREFIX@:>@], [Path to libpthread.])],
 +[     if test "x$withval" != "xno" -a "x$withval" != "xyes"
 +      then
 +              LDFLAGS="$LDFLAGS -L$withval/lib"
 +              CPPFLAGS="$CPPFLAGS -I$withval/include"
 +              with_libpthread="yes"
 +      else
 +              if test "x$withval" = "xno"
 +              then
 +                      with_libpthread="no (disabled)"
 +              fi
 +      fi
 +], [with_libpthread="yes"])
 +if test "x$with_libpthread" = "xyes"
 +then
 +      AC_CHECK_LIB(pthread, pthread_create, [with_libpthread="yes"], [with_libpthread="no (libpthread not found)"], [])
 +fi
 +if test "x$with_libpthread" = "xyes"
 +then
 +      AC_CHECK_HEADERS(pthread.h,, [with_libpthread="no (pthread.h not found)"])
 +fi
 +if test "x$with_libpthread" = "xyes"
 +then
 +      collect_pthread=1
 +else
 +      collect_pthread=0
 +fi
 +AC_DEFINE_UNQUOTED(HAVE_LIBPTHREAD, [$collect_pthread],
 +      [Wether or not to use pthread (POSIX threads) library])
 +AM_CONDITIONAL(BUILD_WITH_LIBPTHREAD, test "x$with_libpthread" = "xyes")
  
  if test "$ac_system" = "Solaris"
  then
@@@ -834,42 -802,6 +834,42 @@@ the
        with_liboping="yes (shipped version)"
  fi
  
 +AC_ARG_WITH(libpcap, [AS_HELP_STRING([--with-libpcap@<:@=PREFIX@:>@], [Path to libpcap.])],
 +[
 +      if test "x$withval" != "xno" && test "x$withval" != "xyes"
 +      then
 +              LDFLAGS="$LDFLAGS -L$withval/lib"
 +              CPPFLAGS="$CPPFLAGS -I$withval/include"
 +              with_libpcap="yes"
 +      fi
 +],
 +[
 +      with_libpcap="yes"
 +])
 +if test "x$with_libpcap" = "xyes"
 +then
 +      AC_CHECK_LIB(pcap, pcap_open_live,
 +      [
 +              AC_DEFINE(HAVE_LIBPCAP, 1, [Define to 1 if you have the pcap library (-lpcap).])
 +      ], [with_libpcap="no (libpcap not found)"])
 +fi
 +if test "x$with_libpcap" = "xyes"
 +then
 +      AC_CHECK_HEADERS(pcap.h,
 +      [
 +              AC_DEFINE(HAVE_PCAP_H, 1, [Define to 1 if you have the <pcap.h> header file.])
 +      ], [with_libpcap="no (pcap.h not found)"])
 +fi
 +if test "x$with_libpcap" = "xyes"
 +then
 +      collect_libpcap=1
 +else
 +      collect_libpcap=0
 +fi
 +AC_DEFINE_UNQUOTED(COLLECT_LIBPCAP, [$collect_libpcap],
 +      [Wether or not to use the pcap library])
 +AM_CONDITIONAL(BUILD_WITH_LIBPCAP, test "x$with_libpcap" = "xyes")
 +
  # Define `step' and `hearbeat' values..
  declare -i collectd_step=10
  declare -i collectd_heartbeat=25
@@@ -906,6 -838,7 +906,6 @@@ the
        AC_DEFINE_UNQUOTED(COLLECTD_HEARTBEAT, "$collectd_heartbeat", [Interval in which plugins are queried.])
  fi
  
 -#
  # Check for enabled/disabled features
  #
  
@@@ -985,13 -918,10 +985,13 @@@ AC_COLLECTD([cpu],       [disable], [mo
  AC_COLLECTD([cpufreq],   [disable], [module], [system cpu frequency statistics])
  AC_COLLECTD([disk],      [disable], [module], [disk/partition statistics])
  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([hddtemp],   [disable], [module], [hdd temperature statistics])
  AC_COLLECTD([load],      [disable], [module], [system load statistics])
  AC_COLLECTD([memory],    [disable], [module], [memory statistics])
 +AC_COLLECTD([multimeter],[disable], [module], [multimeter statistics])
  AC_COLLECTD([mysql],     [disable], [module], [mysql statistics])
  AC_COLLECTD([nfs],       [disable], [module], [nfs statistics])
  AC_COLLECTD([ntpd],      [disable], [module], [nfs statistics])
@@@ -1020,8 -950,6 +1020,8 @@@ Configuration
      libstatgrab . . . . $with_libstatgrab
      libkstat  . . . . . $with_kstat
      libmysql  . . . . . $with_libmysql
 +    libpcap . . . . . . $with_libpcap
 +    libpthread  . . . . $with_libpthread
  
    Features:
      debug . . . . . . . $enable_debug
      cpufreq . . . . . . $enable_cpufreq
      df  . . . . . . . . $enable_df
      disk  . . . . . . . $enable_disk
 +    dns . . . . . . . . $enable_dns
 +    email . . . . . . . $enable_email
      hddtemp . . . . . . $enable_hddtemp
      load  . . . . . . . $enable_load
      memory  . . . . . . $enable_memory
 +    multimeter  . . . . $enable_multimeter
      mysql . . . . . . . $enable_mysql
      nfs . . . . . . . . $enable_nfs
      ntpd  . . . . . . . $enable_ntpd
diff --combined src/collectd.c
@@@ -123,8 -123,6 +123,8 @@@ static void exit_usage (char *name
                        "  General:\n"
                        "    -C <file>       Configuration file.\n"
                        "                    Default: "CONFIGFILE"\n"
 +                      "    -P <file>       PID-file.\n"
 +                      "                    Default: "PIDFILE"\n"
  #if COLLECT_DAEMON
                        "    -f              Don't fork to the background.\n"
  #endif
@@@ -193,7 -191,7 +193,7 @@@ static int start_client (void
                curtime = time (NULL);
  
                /* Issue all plugins */
 -              plugin_read_all ();
 +              plugin_read_all (&loop);
  
                if (gettimeofday (&tv_now, NULL) < 0)
                {
                        continue;
                }
  
 -              while (nanosleep (&ts_wait, &ts_wait) == -1)
 +              while ((loop == 0) && (nanosleep (&ts_wait, &ts_wait) == -1))
                {
                        if (errno != EINTR)
                        {
  #if HAVE_LIBRRD
  static int start_server (void)
  {
-       /* FIXME use stack here! */
        char *host;
        char *type;
        char *instance;
        char *values;
  
-       while (loop == 0)
+       int  error_counter = 0;
+       int  status;
+       while ((loop == 0) && (error_counter < 3))
        {
-               if (network_receive (&host, &type, &instance, &values) == 0)
-                       plugin_write (host, type, instance, values);
+               status = network_receive (&host, &type, &instance, &values);
+               if (status != 0)
+               {
+                       if (status < 0)
+                               error_counter++;
+                       continue;
+               }
+               error_counter = 0;
+               plugin_write (host, type, instance, values);
  
                if (host     != NULL) free (host);     host     = NULL;
                if (type     != NULL) free (type);     type     = NULL;
@@@ -283,7 -292,7 +294,7 @@@ int main (int argc, char **argv
        char *configfile = CONFIGFILE;
  #if COLLECT_DAEMON
        struct sigaction sigChldAction;
 -      char *pidfile    = PIDFILE;
 +      char *pidfile    = NULL;
        pid_t pid;
        int daemonize    = 1;
  #endif
  
                c = getopt (argc, argv, "hC:"
  #if COLLECT_DAEMON
 -                              "f"
 +                              "fP:"
  #endif
                );
  
                                configfile = optarg;
                                break;
  #if COLLECT_DAEMON
 +                      case 'P':
 +                              pidfile = optarg;
 +                              break;
                        case 'f':
                                daemonize = 0;
                                break;
        sigChldAction.sa_handler = SIG_IGN;
        sigaction (SIGCHLD, &sigChldAction, NULL);
  
 -      if ((pidfile = cf_get_option ("PIDFile", PIDFILE)) == NULL)
 +      if ((pidfile == NULL)
 +                      && ((pidfile = cf_get_option ("PIDFile", PIDFILE)) == NULL))
        {
                fprintf (stderr, "Cannot obtain pidfile. This shoud not happen. Ever.");
                return (1);
  #endif
                start_client ();
  
 +      plugin_shutdown_all ();
 +
  #if COLLECT_DEBUG
        if (logfile != NULL)
                DBG_STOPFILE("debug file closed.");