Merge pull request #1153 from mbethke/fix-unixsock
authorPierre-Yves Ritschard <pyr@spootnik.org>
Wed, 5 Aug 2015 09:08:22 +0000 (11:08 +0200)
committerPierre-Yves Ritschard <pyr@spootnik.org>
Wed, 5 Aug 2015 09:08:22 +0000 (11:08 +0200)
Fix Unixsock.pm

52 files changed:
.gitignore
.travis.yml [new file with mode: 0644]
configure.ac
contrib/redhat/collectd.spec
contrib/systemd.collectd.service
src/Makefile.am
src/apcups.c
src/ceph.c
src/collectd-nagios.c
src/collectd.conf.pod
src/curl_json.c
src/daemon/collectd.c
src/daemon/collectd.h
src/daemon/common.c
src/daemon/configfile.c
src/daemon/plugin.c
src/daemon/utils_cache.c
src/email.c
src/gmond.c
src/hddtemp.c
src/interface.c
src/iptables.c
src/ipvs.c
src/irq.c
src/liboconfig/scanner.l
src/log_logstash.c
src/madwifi.c
src/mbmon.c
src/memcached.c
src/modbus.c
src/netlink.c
src/network.c
src/ntpd.c
src/olsrd.c
src/pf.c
src/pinba.c
src/powerdns.c
src/statsd.c
src/tcpconns.c
src/teamspeak2.c
src/unixsock.c
src/utils_crc32.c
src/utils_crc32.h
src/utils_dns.c
src/varnish.c
src/write_graphite.c
src/write_kafka.c
src/write_log.c
src/write_riemann.c
src/write_sensu.c
src/write_tsdb.c
src/zookeeper.c

index 54eaa97..cf4ad15 100644 (file)
@@ -83,9 +83,18 @@ src/tests/.deps/
 src/tests/mock/.deps/
 src/tests/.dirstamp
 src/tests/mock/.dirstamp
+src/test_utils_latency
+src/test_utils_mount
+src/test_utils_vl_lookup
 test*.log
+*.trs
 
 # new daemon repo
 src/daemon/.deps/
 src/daemon/.dirstamp
 src/daemon/collectd
+src/daemon/test_common
+src/daemon/test_meta_data
+src/daemon/test_utils_avltree
+src/daemon/test_utils_heap
+src/daemon/test_utils_subst
diff --git a/.travis.yml b/.travis.yml
new file mode 100644 (file)
index 0000000..09adb4d
--- /dev/null
@@ -0,0 +1,25 @@
+sudo: false
+compiler:
+  - gcc
+  - clang
+addons:
+  apt:
+    packages:
+      - iptables-dev
+      - libcap-dev
+      - libdbi-dev
+      - libhiredis-dev
+      - libnfnetlink-dev
+      - libnotify-dev
+      - libpcap-dev
+      - libperl-dev
+      - libprotobuf-c0-dev
+      - librrd-dev
+      - libsnmp-dev
+      - libudev-dev
+      - libvarnishapi-dev
+      - libyajl-dev
+      - linux-libc-dev
+      - protobuf-c-compiler
+language: c
+script: sh build.sh && ./configure && make distcheck
index 6ee6e9a..9c2f32a 100644 (file)
@@ -90,12 +90,12 @@ case $host_os in
 esac
 AC_MSG_RESULT([$ac_system])
 
