Code

Merge branch 'master' of git://github.com/octo/collectd
authorGarret Heaton <powdahound@gmail.com>
Mon, 9 Nov 2009 16:53:51 +0000 (08:53 -0800)
committerGarret Heaton <powdahound@gmail.com>
Mon, 9 Nov 2009 16:53:51 +0000 (08:53 -0800)
ChangeLog
README
configure.in
src/collectd-snmp.pod
src/collectd.conf.in
src/collectd.conf.pod
src/cpu.c
src/gmond.c
src/processes.c
src/types.db
version-gen.sh

index 83980834a18ad999f123ee01ea1b6692ef66d1da..ecc3869d4abe4c1c93458825b98aba764efe6276 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2009-10-04, Version 4.8.1
+       * Build system: Issues when building the iptables plugin have been
+         fixed.
+       * exec plugin: Clear the signal block mask before calling exec(2).
+       * perl plugin: Declare the “environ” variable. This solves build
+         issues on some platforms.
+       * processes plugin: Remove unnecessary call of realloc(3). Thanks to
+         Andrés J. Díaz for the patch.
+       * unixsock plugin: Fix a (well hidden) race condition related to file
+         descriptor handling.
+
 2009-09-13, Version 4.8.0
        * collectd: Two new data source types, “DERIVE” and “ABSOLUTE”, have
          been added. “DERIVE” can be used for counters that are reset
          lists, where at least one data source is of type COUNTER and the
          counter value of all counter data sources is zero.
 
+2009-10-03, Version 4.7.4
+       * Build system: Issues when building the iptables plugin have been
+         fixed.
+       * exec plugin: Clear the signal block mask before calling exec(2).
+       * perl plugin: Declare the “environ” variable. This solves build
+         issues on some platforms.
+       * processes plugin: Remove unnecessary call of realloc(3). Thanks to
+         Andrés J. Díaz for the patch.
+       * unixsock plugin: Fix a (well hidden) race condition related to file
+         descriptor handling.
+
 2009-09-13, Version 4.7.3
        * collectd: Fix a possible but very rare invalid “free” in the caching
          code. Thanks to Sebastian Harl for the patch.
diff --git a/README b/README
index 796fb8ff20ced56b4dbc8a09b688029564141749..d40fd2f0ab596a42b4aaa5f735d7fc1c0ff4e43c 100644 (file)
--- a/README
+++ b/README
@@ -180,7 +180,7 @@ Features
       Network UPS tools: UPS current, voltage, power, charge, utilisation,
       temperature, etc. See upsd(8).
 
-    - olsr
+    - olsrd
       Queries routing information from the “Optimized Link State Routing”
       daemon.
 
@@ -480,9 +480,11 @@ Prerequisites
 
   * libganglia (optional)
     Used by the `gmond' plugin to process data received from Ganglia.
+    <http://ganglia.info/>
 
   * libgcrypt (optional)
     Used by the `network' plugin for encryption and authentication.
+    <http://www.gnupg.org/>
 
   * libhal (optional)
     If present, the uuid plugin will check for UUID from HAL.
@@ -502,9 +504,11 @@ Prerequisites
     Library that encapsulates the `Java Virtual Machine' (JVM). This library is
     used by the Java plugin to execute Java bytecode. See “Configuring with
     libjvm” below.
+    <http://openjdk.java.net/> (and others)
 
   * libmemcached (optional)
     Used by the `memcachec' plugin to connect to a memcache daemon.
