author | Florian Forster <octo@noris.net> | |
Wed, 23 Jul 2008 15:18:13 +0000 (17:18 +0200) | ||
committer | Florian Forster <octo@noris.net> | |
Wed, 23 Jul 2008 15:18:13 +0000 (17:18 +0200) |
ChangeLog | patch | blob | history | |
src/Makefile.am | patch | blob | history | |
src/collectd.conf.pod | patch | blob | history | |
src/collectd.h | patch | blob | history | |
src/configfile.c | patch | blob | history | |
src/liboconfig/scanner.l | patch | blob | history | |
src/ntpd.c | patch | blob | history | |
src/perl.c | patch | blob | history | |
src/snmp.c | patch | blob | history | |
src/vserver.c | patch | blob | history | |
version-gen.sh | patch | blob | history |
diff --git a/ChangeLog b/ChangeLog
index 0f0f2571f0d6cb5c3d17af11679e221e11264de7..35e8b36cc5c35f2964f08f2ceb5f0fffda298d13 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
+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.
diff --git a/src/Makefile.am b/src/Makefile.am
index 9962c0d0533608fd88ac79d603374fd0b3107b06..c4e7d69f78b725020f55e768275fd212ef5c8897 100644 (file)
--- a/src/Makefile.am
+++ b/src/Makefile.am
perl_la_SOURCES = perl.c
# Despite C99 providing the "bool" type thru stdbool.h, Perl defines its own
# version of that type if HAS_BOOL is not defined... *sigh*
-perl_la_CPPFLAGS = -DHAS_BOOL=1
+perl_la_CPPFLAGS = $(AM_CPPFLAGS) -DHAS_BOOL=1
perl_la_CFLAGS = $(AM_CFLAGS) \
$(PERL_CFLAGS) \
-DXS_VERSION=\"$(VERSION)\" -DVERSION=\"$(VERSION)\"
if BUILD_PLUGIN_POSTGRESQL
pkglib_LTLIBRARIES += postgresql.la
postgresql_la_SOURCES = postgresql.c
-postgresql_la_CPPFLAGS = $(BUILD_WITH_LIBPQ_CPPFLAGS)
+postgresql_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBPQ_CPPFLAGS)
postgresql_la_LDFLAGS = -module -avoid-version \
$(BUILD_WITH_LIBPQ_LDFLAGS) -lpq
collectd_LDADD += "-dlopen" postgresql.la
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index 884298dc3f7bc07cbde2e8e26e8a8ac61d6a5aa7..1a52ae5cd49d2223a9cf2295a901b922f46e74ae 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
ignored. Values are either string, enclosed in double-quotes,
(floating-point-)numbers or a boolean expression, i.E<nbsp>e. either B<true> or
B<false>. String containing of only alphanumeric characters and underscores do
-not need to be quoted.
+not need to be quoted. Lines may be wrapped by using `\' as the last character
+before the newline. This allows long lines to be split into multiple lines.
+Quoted strings may be wrapped as well. However, those are treated special in
+that whitespace at the beginning of the following lines will be ignored, which
+allows for nicely indenting the wrapped lines.
The configuration is read and processed in order, i.E<nbsp>e. from top to
bottom. So the plugins are loaded in the order listed in this config file. It
diff --git a/src/collectd.h b/src/collectd.h
index 5912fe6f809b0557dac19b3460e9f038ac5230e0..a262bf1d1fc99621e07b9aea7619351bc736d809 100644 (file)
--- a/src/collectd.h
+++ b/src/collectd.h
# 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[];
diff --git a/src/configfile.c b/src/configfile.c
index 2afef4f024e402a2cc94bd7f02744e599fac440a..d483032af71b398d10a44c808c65285e55e805e8 100644 (file)
--- a/src/configfile.c
+++ b/src/configfile.c
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 4d9fc3de811bce2f7b79da20b566e65171d9baa0..b559e863179ebfebaf1acc4219baa24522897e5d 100644 (file)
--- a/src/liboconfig/scanner.l
+++ b/src/liboconfig/scanner.l
/**
* oconfig - src/scanner.l
* Copyright (C) 2007 Florian octo Forster <octo at verplant.org>
+ * Copyright (C) 2008 Sebastian tokkee Harl <sh at tokkee.org>
*
* 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
#include "oconfig.h"
#include "aux_types.h"
#include "parser.h"
+
+/* multiline string buffer */
+static char *ml_buffer = NULL;
+static int ml_pos = 0;
+static int ml_len = 0;
+
+#define ml_free (ml_len - ml_pos)
+
+static void ml_append (char *);
+
+#ifdef yyterminate
+# undef yyterminate
+#endif
+#define yyterminate() \
+ do { free (ml_buffer); ml_buffer = NULL; ml_pos = 0; ml_len = 0; \
+ return YY_NULL; } while (0)
%}
%option yylineno
%option noyywrap
+%x ML
WHITE_SPACE [\ \t\b]
-QUOTED_STRING \"([^\\"]+|\\.)*\"
+NON_WHITE_SPACE [^\ \t\b]
+EOL (\r\n|\n)
+QUOTED_STRING ([^\\"]+|\\.)*
UNQUOTED_STRING [0-9A-Za-z_]+
HEX_NUMBER 0[xX][0-9a-fA-F]+
OCT_NUMBER 0[0-7]+
{WHITE_SPACE} |
{COMMENT} {/* ignore */}
-\n {return (EOL);}
+\\{EOL} {/* continue line */}
+
+{EOL} {return (EOL);}
"/" {return (SLASH);}
"<" {return (OPENBRAC);}
">" {return (CLOSEBRAC);}
{NUMBER} {yylval.number = strtod (yytext, NULL); return (NUMBER);}
-{QUOTED_STRING} {yylval.string = yytext; return (QUOTED_STRING);}
+\"{QUOTED_STRING}\" {yylval.string = yytext; return (QUOTED_STRING);}
{UNQUOTED_STRING} {yylval.string = yytext; return (UNQUOTED_STRING);}
+
+\"{QUOTED_STRING}\\{EOL} {
+ int len = strlen (yytext);
+
+ ml_pos = 0;
+
+ /* remove "\\<EOL>" */
+ if ('\r' == yytext[len - 2])
+ len -= 3;
+ else
+ len -= 2;
+ yytext[len] = '\0';
+
+ ml_append (yytext);
+ BEGIN (ML);
+}
+<ML>^{WHITE_SPACE}+ {/* remove leading white-space */}
+<ML>{NON_WHITE_SPACE}{QUOTED_STRING}\\{EOL} {
+ int len = strlen (yytext);
+
+ /* remove "\\<EOL>" */
+ if ('\r' == yytext[len - 2])
+ len -= 3;
+ else
+ len -= 2;
+ yytext[len] = '\0';
+
+ ml_append(yytext);
+}
+<ML>{NON_WHITE_SPACE}{QUOTED_STRING}\" {
+ ml_append(yytext);
+ yylval.string = ml_buffer;
+
+ BEGIN (INITIAL);
+ return (QUOTED_STRING);
+}
%%
+static void ml_append (char *string)
+{
+ int len = strlen (string);
+ int s;
+
+ if (ml_free <= len) {
+ ml_len += len - ml_free + 1;
+ ml_buffer = (char *)realloc (ml_buffer, ml_len);
+ if (NULL == ml_buffer)
+ YY_FATAL_ERROR ("out of dynamic memory in ml_append");
+ }
+
+ s = snprintf (ml_buffer + ml_pos, ml_free, "%s", string);
+ if ((0 > s) || (ml_free <= s))
+ YY_FATAL_ERROR ("failed to write to multiline buffer");
+
+ ml_pos += s;
+ return;
+} /* ml_append */
+
diff --git a/src/ntpd.c b/src/ntpd.c
index 1a0a07dd5a66a9a01d2cf3172e4b12db371431df..44964bb5a8dbd936d23ef2e828e4d05b2561c543 100644 (file)
--- a/src/ntpd.c
+++ b/src/ntpd.c
#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
#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) \
diff --git a/src/perl.c b/src/perl.c
index 541826fb6eb04a2746904f2bcd441f0ec42a6e75..268e1d1428968b5d0eb4f9269ec7e2a004615bcc 100644 (file)
--- a/src/perl.c
+++ b/src/perl.c
/* 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... :-/ */
diff --git a/src/snmp.c b/src/snmp.c
index 05612576837dcbb1f8be3801af197adebd86694f..07465ddd26d1a951addd40b0ea28f9a7cad6b409 100644 (file)
--- a/src/snmp.c
+++ b/src/snmp.c
|| (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)
{
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);
diff --git a/src/vserver.c b/src/vserver.c
index 413674b0338b3f8844c8b2ac39ce80cf67961062..dac4392693159ad63dc1a095536b5a4cbefe9d09 100644 (file)
--- a/src/vserver.c
+++ b/src/vserver.c
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,
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 */
diff --git a/version-gen.sh b/version-gen.sh
index 755e1168026f3cedca6953ad0cf498e468d97f9e..0049f7deac8b95c0ff62859dd406619afbdaed6f 100755 (executable)
--- a/version-gen.sh
+++ b/version-gen.sh
#!/bin/sh
-DEFAULT_VERSION="4.4.1.git"
+DEFAULT_VERSION="4.4.2.git"
VERSION="$( git describe 2> /dev/null | sed -e 's/^collectd-//' )"