-AM_CONDITIONAL([BUILD_LINUX],[test "x$x$ac_system" = "xLinux"])
-AM_CONDITIONAL([BUILD_SOLARIS],[test "x$x$ac_system" = "xSolaris"])
-AM_CONDITIONAL([BUILD_DARWIN],[test "x$x$ac_system" = "xDarwin"])
-AM_CONDITIONAL([BUILD_OPENBSD],[test "x$x$ac_system" = "xOpenBSD"])
-AM_CONDITIONAL([BUILD_AIX],[test "x$x$ac_system" = "xAIX"])
-AM_CONDITIONAL([BUILD_FREEBSD],[test "x$x$ac_system" = "xFreeBSD"])
+AM_CONDITIONAL([BUILD_LINUX],[test "x$ac_system" = "xLinux"])
+AM_CONDITIONAL([BUILD_SOLARIS],[test "x$ac_system" = "xSolaris"])
+AM_CONDITIONAL([BUILD_DARWIN],[test "x$ac_system" = "xDarwin"])
+AM_CONDITIONAL([BUILD_OPENBSD],[test "x$ac_system" = "xOpenBSD"])
+AM_CONDITIONAL([BUILD_AIX],[test "x$ac_system" = "xAIX"])
+AM_CONDITIONAL([BUILD_FREEBSD],[test "x$ac_system" = "xFreeBSD"])
 
 if test "x$ac_system" = "xLinux"
 then
@@ -2562,7 +2562,7 @@ then
        SAVE_CPPFLAGS="$CPPFLAGS"
        CPPFLAGS="$CPPFLAGS $with_libmodbus_cflags"
 
-       AC_CHECK_HEADERS(modbus/modbus.h, [], [with_libmodbus="no (modbus/modbus.h not found)"])
+       AC_CHECK_HEADERS(modbus.h, [], [with_libmodbus="no (modbus.h not found)"])
 
        CPPFLAGS="$SAVE_CPPFLAGS"
 fi
@@ -3749,8 +3749,8 @@ fi
 # }}} --with-python
 
 # --with-librabbitmq {{{
