Merge branch 'collectd-4.4'
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Tue, 15 Jul 2008 15:12:21 +0000 (17:12 +0200)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Tue, 15 Jul 2008 15:12:21 +0000 (17:12 +0200)
Conflicts:

src/snmp.c

ChangeLog
src/collectd.h
src/configfile.c
src/ntpd.c
src/perl.c
src/snmp.c
src/vserver.c
version-gen.sh

index 0f0f257..35e8b36 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2008-07-15, Version 4.4.2
+       * build system: Use pkg-config to detect the upsclient library.
+       * collectd: Try even harder to determine the endianess of the
+         architecture collectd is being built on.
+       * disk plugin: Fix for Linux 2.4: A wrong field was used as the name
+         of disks.
+       * dns plugin: Fix compilation errors with BIND versions 19991001
+         through 19991005.
+       * network plugin: Bugfix in the init routine: The init function
+         cleared a buffer regardless of its contents. This could lead to lost
+         values under Solaris.
+       * nginx plugin: Remove usage of the thread-unsafe `strtok' function.
+       * vserver plugin: Remove usage of the thread-unsafe `readdir'
+         function.
+       * wireless plugin: Work around incorrect noise and power values
+         returned by some broken drivers.
+
 2008-06-03, Version 4.4.1
        * collectd: Fix the `DataSource' option within `Type' blocks. Thanks
          to kyrone for reporting this.
index 5912fe6..a262bf1 100644 (file)
 # include <kstat.h>
 #endif
 
-#if HAVE_PTH_H
-# include <pth.h>
-#endif
 #if HAVE_SENSORS_SENSORS_H
 # include <sensors/sensors.h>
 #endif
 #endif
 
 #if __GNUC__
-# pragma GCC poison strcpy strcat sprintf strtok
+# pragma GCC poison strcpy strcat strtok
+#endif
+
+/* 
+ * Special hack for the perl plugin: Because the later included perl.h defines
+ * a macro which is never used, but contains `sprintf', we cannot poison that
+ * identifies just yet. The parl plugin will do that itself once perl.h is
+ * included.
+ */
+#ifndef DONT_POISON_SPRINTF_YET
+# if __GNUC__
+#  pragma GCC poison sprintf
+# endif
 #endif
 
 extern char hostname_g[];
index 2afef4f..d483032 100644 (file)
@@ -327,7 +327,7 @@ static int dispatch_block_plugin (oconfig_item_t *ci)
                if (ci->children[i].children == NULL)
                        dispatch_value_plugin (name, ci->children + i);
                else
-                       {DEBUG ("No nested config blocks allow for this plugin.");}
+                       {DEBUG ("No nested config blocks allowed for this plugin.");}
        }
 
        return (0);
index 1a0a07d..44964bb 100644 (file)
@@ -68,7 +68,7 @@ static char  ntpd_port[16];
 #define MAXFILENAME 128
 #define MAXSEQ  127
 #define MODE_PRIVATE 7
-#define NTP_OLDVERSION ((u_char) 1) /* oldest credible version */
+#define NTP_OLDVERSION ((uint8_t) 1) /* oldest credible version */
 #define IMPL_XNTPD 3
 #define FP_FRAC 65536.0
 
@@ -117,27 +117,27 @@ struct resp_pkt
 
 #define        ISRESPONSE(rm_vn_mode)  (((rm_vn_mode)&RESP_BIT)!=0)
 #define        ISMORE(rm_vn_mode)      (((rm_vn_mode)&MORE_BIT)!=0)
-#define INFO_VERSION(rm_vn_mode) ((u_char)(((rm_vn_mode)>>3)&0x7))
+#define INFO_VERSION(rm_vn_mode) ((uint8_t)(((rm_vn_mode)>>3)&0x7))
 #define        INFO_MODE(rm_vn_mode)   ((rm_vn_mode)&0x7)
 
 #define        RM_VN_MODE(resp, more, version)         \
-                               ((u_char)(((resp)?RESP_BIT:0)\
+                               ((uint8_t)(((resp)?RESP_BIT:0)\
                                |((more)?MORE_BIT:0)\
                                |((version?version:(NTP_OLDVERSION+1))<<3)\
                                |(MODE_PRIVATE)))
 
 #define        INFO_IS_AUTH(auth_seq)  (((auth_seq) & 0x80) != 0)
 #define        INFO_SEQ(auth_seq)      ((auth_seq)&0x7f)
-#define        AUTH_SEQ(auth, seq)     ((u_char)((((auth)!=0)?0x80:0)|((seq)&0x7f)))
+#define        AUTH_SEQ(auth, seq)     ((uint8_t)((((auth)!=0)?0x80:0)|((seq)&0x7f)))
 
-#define        INFO_ERR(err_nitems)    ((u_short)((ntohs(err_nitems)>>12)&0xf))
-#define        INFO_NITEMS(err_nitems) ((u_short)(ntohs(err_nitems)&0xfff))
-#define        ERR_NITEMS(err, nitems) (htons((u_short)((((u_short)(err)<<12)&0xf000)\
-                               |((u_short)(nitems)&0xfff))))
+#define        INFO_ERR(err_nitems)    ((uint16_t)((ntohs(err_nitems)>>12)&0xf))
+#define        INFO_NITEMS(err_nitems) ((uint16_t)(ntohs(err_nitems)&0xfff))
+#define        ERR_NITEMS(err, nitems) (htons((uint16_t)((((uint16_t)(err)<<12)&0xf000)\
+                               |((uint16_t)(nitems)&0xfff))))
 
 #define        INFO_MBZ(mbz_itemsize)  ((ntohs(mbz_itemsize)>>12)&0xf)