+    <http://tangent.org/552/libmemcached.html>
 
   * libmysqlclient (optional)
     Unsurprisingly used by the `mysql' plugin.
@@ -567,6 +571,10 @@ Prerequisites
     and/or Solaris.
     <http://www.i-scream.org/libstatgrab/>
 
+  * libtokyotyrant (optional)
+    Used by the tokyotyrant plugin.
+    <http://1978th.net/tokyotyrant/>
+
   * libupsclient/nut (optional)
     For the `nut' plugin which queries nut's `upsd'.
     <http://networkupstools.org/>
index 9ab3006e4a156dc527f8a03c4d34bb4c9dbe6aaf..b3d9516e30e349db1b6f843ce44a8080bdc1e265 100644 (file)
@@ -1589,7 +1589,7 @@ then
        if test -d "$with_java_home"
        then
                AC_MSG_CHECKING([for jni.h])
-               TMPDIR=`find -L "$with_java_home" -name jni.h -type f -exec 'dirname' '{}' ';' | head -n 1`
+               TMPDIR=`find "$with_java_home" -name jni.h -type f -exec 'dirname' '{}' ';' | head -n 1`
                if test "x$TMPDIR" != "x"
                then
                        AC_MSG_RESULT([found in $TMPDIR])
@@ -1599,7 +1599,7 @@ then
                fi
 
                AC_MSG_CHECKING([for jni_md.h])
-               TMPDIR=`find -L "$with_java_home" -name jni_md.h -type f -exec 'dirname' '{}' ';' | head -n 1`
+               TMPDIR=`find "$with_java_home" -name jni_md.h -type f -exec 'dirname' '{}' ';' | head -n 1`
                if test "x$TMPDIR" != "x"
                then
                        AC_MSG_RESULT([found in $TMPDIR])
@@ -1609,7 +1609,7 @@ then
                fi
 
                AC_MSG_CHECKING([for libjvm.so])
-               TMPDIR=`find -L "$with_java_home" -name libjvm.so -type f -exec 'dirname' '{}' ';' | head -n 1`
+               TMPDIR=`find "$with_java_home" -name libjvm.so -type f -exec 'dirname' '{}' ';' | head -n 1`
                if test "x$TMPDIR" != "x"
                then
                        AC_MSG_RESULT([found in $TMPDIR])
@@ -1621,7 +1621,7 @@ then
                if test "x$JAVAC" = "x"
                then
                        AC_MSG_CHECKING([for javac])
-                       TMPDIR=`find -L "$with_java_home" -name javac -type f | head -n 1`
+                       TMPDIR=`find "$with_java_home" -name javac -type f | head -n 1`
                        if test "x$TMPDIR" != "x"
                        then
                                JAVAC="$TMPDIR"
index f34113d9214f08f4b7c1129a2851d87a95a02cbb..51e04813fa7537ae0b3219c523c4c1d9ea4b53cf 100644 (file)
@@ -184,7 +184,7 @@ This value is not applied to counter-values.
 I<Value> is added to gauge-values returned by the SNMP-agent after they have
 been multiplied by any B<Scale> value. If, for example, a thermometer returns
 degrees Kelvin you could specify a shift of B<273.15> here to store values in
-degrees Celsius. The default value is is course B<0.0>.
+degrees Celsius. The default value is of course B<0.0>.
 
 This value is not applied to counter-values.
 
index 11ae74856aa13dce422ee5b80256eabc88650a7e..ad13353f59242ddadceed98393f03fed8cdfa1a7 100644 (file)
@@ -82,6 +82,7 @@ FQDNLookup   true
 #@BUILD_PLUGIN_JAVA_TRUE@LoadPlugin java
 #@BUILD_PLUGIN_LIBVIRT_TRUE@LoadPlugin libvirt
 @BUILD_PLUGIN_LOAD_TRUE@@BUILD_PLUGIN_LOAD_TRUE@LoadPlugin load
+#@BUILD_PLUGIN_MADWIFI_TRUE@LoadPlugin madwifi
 #@BUILD_PLUGIN_MBMON_TRUE@LoadPlugin mbmon
 #@BUILD_PLUGIN_MEMCACHEC_TRUE@LoadPlugin memcachec
 #@BUILD_PLUGIN_MEMCACHED_TRUE@LoadPlugin memcached
@@ -360,6 +361,17 @@ FQDNLookup   true
 #      HostnameFormat name
 #</Plugin>
 
+#<Plugin madwifi>
+#      Interface "wlan0"
+#      IgnoreSelected false
+#      Source "SysFS"
+#      WatchSet "None"
+#      WatchAdd "node_octets"
+#      WatchAdd "node_rssi"
+#      WatchAdd "is_rx_acl"
+#      WatchAdd "is_scan_active"
+#</Plugin>
+
 #<Plugin mbmon>
 #      Host "127.0.0.1"
 #      Port "411"
@@ -727,6 +739,7 @@ FQDNLookup   true
 ##############################################################################
 
 # Load required matches:
+#@BUILD_PLUGIN_MATCH_EMPTY_COUNTER_TRUE@LoadPlugin match_empty_counter
 #@BUILD_PLUGIN_MATCH_REGEX_TRUE@LoadPlugin match_regex
 #@BUILD_PLUGIN_MATCH_VALUE_TRUE@LoadPlugin match_value
 #@BUILD_PLUGIN_MATCH_TIMEDIFF_TRUE@LoadPlugin match_timediff
index 3ea3d4dd588ab47ed1cd63e759f76ffa19dc0390..6bae33936e3eac1b0cbe6980e019bf1e55db1d45 100644 (file)
@@ -3235,7 +3235,7 @@ C<I<prefix>/var/run/collectd-powerdns>.
 Select more detailed statistics of processes matching this name. The statistics
 collected for these selected processes are size of the resident segment size
 (RSS), user- and system-time used, number of processes and number of threads,
-and minor and major pagefaults.
+io data (where available) and minor and major pagefaults.
 
 =item B<ProcessMatch> I<name> I<regex>
 
index c4bd1a6d8459d7e3acb8c622734deadf784270f7..b92b0e2f0b7e74d4f89800e97d29e0434b5abe83 100644 (file)
--- a/src/cpu.c
+++ b/src/cpu.c
@@ -123,6 +123,9 @@ static int numcpu;
 
 #elif defined(HAVE_SYSCTLBYNAME)
 static int numcpu;
+#  ifdef HAVE_SYSCTL_KERN_CP_TIMES
+static int maxcpu;
+#  endif /* HAVE_SYSCTL_KERN_CP_TIMES */
 /* #endif HAVE_SYSCTLBYNAME */
 
 #elif defined(HAVE_LIBSTATGRAB)
@@ -193,12 +196,22 @@ static int init (void)
        if (sysctlbyname ("hw.ncpu", &numcpu, &numcpu_size, NULL, 0) < 0)
        {
                char errbuf[1024];
-               WARNING ("cpu plugin: sysctlbyname: %s",
+               WARNING ("cpu plugin: sysctlbyname(hw.ncpu): %s",
                                sstrerror (errno, errbuf, sizeof (errbuf)));
                return (-1);
        }
 
-#ifndef HAVE_SYSCTL_KERN_CP_TIMES
+#ifdef HAVE_SYSCTL_KERN_CP_TIMES
+       numcpu_size = sizeof (maxcpu);
+
+       if (sysctlbyname("kern.smp.maxcpus", &maxcpu, &numcpu_size, NULL, 0) < 0)
+       {
+               char errbuf[1024];
+               WARNING ("cpu plugin: sysctlbyname(kern.smp.maxcpus): %s",
+                               sstrerror (errno, errbuf, sizeof (errbuf)));
+               return (-1);
+       }
+#else
        if (numcpu != 1)
                NOTICE ("cpu: Only one processor supported when using `sysctlbyname' (found %i)", numcpu);
 #endif
