Merge branch 'collectd-5.5'
authorMarc Fournier <marc.fournier@camptocamp.com>
Sat, 1 Aug 2015 07:34:28 +0000 (09:34 +0200)
committerMarc Fournier <marc.fournier@camptocamp.com>
Sat, 1 Aug 2015 07:34:28 +0000 (09:34 +0200)
14 files changed:
src/Makefile.am
src/collectd-nagios.c
src/collectd.conf.pod
src/daemon/collectd.c
src/daemon/configfile.c
src/daemon/plugin.c
src/daemon/utils_cache.c
src/gmond.c
src/iptables.c
src/liboconfig/scanner.l
src/memcached.c
src/utils_crc32.c
src/utils_crc32.h
src/write_kafka.c

index df60d0d..e522f21 100644 (file)
@@ -119,6 +119,7 @@ if BUILD_PLUGIN_AMQP
 pkglib_LTLIBRARIES += amqp.la
 amqp_la_SOURCES = amqp.c \
                  utils_cmd_putval.c utils_cmd_putval.h \
+                 utils_parse_option.c utils_parse_option.h \
                  utils_format_graphite.c utils_format_graphite.h \
                  utils_format_json.c utils_format_json.h
 amqp_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBRABBITMQ_LDFLAGS)
index 3d6039c..b17e47e 100644 (file)
@@ -308,8 +308,7 @@ static int do_listval (lcc_connection_t *connection)
 
                if ((hostname == NULL) || strcasecmp (hostname, ret_ident[i].host))
                {
-                       if (hostname != NULL)
-                               free (hostname);
+                       free (hostname);
                        hostname = strdup (ret_ident[i].host);
                        printf ("Host: %s\n", hostname);
                }
@@ -323,6 +322,8 @@ static int do_listval (lcc_connection_t *connection)
                        printf ("ERROR: listval: Failed to convert returned "
                                        "identifier to a string: %s\n",
                                        lcc_strerror (connection));
+                       free (hostname);
+                       hostname = NULL;
                        continue;
                }
 
@@ -330,8 +331,8 @@ static int do_listval (lcc_connection_t *connection)
                printf ("\t%s\n", id + 1);
        }
 
-       if (ret_ident != NULL)
-               free (ret_ident);
+       free (ret_ident);
+       free (hostname);
        return (RET_OKAY);
 } /* int do_listval */
 
index 9a8d2c1..bd39295 100644 (file)
@@ -510,7 +510,7 @@ are disabled by default.
 
 =head2 Plugin C<amqp>
 
-The I<AMQMP plugin> can be used to communicate with other instances of
+The I<AMQP plugin> can be used to communicate with other instances of
 I<collectd> or third party applications using an AMQP message broker. Values
 are sent to or received from the broker, which handles routing, queueing and
 possibly filtering out messages.
@@ -7119,6 +7119,10 @@ You can also specify combinations of these fields. For example B<name uuid>
 means to concatenate the guest name and UUID (with a literal colon character
 between, thus I<"foo:1234-1234-1234-1234">).
 
+At the moment of writing (collectd-5.5), hostname string is limited to 62
+characters. In case when combination of fields exceeds 62 characters,
+hostname will be truncated without a warning.
+
 =item B<InterfaceFormat> B<name>|B<address>
 
 When the virt plugin logs interface data, it sets the name of the collected
index cffb9a5..a40e604 100644 (file)
@@ -197,8 +197,10 @@ static int change_basedir (const char *orig_dir)
        while ((dirlen > 0) && (dir[dirlen - 1] == '/'))
                dir[--dirlen] = '\0';
 
-       if (dirlen <= 0)
+       if (dirlen <= 0) {
+               free (dir);
                return (-1);
+       }
 
        status = chdir (dir);
        if (status == 0)
index f367ee9..ae9ab3a 100644 (file)
@@ -628,8 +628,11 @@ static int cf_include_all (oconfig_item_t *root, int depth)
                        return (-1);
 
                /* Now replace the i'th child in `root' with `new'. */
-               if (cf_ci_replace_child (root, new, i) < 0)
+               if (cf_ci_replace_child (root, new, i) < 0) {
+                       sfree (new->values);
+                       sfree (new);
                        return (-1);
+               }
 
                /* ... and go back to the new i'th child. */
                --i;
index 51cc425..2f933c0 100644 (file)
@@ -1243,8 +1243,10 @@ int plugin_register_read (const char *name,
        rf->rf_interval = plugin_get_interval ();
 
        status = plugin_insert_read (rf);
-       if (status != 0)
+       if (status != 0) {
+               sfree (rf->rf_name);
                sfree (rf);
+       }
 
        return (status);
 } /* int plugin_register_read */
@@ -1288,8 +1290,10 @@ int plugin_register_complex_read (const char *group, const char *name,
        rf->rf_ctx = plugin_get_ctx ();
 
        status = plugin_insert_read (rf);
-       if (status != 0)
+       if (status != 0) {
+               sfree (rf->rf_name);
                sfree (rf);
+       }
 
        return (status);
 } /* int plugin_register_complex_read */
@@ -1831,6 +1835,7 @@ int plugin_read_all_once (void)
                        return_status = -1;
                }
 
+               sfree (rf->rf_name);
                destroy_callback ((void *) rf);
        }
 