-#define        INFO_ITEMSIZE(mbz_itemsize)     ((u_short)(ntohs(mbz_itemsize)&0xfff))
-#define        MBZ_ITEMSIZE(itemsize)  (htons((u_short)(itemsize)))
+#define        INFO_ITEMSIZE(mbz_itemsize)     ((uint16_t)(ntohs(mbz_itemsize)&0xfff))
+#define        MBZ_ITEMSIZE(itemsize)  (htons((uint16_t)(itemsize)))
 
 /* negate a long float type */
 #define M_NEG(v_i, v_f) \
index 541826f..268e1d1 100644 (file)
 /* do not automatically get the thread specific perl interpreter */
 #define PERL_NO_GET_CONTEXT
 
+#define DONT_POISON_SPRINTF_YET 1
 #include "collectd.h"
+#undef DONT_POISON_SPRINTF_YET
 
 #include "configfile.h"
 
 #include <EXTERN.h>
 #include <perl.h>
 
+#if __GNUC__
+# pragma GCC poison sprintf
+#endif
+
 #include <XSUB.h>
 
 /* Some versions of Perl define their own version of DEBUG... :-/ */
index 0561257..07465dd 100644 (file)
@@ -708,14 +708,14 @@ static value_t csnmp_value_list_to_value (struct variable_list *vl, int type,
       || (vl->type == ASN_GAUGE))
   {
     temp = (uint32_t) *vl->val.integer;
-    DEBUG ("snmp plugin: Parsed int32 value is %llu.", temp);
+    DEBUG ("snmp plugin: Parsed int32 value is %"PRIu64".", temp);
   }
   else if (vl->type == ASN_COUNTER64)
   {
     temp = (uint32_t) vl->val.counter64->high;
     temp = temp << 32;
     temp += (uint32_t) vl->val.counter64->low;
-    DEBUG ("snmp plugin: Parsed int64 value is %llu.", temp);
+    DEBUG ("snmp plugin: Parsed int64 value is %"PRIu64".", temp);
   }
   else if (vl->type == ASN_OCTET_STR)
   {
@@ -1424,8 +1424,8 @@ static int csnmp_read_host (host_definition_t *host)
   if ((time_end - time_start) > host->interval)
   {
     WARNING ("snmp plugin: Host `%s' should be queried every %i seconds, "
-       "but reading all values takes %lu seconds.",
-       host->name, host->interval, (unsigned long)(time_end - time_start));
+       "but reading all values takes %u seconds.",
+       host->name, host->interval, (unsigned int) (time_end - time_start));
   }
 
   return (0);
index 413674b..dac4392 100644 (file)
@@ -120,11 +120,19 @@ static inline long long __get_sock_bytes(const char *s)
 
 static int vserver_read (void)
 {
+#if NAME_MAX < 1024
+# define DIRENT_BUFFER_SIZE (sizeof (struct dirent) + 1024 + 1)
+#else
+# define DIRENT_BUFFER_SIZE (sizeof (struct dirent) + NAME_MAX + 1)
+#endif
+
        DIR                     *proc;
        struct dirent   *dent; /* 42 */
+       char dirent_buffer[DIRENT_BUFFER_SIZE];
 
        errno = 0;
-       if (NULL == (proc = opendir (PROCDIR)))
+       proc = opendir (PROCDIR);
+       if (proc == NULL)
        {
                char errbuf[1024];
                ERROR ("vserver plugin: fopen (%s): %s", PROCDIR, 
@@ -132,21 +140,51 @@ static int vserver_read (void)
                return (-1);
        }
 
-       while (NULL != (dent = readdir (proc)))
+       while (42)
        {
-               int  len;
+               size_t len;
                char file[BUFSIZE];
 
                FILE *fh;
                char buffer[BUFSIZE];
 
+               struct stat statbuf;
                char *cols[4];
 
+               int status;
+
+               status = readdir_r (proc, (struct dirent *) dirent_buffer, &dent);
+               if (status != 0)
+               {
+                       char errbuf[4096];
+                       ERROR ("vserver plugin: readdir_r failed: %s",
+                                       sstrerror (errno, errbuf, sizeof (errbuf)));
+                       closedir (proc);
+                       return (-1);
+               }
+               else if (dent == NULL)
+               {
+                       /* end of directory */
+                       break;
+               }
+
                if (dent->d_name[0] == '.')
                        continue;
 
-               /* This is not a directory */
-               if (dent->d_type != DT_DIR)
+               len = snprintf (file, sizeof (file), PROCDIR "/%s", dent->d_name);
+               if ((len < 0) || (len >= BUFSIZE))
+                       continue;
+               
+               status = stat (file, &statbuf);
+               if (status != 0)
+               {
+                       char errbuf[4096];
+                       WARNING ("vserver plugin: stat (%s) failed: %s",
+                                       file, sstrerror (errno, errbuf, sizeof (errbuf)));
+                       continue;
+               }
+               
+               if (!S_ISDIR (statbuf.st_mode))
                        continue;
 
                /* socket message accounting */
index 755e116..0049f7d 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-DEFAULT_VERSION="4.4.1.git"
+DEFAULT_VERSION="4.4.2.git"
 
 VERSION="$( git describe 2> /dev/null | sed -e 's/^collectd-//' )"