@@ -467,7 +480,7 @@ static int cpu_read (void)
        }
 /* #endif CAN_USE_SYSCTL */
 #elif defined(HAVE_SYSCTLBYNAME) && defined(HAVE_SYSCTL_KERN_CP_TIMES)
-       long cpuinfo[numcpu][CPUSTATES];
+       long cpuinfo[maxcpu][CPUSTATES];
        size_t cpuinfo_size;
        int i;
 
index 3357ea0b35ae73d3323324c6ea9de3db8431b858..2ffc42a57d93aadf0b3d3bf080d6566c093592f4 100644 (file)
@@ -542,9 +542,9 @@ static int staging_entry_update (const char *host, const char *name, /* {{{ */
   else if (ds_type == DS_TYPE_GAUGE)
     se->vl.values[ds_index].gauge = value.gauge;
   else if (ds_type == DS_TYPE_DERIVE)
-    se->vl.values[ds_index].DERIVE += value.derive;
+    se->vl.values[ds_index].derive += value.derive;
   else if (ds_type == DS_TYPE_ABSOLUTE)
-    se->vl.values[ds_index].ABSOLUTE = value.absolute;
+    se->vl.values[ds_index].absolute = value.absolute;
 
   se->flags |= (0x01 << ds_index);
 
index 5f67abaa12dd879072ccc4e794e575fc241146a9..5ef4acc039907743d1f22180f23871ec5f9ce326 100644 (file)
@@ -136,6 +136,12 @@ typedef struct procstat_entry_s
        unsigned long cpu_user_counter;
        unsigned long cpu_system_counter;
 
+       /* io data */
+       long io_rchar;
+       long io_wchar;
+       long io_syscr;
+       long io_syscw;
+
        struct procstat_entry_s *next;
 } procstat_entry_t;
 