-with_librabbitmq_cppflags=""
-with_librabbitmq_ldflags=""
+with_librabbitmq_cppflags="-I/usr/local/include"
+with_librabbitmq_ldflags="-L/usr/local/lib"
 AC_ARG_WITH(librabbitmq, [AS_HELP_STRING([--with-librabbitmq@<:@=PREFIX@:>@], [Path to librabbitmq.])],
 [
        if test "x$withval" != "xno" && test "x$withval" != "xyes"
@@ -4838,11 +4838,11 @@ then
 
        CPPFLAGS="$CPPFLAGS $with_libvarnish_cflags"
 
-       AC_CHECK_HEADERS(varnish/vapi/vsc.h,
+       AC_CHECK_HEADERS(vapi/vsc.h,
                [AC_DEFINE([HAVE_VARNISH_V4], [1], [Varnish 4 API support])],
-               [AC_CHECK_HEADERS(varnish/vsc.h,
+               [AC_CHECK_HEADERS(vsc.h,
                        [AC_DEFINE([HAVE_VARNISH_V3], [1], [Varnish 3 API support])],
-                       [AC_CHECK_HEADERS(varnish/varnishapi.h,
+                       [AC_CHECK_HEADERS(varnishapi.h,
                                [AC_DEFINE([HAVE_VARNISH_V2], [1], [Varnish 2 API support])],
                                [with_libvarnish="no (found none of the varnish header files)"])])])
 
@@ -5352,15 +5352,15 @@ fi
 
 if test "x$ac_system" = "xAIX"
 then
-        plugin_tcpconns="yes"
-        plugin_ipc="yes"
+       plugin_tcpconns="yes"
+       plugin_ipc="yes"
 fi
 
 # FreeBSD
 
 if test "x$ac_system" = "xFreeBSD"
 then
-        plugin_zfs_arc="yes"
+       plugin_zfs_arc="yes"
 fi
 
 
index 5e83b0f..2252181 100644 (file)
@@ -68,6 +68,7 @@
 %{?el7:%global _has_atasmart 1}
 %{?el7:%global _has_hiredis 1}
 %{?el7:%global _has_asm_msr_index 1}
+%{?el7:%global _has_libmosquitto 1}
 
 # plugins enabled by default
 %define with_aggregation 0%{!?_without_aggregation:1}
 %define with_memory 0%{!?_without_memory:1}
 %define with_multimeter 0%{!?_without_multimeter:1}
 %define with_modbus 0%{!?_without_modbus:0%{?_has_libmodbus}}
+%define with_mqtt 0%{!?_without_mqtt:0%{?_has_libmosquitto}}
 %define with_mysql 0%{!?_without_mysql:1}
 %define with_netlink 0%{!?_without_netlink:0%{?_has_iproute}}
 %define with_network 0%{!?_without_network:1}
@@ -516,6 +518,16 @@ MySQL querying plugin. This plugin provides data of issued commands, called
 handlers and database traffic.
 %endif
 
+%if %{with_mqtt}
+%package mqtt
+Summary:       mqtt plugin for collectd
+Group:         System Environment/Daemons
+Requires:      %{name}%{?_isa} = %{version}-%{release}
+BuildRequires: mosquitto-devel
+%description mqtt
+The MQTT plugin publishes and subscribes to MQTT topics.
+%endif
+
 %if %{with_netlink}
 %package netlink
 Summary:       netlink plugin for collectd
@@ -1167,6 +1179,12 @@ Collectd utilities
 %define _with_multimeter --disable-multimeter
 %endif
 
+%if %{with_mqtt}
+%define _with_mqtt --enable-mqtt
+%else
+%define _with_mqtt --disable-mqtt
+%endif
+
 %if %{with_mysql}
 %define _with_mysql --enable-mysql
 %else
@@ -1647,6 +1665,7 @@ Collectd utilities
        %{?_with_mic} \
        %{?_with_modbus} \
        %{?_with_multimeter} \
+       %{?_with_mqtt} \
        %{?_with_mysql} \
        %{?_with_netapp} \
        %{?_with_netlink} \
@@ -2205,6 +2224,11 @@ fi
 %{_libdir}/%{name}/modbus.so
 %endif
 
+%if %{with_mqtt}
+%files mqtt
+%{_libdir}/%{name}/mqtt.so
+%endif
+
 %if %{with_mysql}
 %files mysql
 %{_libdir}/%{name}/mysql.so
@@ -2346,6 +2370,7 @@ fi
 %changelog
 #* TODO: next feature release changelog
 #- New upstream version
+#- New plugins enabled by default: mqtt
 #- New plugins disabled by default: zone
 #
 * Wed May 27 2015 Marc Fournier <marc.fournier@camptocamp.com> 5.5.0-1
index b046192..96df8a5 100644 (file)
@@ -5,6 +5,8 @@ Requires=local-fs.target network.target
 
 [Service]
 ExecStart=/usr/sbin/collectd
+EnvironmentFile=-/etc/sysconfig/collectd
+EnvironmentFile=-/etc/default/collectd
 
 # Tell systemd it will receive a notification from collectd over it's control
 # socket once the daemon is ready. See systemd.service(5) for more details.
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 dc533f1..718061a 100644 (file)
@@ -32,9 +32,6 @@
 #if HAVE_SYS_TYPES_H
 # include <sys/types.h>
 #endif
-#if HAVE_SYS_SOCKET_H
-# include <sys/socket.h>
-#endif
 #if HAVE_NETDB_H
 # include <netdb.h>
 #endif
index d928a7b..419ca6e 100644 (file)
@@ -43,7 +43,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <strings.h>
-#include <sys/socket.h>
 #include <sys/time.h>
 #include <sys/types.h>
 #include <sys/un.h>
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 978c1c5..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
@@ -7611,7 +7615,7 @@ Synopsis:
 
 Values are submitted to I<Sorted Sets>, using the metric name as the key, and
 the timestamp as the score. Retrieving a date range can then be done using the
-C<ZRANGEBYSCORE> I<Redis> command. Additionnally, all the identifiers of these
+C<ZRANGEBYSCORE> I<Redis> command. Additionally, all the identifiers of these
 I<Sorted Sets> are kept in a I<Set> called C<collectd/values> (or
 C<${prefix}/values> if the B<Prefix> option was specified) and can be retrieved
 using the C<SMEMBERS> I<Redis> command. You can specify the database to use 
@@ -7631,9 +7635,9 @@ options are available:
 =item B<Node> I<Nodename>
 
 The B<Node> block identifies a new I<Redis> node, that is a new I<Redis>
-instance running in an specified host and port. The name for node is a
+instance running on a specified host and port. The node name is a
 canonical identifier which is used as I<plugin instance>. It is limited to
-64E<nbsp>characters in length.
+51E<nbsp>characters in length.
 
 =item B<Host> I<Hostname>
 
index 5aceae4..8063242 100644 (file)
@@ -28,7 +28,6 @@
 #include "utils_avltree.h"
 #include "utils_complain.h"
 
-#include <sys/socket.h>
 #include <sys/types.h>
 #include <sys/un.h>
 
index cffb9a5..58325b9 100644 (file)
@@ -32,7 +32,6 @@
 #include "configfile.h"
 
 #include <sys/types.h>
-#include <sys/socket.h>
 #include <sys/un.h>
 #include <netdb.h>
 
@@ -197,8 +196,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 80b753c..66b4856 100644 (file)
@@ -95,6 +95,9 @@
 #  include <time.h>
 # endif
 #endif
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
 
 #if HAVE_ASSERT_H
 # include <assert.h>
index abe9a6e..8f22011 100644 (file)
@@ -46,7 +46,6 @@
 
 /* for getaddrinfo */
 #include <sys/types.h>
-#include <sys/socket.h>
 #include <netdb.h>
 
 #if HAVE_NETINET_IN_H
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..be3f03f 100644 (file)
@@ -241,13 +241,13 @@ static void destroy_read_heap (void) /* {{{ */
 
        while (42)
        {
-               callback_func_t *cf;
+               read_func_t *rf;
 
-               cf = c_heap_get_root (read_heap);
-               if (cf == NULL)
+               rf = c_heap_get_root (read_heap);
+               if (rf == NULL)
                        break;
-
-               destroy_callback (cf);
+               sfree (rf->rf_name);
+               destroy_callback ((callback_func_t *) rf);
        }
 
        c_heap_destroy (read_heap);
@@ -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 365af27..1bf9add 100644 (file)
@@ -50,7 +50,6 @@
 # include <pthread.h>
 #endif
 
-#include <sys/socket.h>
 #include <sys/un.h>
 #include <sys/select.h>
 
index e5a5555..c778d48 100644 (file)
@@ -33,9 +33,6 @@
 #if HAVE_PTHREAD_H
 # include <pthread.h>
 #endif
-#if HAVE_SYS_SOCKET_H
-# include <sys/socket.h>
-#endif
 #if HAVE_NETDB_H
 # include <netdb.h>
 #endif
@@ -875,6 +872,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 82c158c..3de18fd 100644 (file)
@@ -35,7 +35,6 @@
 #include "configfile.h"
 
 # include <netdb.h>
-# include <sys/socket.h>
 # include <netinet/in.h>
 # include <netinet/tcp.h>
 # include <libgen.h> /* for basename */
index df8ffb4..e17711e 100644 (file)
@@ -31,9 +31,6 @@
 #if HAVE_SYS_TYPES_H
 #  include <sys/types.h>
 #endif
-#if HAVE_SYS_SOCKET_H
-#  include <sys/socket.h>
-#endif
 
 /* One cannot include both. This sucks. */
 #if HAVE_LINUX_IF_H
index 49454f0..806b7a4 100644 (file)
@@ -29,8 +29,6 @@
 #include "plugin.h"
 #include "configfile.h"
 
-#include <sys/socket.h>
-
 #include <libiptc/libiptc.h>
 #include <libiptc/libip6tc.h>
 
@@ -213,6 +211,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 +222,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 38e4641..4345a46 100644 (file)
@@ -37,9 +37,6 @@
 #if HAVE_ARPA_INET_H
 # include <arpa/inet.h>
 #endif /* HAVE_ARPA_INET_H */
-#if HAVE_SYS_SOCKET_H
-# include <sys/socket.h>
-#endif /* HAVE_SYS_SOCKET_H */
 #if HAVE_NETINET_IN_H
 # include <netinet/in.h>
 #endif /* HAVE_NETINET_IN_H */
index 1168b97..6afacf0 100644 (file)
--- a/src/irq.c
+++ b/src/irq.c
@@ -155,6 +155,10 @@ static int irq_read (void)
                if (irq_name[irq_name_len - 1] != ':')
                        continue;
 
+               /* Is it the the ARM fast interrupt (FIQ)? */
+               if (irq_name_len == 4 && (strncmp(irq_name, "FIQ:", 4) == 0))
+                       continue;
+
                irq_name[irq_name_len - 1] = 0;
                irq_name_len--;
 
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 61e7f48..2883e6c 100644 (file)
@@ -208,7 +208,7 @@ static void log_logstash_log (int severity, const char *msg,
 {
        yajl_gen g;
 #if !defined(HAVE_YAJL_V2)
-       yajl_gen_config conf;
+       yajl_gen_config conf = {};
 
        conf.beautify = 0;
 #endif
@@ -252,7 +252,7 @@ static int log_logstash_notification (const notification_t *n,
 #if HAVE_YAJL_V2
        g = yajl_gen_alloc(NULL);
 #else
-       yajl_gen_config conf;
+       yajl_gen_config conf = {};
 
        conf.beautify = 0;
        g = yajl_gen_alloc(&conf, NULL);
index d3a5803..bb33b15 100644 (file)
@@ -96,7 +96,6 @@
 
 #include <dirent.h>
 #include <sys/ioctl.h>
-#include <sys/socket.h>
 
 #if !KERNEL_LINUX
 # error "No applicable input method."
index d23062d..5e87f00 100644 (file)
@@ -29,7 +29,6 @@
 #include "configfile.h"
 
 #include <netdb.h>
-#include <sys/socket.h>
 #include <netinet/in.h>
 #include <netinet/tcp.h>
 
index ab9de56..f684abf 100644 (file)
@@ -34,7 +34,6 @@
 #include "configfile.h"
 
 #include <netdb.h>
-#include <sys/socket.h>
 #include <sys/un.h>
 #include <netinet/in.h>
 #include <netinet/tcp.h>
@@ -62,6 +61,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 4a98e53..cfc6331 100644 (file)
@@ -27,7 +27,7 @@
 
 #include <netdb.h>
 
-#include <modbus/modbus.h>
+#include <modbus.h>
 
 #ifndef LIBMODBUS_VERSION_CHECK
 /* Assume version 2.0.3 */
index aa9760f..e1f378d 100644 (file)
@@ -30,7 +30,6 @@
 #include "common.h"
 
 #include <asm/types.h>
-#include <sys/socket.h>
 
 #include <linux/netlink.h>
 #include <linux/rtnetlink.h>
index 0c74e22..9169000 100644 (file)
@@ -39,9 +39,6 @@
 #if HAVE_PTHREAD_H
 # include <pthread.h>
 #endif
-#if HAVE_SYS_SOCKET_H
-# include <sys/socket.h>
-#endif
 #if HAVE_NETDB_H
 # include <netdb.h>
 #endif
index 952ab7c..dbde660 100644 (file)
@@ -38,9 +38,6 @@
 #if HAVE_NETDB_H
 # include <netdb.h>
 #endif
-#if HAVE_SYS_SOCKET_H
-# include <sys/socket.h>
-#endif
 #if HAVE_NETINET_IN_H
 # include <netinet/in.h>
 #endif
index 6d0576c..bbf387f 100644 (file)
@@ -30,7 +30,6 @@
 
 #include <sys/types.h>
 #include <netdb.h>
-#include <sys/socket.h>
 #include <netinet/in.h>
 #include <netinet/tcp.h>
 
index 29f3a3d..d11bd8a 100644 (file)
--- a/src/pf.c
+++ b/src/pf.c
@@ -26,9 +26,6 @@
 #if HAVE_SYS_IOCTL_H
 # include <sys/ioctl.h>
 #endif
-#if HAVE_SYS_SOCKET_H
-# include <sys/socket.h>
-#endif
 #if HAVE_NET_IF_H
 # include <net/if.h>
 #endif
index 9f0a800..b6e7b15 100644 (file)
@@ -29,7 +29,6 @@
 #include "configfile.h"
 
 #include <pthread.h>
-#include <sys/socket.h>
 #include <netdb.h>
 #include <poll.h>
 
index 7b7cab3..5ea1b09 100644 (file)
@@ -37,7 +37,6 @@
 #include <string.h>
 #include <errno.h>
 #include <sys/types.h>
-#include <sys/socket.h>
 #include <sys/un.h>
 
 #ifndef UNIX_PATH_MAX
index 5b0bdd6..9a6da1d 100644 (file)
@@ -35,7 +35,6 @@
 #include <pthread.h>
 
 #include <sys/types.h>
-#include <sys/socket.h>
 #include <netdb.h>
 #include <poll.h>
 
index 5d4bb69..8f40be6 100644 (file)
 
 #if KERNEL_LINUX
 # include <asm/types.h>
-/* sys/socket.h is necessary to compile when using netlink on older systems. */
-# include <sys/socket.h>
 # include <linux/netlink.h>
 #if HAVE_LINUX_INET_DIAG_H
 # include <linux/inet_diag.h>
 #endif
-# include <sys/socket.h>
 # include <arpa/inet.h>
 /* #endif KERNEL_LINUX */
 
@@ -90,9 +87,6 @@
 #if HAVE_SYS_TYPES_H
 # include <sys/types.h>
 #endif
-#if HAVE_SYS_SOCKET_H
-# include <sys/socket.h>
-#endif
 #if HAVE_NET_IF_H
 # include <net/if.h>
 #endif
 /* This is for OpenBSD and NetBSD. */
 #elif HAVE_LIBKVM_NLIST
 # include <sys/queue.h>
-# include <sys/socket.h>
 # include <net/route.h>
 # include <netinet/in.h>
 # include <netinet/in_systm.h>
index 201e182..56e8d14 100644 (file)
@@ -28,7 +28,6 @@
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <sys/types.h>
-#include <sys/socket.h>
 #include <netdb.h>
 
 /*
index 664c018..e6c75a6 100644 (file)
@@ -39,7 +39,6 @@
 /* Folks without pthread will need to disable this plugin. */
 #include <pthread.h>
 
-#include <sys/socket.h>
 #include <sys/stat.h>
 #include <sys/un.h>
 
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 f83fc02..4c763a1 100644 (file)
 #include "plugin.h"
 #include "common.h"
 
-#if HAVE_SYS_SOCKET_H
-# include <sys/socket.h>
-#endif
-
 #if HAVE_NET_IF_ARP_H
 # include <net/if_arp.h>
 #endif
index a94cb80..c6c4df0 100644 (file)
 #include "configfile.h"
 
 #if HAVE_VARNISH_V4
-#include <varnish/vapi/vsm.h>
-#include <varnish/vapi/vsc.h>
+#include <vapi/vsm.h>
+#include <vapi/vsc.h>
 typedef struct VSC_C_main c_varnish_stats_t;
 #endif
 
 #if HAVE_VARNISH_V3
-#include <varnish/varnishapi.h>
-#include <varnish/vsc.h>
+#include <varnishapi.h>
+#include <vsc.h>
 typedef struct VSC_C_main c_varnish_stats_t;
 #endif
 
 #if HAVE_VARNISH_V2
-#include <varnish/varnishapi.h>
+#include <varnishapi.h>
 typedef struct varnish_stats c_varnish_stats_t;
 #endif
 
index 41451a8..7fc9eb9 100644 (file)
 /* Folks without pthread will need to disable this plugin. */
 #include <pthread.h>
 
-#include <sys/socket.h>
 #include <netdb.h>
 
-#ifndef WG_DEFAULT_NODE
-# define WG_DEFAULT_NODE "localhost"
-#endif
-
-#ifndef WG_DEFAULT_SERVICE
-# define WG_DEFAULT_SERVICE "2003"
-#endif
-
-#ifndef WG_DEFAULT_PROTOCOL
-# define WG_DEFAULT_PROTOCOL "tcp"
-#endif
-
-#ifndef WG_DEFAULT_LOG_SEND_ERRORS
-# define WG_DEFAULT_LOG_SEND_ERRORS 1
-#endif
-
-#ifndef WG_DEFAULT_ESCAPE
-# define WG_DEFAULT_ESCAPE '_'
-#endif
+#define WG_DEFAULT_NODE "localhost"
+#define WG_DEFAULT_SERVICE "2003"
+#define WG_DEFAULT_PROTOCOL "tcp"
+#define WG_DEFAULT_LOG_SEND_ERRORS 1
+#define WG_DEFAULT_ESCAPE '_'
 
 /* Ethernet - (IPv6 + TCP) = 1500 - (40 + 32) = 1428 */
-#ifndef WG_SEND_BUF_SIZE
-# define WG_SEND_BUF_SIZE 1428
-#endif
+#define WG_SEND_BUF_SIZE 1428
 
-#ifndef WG_MIN_RECONNECT_INTERVAL
-# define WG_MIN_RECONNECT_INTERVAL TIME_T_TO_CDTIME_T (1)
-#endif
+#define WG_MIN_RECONNECT_INTERVAL TIME_T_TO_CDTIME_T (1)
 
 /*
  * Private variables
@@ -134,13 +115,11 @@ static int wg_send_buffer (struct wg_callback *cb)
     status = swrite (cb->sock_fd, cb->send_buf, strlen (cb->send_buf));
     if (status < 0)
     {
-        const char *protocol = cb->protocol ? cb->protocol : WG_DEFAULT_PROTOCOL;
-
         if (cb->log_send_errors)
         {
             char errbuf[1024];
             ERROR ("write_graphite plugin: send to %s:%s (%s) failed with status %zi (%s)",
-                    cb->node, cb->service, protocol,
+                    cb->node, cb->service, cb->protocol,
                     status, sstrerror (errno, errbuf, sizeof (errbuf)));
         }
 
@@ -193,10 +172,6 @@ static int wg_callback_init (struct wg_callback *cb)
     cdtime_t now;
     int status;
 
-    const char *node = cb->node ? cb->node : WG_DEFAULT_NODE;
-    const char *service = cb->service ? cb->service : WG_DEFAULT_SERVICE;
-    const char *protocol = cb->protocol ? cb->protocol : WG_DEFAULT_PROTOCOL;
-
     char connerr[1024] = "";
 
     if (cb->sock_fd > 0)
@@ -215,18 +190,18 @@ static int wg_callback_init (struct wg_callback *cb)
 #endif
     ai_hints.ai_family = AF_UNSPEC;
 
-    if (0 == strcasecmp ("tcp", protocol))
+    if (0 == strcasecmp ("tcp", cb->protocol))
         ai_hints.ai_socktype = SOCK_STREAM;
     else
         ai_hints.ai_socktype = SOCK_DGRAM;
 
     ai_list = NULL;
 
-    status = getaddrinfo (node, service, &ai_hints, &ai_list);
+    status = getaddrinfo (cb->node, cb->service, &ai_hints, &ai_list);
     if (status != 0)
     {
         ERROR ("write_graphite plugin: getaddrinfo (%s, %s, %s) failed: %s",
-                node, service, protocol, gai_strerror (status));
+                cb->node, cb->service, cb->protocol, gai_strerror (status));
         return (-1);
     }
 
@@ -265,14 +240,14 @@ static int wg_callback_init (struct wg_callback *cb)
             sstrerror (errno, connerr, sizeof (connerr));
         c_complain (LOG_ERR, &cb->init_complaint,
                   "write_graphite plugin: Connecting to %s:%s via %s failed. "
-                  "The last error was: %s", node, service, protocol, connerr);
+                  "The last error was: %s", cb->node, cb->service, cb->protocol, connerr);
         return (-1);
     }
     else
     {
         c_release (LOG_INFO, &cb->init_complaint,
                 "write_graphite plugin: Successfully connected to %s:%s via %s.",
-                node, service, protocol);
+                cb->node, cb->service, cb->protocol);
     }
 
     wg_reset_buffer (cb);
@@ -383,9 +358,7 @@ static int wg_send_message (char const *message, struct wg_callback *cb)
     cb->send_buf_free -= message_len;
 
     DEBUG ("write_graphite plugin: [%s]:%s (%s) buf %zu/%zu (%.1f %%) \"%s\"",
-            cb->node,
-            cb->service,
-            cb->protocol,
+            cb->node, cb->service, cb->protocol,
             cb->send_buf_fill, sizeof (cb->send_buf),
             100.0 * ((double) cb->send_buf_fill) / ((double) sizeof (cb->send_buf)),
             message);
@@ -486,9 +459,9 @@ static int wg_config_node (oconfig_item_t *ci)
     memset (cb, 0, sizeof (*cb));
     cb->sock_fd = -1;
     cb->name = NULL;
-    cb->node = NULL;
-    cb->service = NULL;
-    cb->protocol = NULL;
+    cb->node = strdup (WG_DEFAULT_NODE);
+    cb->service = strdup (WG_DEFAULT_SERVICE);
+    cb->protocol = strdup (WG_DEFAULT_PROTOCOL);
     cb->log_send_errors = WG_DEFAULT_LOG_SEND_ERRORS;
     cb->prefix = NULL;
     cb->postfix = NULL;
@@ -566,9 +539,7 @@ static int wg_config_node (oconfig_item_t *ci)
     /* FIXME: Legacy configuration syntax. */
     if (cb->name == NULL)
         ssnprintf (callback_name, sizeof (callback_name), "write_graphite/%s/%s/%s",
-                cb->node != NULL ? cb->node : WG_DEFAULT_NODE,
-                cb->service != NULL ? cb->service : WG_DEFAULT_SERVICE,
-                cb->protocol != NULL ? cb->protocol : WG_DEFAULT_PROTOCOL);
+                cb->node, cb->service, cb->protocol);
     else
         ssnprintf (callback_name, sizeof (callback_name), "write_graphite/%s",
                 cb->name);
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;
index e37aae9..ebf0e12 100644 (file)
@@ -35,7 +35,6 @@
 /* Folks without pthread will need to disable this plugin. */
 #include <pthread.h>
 
-#include <sys/socket.h>
 #include <netdb.h>
 
 #define WL_BUF_SIZE 8192
index 26fa3f4..73d202c 100644 (file)
@@ -33,7 +33,6 @@
 #include "utils_cache.h"
 #include "riemann.pb-c.h"
 
-#include <sys/socket.h>
 #include <arpa/inet.h>
 #include <errno.h>
 #include <netdb.h>
index 791acb3..67c0496 100644 (file)
@@ -29,7 +29,6 @@
 #include "common.h"
 #include "configfile.h"
 #include "utils_cache.h"
-#include <sys/socket.h>
 #include <arpa/inet.h>
 #include <errno.h>
 #include <netdb.h>
index 2c39ec1..4a62614 100644 (file)
@@ -49,7 +49,6 @@
 #include "utils_cache.h"
 
 #include <pthread.h>
-#include <sys/socket.h>
 #include <netdb.h>
 
 #ifndef WT_DEFAULT_NODE
index 63ee6c9..abdbf20 100644 (file)
@@ -29,7 +29,6 @@
 #include "plugin.h"
 
 #include <netdb.h>
-#include <sys/socket.h>
 #include <sys/un.h>
 #include <netinet/in.h>
 #include <netinet/tcp.h>