index 4fc96c2..3f7a596 100644 (file)
@@ -198,6 +198,7 @@ static int uc_insert (const data_set_t *ds, const value_list_t *vl,
        /* This shouldn't happen. */
        ERROR ("uc_insert: Don't know how to handle data source type %i.",
            ds->ds[i].type);
+       sfree (key_copy);
        return (-1);
     } /* switch (ds->ds[i].type) */
   } /* for (i) */
index e5a5555..4660713 100644 (file)
@@ -875,6 +875,7 @@ static void *mc_receive_thread (void *arg) /* {{{ */
     }
   } /* while (mc_receive_thread_loop != 0) */
 
+  free (mc_receive_socket_entries);
   return ((void *) 0);
 } /* }}} void *mc_receive_thread */
 
index 49454f0..606b24d 100644 (file)
@@ -213,6 +213,7 @@ static int iptables_config (const char *key, const char *value)
                    char errbuf[1024];
                    ERROR ("realloc failed: %s",
                            sstrerror (errno, errbuf, sizeof (errbuf)));
+                   sfree (temp.rule.comment);
                    return (1);
                }
 
@@ -223,6 +224,7 @@ static int iptables_config (const char *key, const char *value)
                    char errbuf[1024];
                    ERROR ("malloc failed: %s",
                            sstrerror (errno, errbuf, sizeof (errbuf)));
+                   sfree (temp.rule.comment);
                    return (1);
                }
                memcpy (final, &temp, sizeof (temp));
index 08524fd..638e3a2 100644 (file)
  */
 
 %{
-/* lex and yacc do some weird stuff, so turn off some warnings. */
-#if defined(__clang__)
-# pragma clang diagnostic ignored "-Wunused-function"
-# pragma clang diagnostic ignored "-Wunneeded-internal-declaration"
-#endif
-
 #include <stdlib.h>
 #include "oconfig.h"
 #include "aux_types.h"
@@ -56,6 +50,8 @@ static void ml_append (char *);
 %}
 %option yylineno
 %option noyywrap
+%option noinput
+%option nounput
 %x ML
 WHITE_SPACE [\ \t\b]
 NON_WHITE_SPACE [^\ \t\b]
index ab9de56..472b089 100644 (file)
@@ -62,6 +62,7 @@ static void memcached_free (memcached_t *st)
   sfree (st->socket);
   sfree (st->host);
   sfree (st->port);
+  sfree (st);
 }
 
 static int memcached_connect_unix (memcached_t *st)
index 4c6d694..f9eaf88 100644 (file)
  *      polynomial $edb88320
  */
 
-#include <sys/types.h>
+#include <stdint.h>
+#include <stddef.h>
 
-u_int32_t               crc32_buffer(const u_char *, size_t);
+uint32_t               crc32_buffer(const unsigned char *, size_t);
 static unsigned int     crc32_tab[] = {
        0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
        0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
@@ -97,11 +98,11 @@ static unsigned int     crc32_tab[] = {
 
 /* Return a 32-bit CRC of the contents of the buffer. */
 
-u_int32_t
-crc32_buffer(const u_char *s, size_t len)
+uint32_t
+crc32_buffer(const unsigned char *s, size_t len)
 {
     size_t      i;
-    u_int32_t   ret;
+    uint32_t   ret;
 
     ret = 0;
     for (i = 0;  i < len;  i++)
index 822a62b..cf60d24 100644 (file)
@@ -27,6 +27,6 @@
 #ifndef UTILS_CRC32_H
 #define UTILS_CRC32_H 1
 
-u_int32_t               crc32_buffer(const u_char *, size_t);
+uint32_t               crc32_buffer(const unsigned char *, size_t);
 
 #endif
index b6e8961..775e2e0 100644 (file)
@@ -34,7 +34,7 @@
 #include "utils_format_json.h"
 #include "utils_crc32.h"
 
-#include <sys/types.h>
+#include <stdint.h>
 #include <librdkafka/rdkafka.h>
 #include <pthread.h>
 #include <zlib.h>
@@ -44,7 +44,7 @@ struct kafka_topic_context {
 #define KAFKA_FORMAT_JSON        0
 #define KAFKA_FORMAT_COMMAND     1
 #define KAFKA_FORMAT_GRAPHITE    2
-    u_int8_t                     format;
+    uint8_t                     format;
     unsigned int                 graphite_flags;
     _Bool                        store_rates;
     rd_kafka_topic_conf_t       *conf;
@@ -52,7 +52,7 @@ struct kafka_topic_context {
     rd_kafka_conf_t             *kafka_conf;
     rd_kafka_t                  *kafka;
     int                          has_key;
-    u_int32_t                    key;
+    uint32_t                    key;
     char                        *prefix;
     char                        *postfix;
     char                         escape_char;
@@ -79,8 +79,8 @@ static int32_t kafka_partition(const rd_kafka_topic_t *rkt,
                                const void *keydata, size_t keylen,
                                int32_t partition_cnt, void *p, void *m)
 {
-    u_int32_t key = *((u_int32_t *)keydata );
-    u_int32_t target = key % partition_cnt;
+    uint32_t key = *((uint32_t *)keydata );
+    uint32_t target = key % partition_cnt;
     int32_t   i = partition_cnt;
 
     while (--i > 0 && !rd_kafka_topic_partition_available(rkt, target)) {
@@ -148,7 +148,7 @@ static int kafka_write(const data_set_t *ds, /* {{{ */
              user_data_t *ud)
 {
        int                      status = 0;
-    u_int32_t    key;
+    uint32_t    key;
     char         buffer[8192];
     size_t bfree = sizeof(buffer);
     size_t bfill = 0;