@@ -159,6 +165,12 @@ typedef struct procstat
        unsigned long cpu_user_counter;
        unsigned long cpu_system_counter;
 
+       /* io data */
+       long io_rchar;
+       long io_wchar;
+       long io_syscr;
+       long io_syscw;
+
        struct procstat   *next;
        struct procstat_entry_s *instances;
 } procstat_t;
@@ -328,6 +340,10 @@ static void ps_list_add (const char *name, const char *cmdline, procstat_entry_t
                pse->vmem_size  = entry->vmem_size;
                pse->vmem_rss   = entry->vmem_rss;
                pse->stack_size = entry->stack_size;
+               pse->io_rchar   = entry->io_rchar;
+               pse->io_wchar   = entry->io_wchar;
+               pse->io_syscr   = entry->io_syscr;
+               pse->io_syscw   = entry->io_syscw;
 
                ps->num_proc   += pse->num_proc;
                ps->num_lwp    += pse->num_lwp;
@@ -335,6 +351,11 @@ static void ps_list_add (const char *name, const char *cmdline, procstat_entry_t
                ps->vmem_rss   += pse->vmem_rss;
                ps->stack_size += pse->stack_size;
 
+               ps->io_rchar   += ((pse->io_rchar == -1)?0:pse->io_rchar);
+               ps->io_wchar   += ((pse->io_wchar == -1)?0:pse->io_wchar);
+               ps->io_syscr   += ((pse->io_syscr == -1)?0:pse->io_syscr);
+               ps->io_syscw   += ((pse->io_syscw == -1)?0:pse->io_syscw);
+
                if ((entry->vmem_minflt_counter == 0)
                                && (entry->vmem_majflt_counter == 0))
                {
@@ -425,6 +446,10 @@ static void ps_list_reset (void)
                ps->vmem_size   = 0;
                ps->vmem_rss    = 0;
                ps->stack_size  = 0;
+               ps->io_rchar = -1;
+               ps->io_wchar = -1;
+               ps->io_syscr = -1;
+               ps->io_syscw = -1;
 
                pse_prev = NULL;
                pse = ps->instances;
@@ -607,12 +632,33 @@ static void ps_submit_proc_list (procstat_t *ps)
        vl.values_len = 2;
        plugin_dispatch_values (&vl);
 
+       if ( (ps->io_rchar != -1) && (ps->io_wchar != -1) )
+       {
+               sstrncpy (vl.type, "ps_disk_octets", sizeof (vl.type));
+               vl.values[0].counter = ps->io_rchar;
+               vl.values[1].counter = ps->io_wchar;
+               vl.values_len = 2;
+               plugin_dispatch_values (&vl);
+       }
+
+       if ( (ps->io_syscr != -1) && (ps->io_syscw != -1) )
+       {
+               sstrncpy (vl.type, "ps_disk_ops", sizeof (vl.type));
+               vl.values[0].counter = ps->io_syscr;
+               vl.values[1].counter = ps->io_syscw;
+               vl.values_len = 2;
+               plugin_dispatch_values (&vl);
+       }
+
        DEBUG ("name = %s; num_proc = %lu; num_lwp = %lu; vmem_rss = %lu; "
                        "vmem_minflt_counter = %lu; vmem_majflt_counter = %lu; "
-                       "cpu_user_counter = %lu; cpu_system_counter = %lu;",
+                       "cpu_user_counter = %lu; cpu_system_counter = %lu; "
+                       "io_rchar = %ld; io_wchar = %ld; "
+                       "io_syscr = %ld; io_syscw = %ld;",
                        ps->name, ps->num_proc, ps->num_lwp, ps->vmem_rss,
                        ps->vmem_minflt_counter, ps->vmem_majflt_counter,
-                       ps->cpu_user_counter, ps->cpu_system_counter);
+                       ps->cpu_user_counter, ps->cpu_system_counter,
+                       ps->io_rchar, ps->io_wchar, ps->io_syscr, ps->io_syscw);
 } /* void ps_submit_proc_list */
 
 /* ------- additional functions for KERNEL_LINUX/HAVE_THREAD_INFO ------- */
@@ -644,6 +690,52 @@ static int ps_read_tasks (int pid)
        return ((count >= 1) ? count : 1);
 } /* int *ps_read_tasks */
 
+static procstat_t *ps_read_io (int pid, procstat_t *ps)
+{
+       FILE *fh;
+       char buffer[1024];
+       char filename[64];
+
+       char *fields[8];
+       int numfields;
+
+       ssnprintf (filename, sizeof (filename), "/proc/%i/io", pid);
+       if ((fh = fopen (filename, "r")) == NULL)
+               return (NULL);
+
+       while (fgets (buffer, 1024, fh) != NULL)
+       {
+               long *val = NULL;
+
+               if (strncasecmp (buffer, "rchar:", 6) == 0)
+                       val = &(ps->io_rchar);
+               else if (strncasecmp (buffer, "wchar:", 6) == 0)
+                       val = &(ps->io_wchar);
+               else if (strncasecmp (buffer, "syscr:", 6) == 0)
+                       val = &(ps->io_syscr);
+               else if (strncasecmp (buffer, "syscw:", 6) == 0)
+                       val = &(ps->io_syscw);
+               else
+                       continue;
+
+               numfields = strsplit (buffer, fields, 8);
+
+               if (numfields < 2)
+                       continue;
+
+               *val = atol (fields[1]);
+       }
+
+       if (fclose (fh))
+       {
+               char errbuf[1024];
+               WARNING ("processes: fclose: %s",
+                               sstrerror (errno, errbuf, sizeof (errbuf)));
+       }
+
+       return (ps);
+} /* procstat_t *ps_read_io */
+
 int ps_read_process (int pid, procstat_t *ps, char *state)
 {
        char  filename[64];
@@ -746,6 +838,17 @@ int ps_read_process (int pid, procstat_t *ps, char *state)
        ps->vmem_rss = (unsigned long) vmem_rss;
        ps->stack_size = (unsigned long) stack_size;
 
+       if ( (ps_read_io (pid, ps)) == NULL)
+       {
+               /* no io data */
+               ps->io_rchar = -1;
+               ps->io_wchar = -1;
+               ps->io_syscr = -1;
+               ps->io_syscw = -1;
+
+               DEBUG("ps_read_process: not get io data for pid %i",pid);
+       }
+
        /* success */
        return (0);
 } /* int ps_read_process (...) */
@@ -1274,6 +1377,11 @@ static int ps_read (void)
                pse.cpu_system = 0;
                pse.cpu_system_counter = ps.cpu_system_counter;
 
+               pse.io_rchar = ps.io_rchar;
+               pse.io_wchar = ps.io_wchar;
+               pse.io_syscr = ps.io_syscr;
+               pse.io_syscw = ps.io_syscw;
+
                switch (state)
                {
                        case 'R': running++;  break;
@@ -1402,6 +1510,12 @@ static int ps_read (void)
                        * 1000
                        + procs[i].ki_rusage.ru_stime.tv_usec;
 
+               /* no io data */
+               pse.io_rchar = -1;
+               pse.io_wchar = -1;
+               pse.io_syscr = -1;
+               pse.io_syscw = -1;
+
                switch (procs[i].ki_stat)
                {
                        case SSTOP:     stopped++;      break;
index 0225e0f6b8e6586bb44db3fb8d83baefbeb9eab7..c8c6b98aa7a73337a68252e73c0c33feb4727498 100644 (file)
@@ -123,6 +123,8 @@ protocol_counter    value:COUNTER:0:U
 ps_count               processes:GAUGE:0:1000000, threads:GAUGE:0:1000000
 ps_cputime             user:COUNTER:0:16000000, syst:COUNTER:0:16000000
 ps_pagefaults          minflt:COUNTER:0:9223372036854775807, majflt:COUNTER:0:9223372036854775807
+ps_disk_octets         read:DERIVE:0:U, write:DERIVE:0:U
+ps_disk_ops            read:DERIVE:0:U, write:DERIVE:0:U
 ps_rss                 value:GAUGE:0:9223372036854775807
 ps_stacksize           value:GAUGE:0:9223372036854775807
 ps_state               value:GAUGE:0:65535
index f2c61f54527075dbc263adbbd97d70b96a2a3e18..e0114d0422a0a94c0ac071628e314e09221dbac3 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-DEFAULT_VERSION="4.8.0.git"
+DEFAULT_VERSION="4.8.1.git"
 
 VERSION="`git describe 2> /dev/null | sed -e 's/^collectd-//'`"