Merge pull request #2301 from rpv-tomsk/fix-apcups
authorRuben Kerkhof <ruben@rubenkerkhof.com>
Sun, 2 Jul 2017 11:34:05 +0000 (13:34 +0200)
committerGitHub <noreply@github.com>
Sun, 2 Jul 2017 11:34:05 +0000 (13:34 +0200)
apcups: Fix reconnect implementation

19 files changed:
ChangeLog
Makefile.am
configure.ac
m4/ax_compiler_vendor.m4 [new file with mode: 0644]
src/amqp.c
src/bind.c
src/collectd-snmp.pod
src/collectd.conf.pod
src/daemon/utils_cache.c
src/email.c
src/exec.c
src/intel_rdt.c
src/ipvs.c
src/openldap.c
src/snmp_agent.c
src/unixsock.c
src/utils_format_graphite.c
src/write_mongodb.c
version-gen.sh

index 9f1b639..b8755d9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,50 @@
+2017-06-06, Version 5.7.2
+       * Build system: The Notify Email plugin is no longer linked with
+         indirect dependencies. Thanks to Marc Fournier.
+       * collectd: A race condition when calculating a metric's rate has been
+         fixed. Thanks to Florian Forster. #1193
+       * AMQP, Exec, UnixSock, Write Kafka plugins: Parsing of the PUTVAL
+         command with multiple values has been fixed. Thanks to Florian
+         Forster. #2274
+       * AMQP plugin: The "ExchangeType" option is now also valid for
+         publishers. Thanks to Florian Forster. #2286
+       * BIND plugin: Fix parsing of the sample time provided by BIND.
+         Previously, the time was assumed to be in the local timezone when in
+         fact it was in UTC. Thanks to Ed Ravin. #1268
+       * BIND plugin: Memory leaks have been fixed. Thanks to Ruben Kerkhof.
+         #2303
+       * cURL-JSON plugin: Handling of arrays has been fixed. Thanks to Florian
+         Forster. #2266
+       * DPDKStat plugin: Error handling during initialization has been
+         improved. Thanks to Ruben Kerkhof.
+       * DPDKStat plugin: Handling of a number of metrics has been improved,
+         for example "rx_q0bytes". Thanks to Przemyslaw Szczerbik. #2167
+       * Intel RDT plugin: Configuration handling has been changed to be more
+         graceful. Thanks to Maryam Tahhan. #2165
+       * Log Logstash plugin: If writing the log entry fails, print it to
+         "STDERR" instead. Thanks to Marc Fournier.
+       * LogFile plugin: If writing to the file fails, print log messages on
+         "STDERR" instead. Thanks to Marc Fournier.
+       * memcachec, Tail plugins: A resource leak in the matching
+         infrastructure has been fixed. Thanks to Krzysztof Matczak. #2192
+       * MQTT plugin: Invalid symbols in topic names are now replaced and a
+         resource leak has been fixed. Thanks to Denys Fedoryshchenko. #2123
+       * Network plugin: A potential endless-loop has been fixed. This can be
+         triggered remotely by sending a signed network packet to a server
+         which is not set up to check signatures. Thanks to Marcin Kozlowski
+         and Pavel Rochnyack. #2174, #2233, CVE-2017-7401
+       * Perl plugin: A potential double-free has been fixed. Thanks to Florian
+         Forster. #2278
+       * Processes plugin: A compilation error on AIX has been fixed. Thanks to
+         Pavel Rochnyack. #2210
+       * SMART plugin: A check for the "CAP_SYS_RAWIO" capability has been
+         added. Thanks to Marc Fournier.
+       * Write Graphite plugin: Error handling in the case that calculating a
+         metric's rate fails has been improved. Previously, the raw counter
+         values were sent to Graphite. Thanks to Iain Buclaw. #2209
+       * Write Prometheus plugin: An incorrect use of "realloc(3)" has been
+         fixed. Thanks to Florian Forster. #2275
+
 2017-01-23, Version 5.7.1
        * collectd: Handling of boolean configuration options has been unified.
          Thanks to Sebastian Harl. #2083, #2098
index 37125bc..719cfb8 100644 (file)
@@ -940,10 +940,6 @@ endif
 if BUILD_PLUGIN_IPVS
 pkglib_LTLIBRARIES += ipvs.la
 ipvs_la_SOURCES = src/ipvs.c
-ipvs_la_CFLAGS = $(AM_CFLAGS)
-if IP_VS_H_NEEDS_KERNEL_CFLAGS
-ipvs_la_CFLAGS += $(KERNEL_CFLAGS)
-endif
 ipvs_la_LDFLAGS = $(PLUGIN_LDFLAGS)
 endif
 
@@ -1389,9 +1385,6 @@ python_la_SOURCES = \
        src/pyvalues.c \
        src/cpython.h
 python_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBPYTHON_CPPFLAGS)
-if COMPILER_IS_GCC
-python_la_CPPFLAGS += -fno-strict-aliasing -Wno-strict-aliasing
-endif
 python_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(LIBPYTHON_LDFLAGS)
 endif
 
@@ -1493,9 +1486,9 @@ endif
 if BUILD_PLUGIN_SNMP_AGENT
 pkglib_LTLIBRARIES += snmp_agent.la
 snmp_agent_la_SOURCES = src/snmp_agent.c
-snmp_agent_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBNETSNMP_CPPFLAGS)
-snmp_agent_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBNETSNMP_LDFLAGS)
-snmp_agent_la_LIBADD = $(BUILD_WITH_LIBNETSNMP_LIBS)
+snmp_agent_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBNETSNMPAGENT_CPPFLAGS)
+snmp_agent_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBNETSNMPAGENT_LDFLAGS)
+snmp_agent_la_LIBADD = $(BUILD_WITH_LIBNETSNMPAGENT_LIBS)
 endif
 
 if BUILD_PLUGIN_STATSD
index b4ef3d5..3357375 100644 (file)
@@ -11,8 +11,6 @@ dnl we don't really need the 'u' even in older toolchains.  Then there is
 dnl older libtool, which spelled it AR_FLAGS
 m4_divert_text([DEFAULTS], [: "${ARFLAGS=cr} ${AR_FLAGS=cr}"])
 
-m4_include([m4/ax_compare_version.m4])
-
 LT_INIT([dlopen disable-static])
 
 AM_INIT_AUTOMAKE([subdir-objects tar-pax dist-bzip2 no-dist-gzip foreign])
@@ -29,6 +27,9 @@ AC_SYS_LARGEFILE
 AC_PROG_CC_C99([],
   [AC_MSG_ERROR([No compiler found that supports C99])]
 )
+
+AX_COMPILER_VENDOR
+
 AC_PROG_CXX
 AC_PROG_CPP
 AC_PROG_EGREP
@@ -36,7 +37,6 @@ AC_PROG_INSTALL
 AC_PROG_LN_S
 AC_PROG_MAKE_SET
 AM_PROG_CC_C_O
-AM_CONDITIONAL([COMPILER_IS_GCC], [test "x$GCC" = "xyes"])
 
 AC_PROG_LEX
 AC_PROG_YACC
@@ -62,9 +62,9 @@ if test "x$collectd_cv_prog_bison" = "xno" && test ! -f "${srcdir}/src/liboconfi
   AC_MSG_ERROR([bison is missing and you do not have ${srcdir}/src/liboconfig/parser.c. Please install bison])
 fi
 
-AS_IF([test "x$lt_cv_dlopen" = "xno"],
-  [AC_MSG_ERROR([Your system does not support dlopen])]
-)
+if test "x$lt_cv_dlopen" = "xno"; then
+  AC_MSG_ERROR([Your system does not support dlopen])
+fi
 
 AC_SUBST([DLOPEN_LIBS], [$lt_cv_dlopen_libs])
 
@@ -112,15 +112,6 @@ AM_CONDITIONAL([BUILD_LINUX], [test "x$ac_system" = "xLinux"])
 AM_CONDITIONAL([BUILD_OPENBSD], [test "x$ac_system" = "xOpenBSD"])
 AM_CONDITIONAL([BUILD_SOLARIS], [test "x$ac_system" = "xSolaris"])
 
-if test "x$ac_system" = "xLinux"; then
-  AC_ARG_VAR([KERNEL_DIR], [path to Linux kernel sources])
-  if test "x$KERNEL_DIR" = "x"; then
-    KERNEL_DIR="/lib/modules/`uname -r`/source"
-  fi
-  KERNEL_CFLAGS="-I$KERNEL_DIR/include"
-  AC_SUBST([KERNEL_CFLAGS])
-fi
-
 if test "x$ac_system" = "xSolaris"; then
   AC_DEFINE([_POSIX_PTHREAD_SEMANTICS], [1], [Define to enforce POSIX thread semantics under Solaris.])
   AC_DEFINE([_REENTRANT], [1], [Define to enable reentrancy interfaces.])
@@ -361,7 +352,7 @@ AC_CHECK_HEADERS([netinet/udp.h], [], [],
 AC_CHECK_HEADERS([sys/dkstat.h])
 if test "x$ac_system" = "xDarwin"; then
   AC_CHECK_HEADERS(
-    [[ \
+    [ \
       mach/mach_init.h \
       mach/host_priv.h \
       mach/mach_error.h \
@@ -385,7 +376,7 @@ if test "x$ac_system" = "xDarwin"; then
       IOKit/ps/IOPSKeys.h \
       IOKit/IOBSD.h \
       IOKit/storage/IOBlockStorageDriver.h
-    ]]
+    ]
   )
 
   # For the battery plugin
@@ -461,7 +452,7 @@ if test "x$ac_system" = "xLinux"; then
       #endif
     ]]
   )
-  
+
   AC_CHECK_HEADERS([linux/inet_diag.h], [], [],
     [[
       #if HAVE_SYS_TYPES_H
@@ -472,7 +463,7 @@ if test "x$ac_system" = "xLinux"; then
       #endif
     ]]
   )
-  
+
   AC_CHECK_HEADERS([linux/netdevice.h], [], [],
     [[
       #if HAVE_SYS_TYPES_H
@@ -486,7 +477,7 @@ if test "x$ac_system" = "xLinux"; then
       #endif
     ]]
   )
-  
+
   # For ethstat module
   AC_CHECK_HEADERS([linux/sockios.h],
     [have_linux_sockios_h="yes"],
@@ -500,7 +491,7 @@ if test "x$ac_system" = "xLinux"; then
       #endif
     ]]
   )
-  
+
   AC_CHECK_HEADERS([linux/ethtool.h],
     [have_linux_ethtool_h="yes"],
     [have_linux_ethtool_h="no"],
@@ -518,28 +509,7 @@ if test "x$ac_system" = "xLinux"; then
   )
 
   # For ipvs module
-  AC_CHECK_HEADERS([linux/ip_vs.h], [have_linux_ip_vs_h="yes"], [have_linux_ip_vs="no"])
-  AC_CHECK_HEADERS([net/ip_vs.h], [have_net_ip_vs_h="yes"], [have_net_ip_vs_h="no"])
-  AC_CHECK_HEADERS([ip_vs.h], [have_ip_vs_h="yes"], [have_ip_vs_h="no"])
-
-  ip_vs_h_needs_kernel_cflags="no"
-  
-  if test "x$have_linux_ip_vs_h$have_net_ip_vs_h$have_ip_vs_h" = "xnonono" && test -d "$KERNEL_DIR"; then
-    SAVE_CFLAGS="$CFLAGS"
-    CFLAGS="$CFLAGS $KERNEL_CFLAGS"
-    
-    AC_MSG_NOTICE([Did not find ip_vs.h. Trying again using headers from $KERNEL_DIR.])
-    
-    AC_CHECK_HEADERS([linux/ip_vs.h], [have_linux_ip_vs_h="yes"])
-    AC_CHECK_HEADERS([net/ip_vs.h], [have_net_ip_vs_h="yes"])
-    AC_CHECK_HEADERS([ip_vs.h], [have_ip_vs_h="yes"])
-    
-    if test "x$have_linux_ip_vs_h" = "xyes" || test "x$have_net_ip_vs_h" = "xyes" || test "x$have_ip_vs_h" = "xyes"; then
-      ip_vs_h_needs_kernel_cflags="yes"
-    fi
-    
-    CFLAGS="$SAVE_CFLAGS"
-  fi
+  AC_CHECK_HEADERS_ONCE([linux/ip_vs.h])
 
   # For the email plugin
   AC_CHECK_HEADERS([linux/un.h], [], [],
@@ -554,7 +524,7 @@ if test "x$ac_system" = "xLinux"; then
     [have_asm_msrindex_h="yes"],
     [have_asm_msrindex_h="no"]
   )
-  
+
   if test "x$have_asm_msrindex_h" = "xyes"; then
     AC_CACHE_CHECK([whether asm/msr-index.h has MSR_PKG_C10_RESIDENCY],
       [c_cv_have_usable_asm_msrindex_h],
@@ -575,12 +545,12 @@ if test "x$ac_system" = "xLinux"; then
       ]
     )
   fi
-  
+
   AC_CHECK_HEADERS([cpuid.h],
     [have_cpuid_h="yes"],
     [have_cpuid_h="no (cpuid.h not found)"]
   )
-  
+
   AC_CHECK_HEADERS([sys/capability.h],
     [have_capability="yes"],
     [have_capability="no (<sys/capability.h> not found)"]
@@ -610,7 +580,6 @@ else
   have_linux_wireless_h="no"
 fi
 
-AM_CONDITIONAL([IP_VS_H_NEEDS_KERNEL_CFLAGS], [test "x$ip_vs_h_needs_kernel_cflags" = "xyes"])
 AM_CONDITIONAL([BUILD_WITH_CAPABILITY], [test "x$have_capability" = "xyes"])
 
 # For the swap module
@@ -1445,13 +1414,13 @@ if test "x$fp_layout_type" = "xunknown"; then
               uint64_t i1;
               uint8_t c[8];
               double d;
-              
+
               d = 8.642135e130;
               memcpy ((void *) &i0, (void *) &d, 8);
-              
+
               i1 = endianflip (i0);
               memcpy ((void *) c, (void *) &i1, 8);
-              
+
               if ((c[0] == 0x2f) && (c[1] == 0x25)
                   && (c[2] == 0xc0) && (c[3] == 0xc7)
                   && (c[4] == 0x43) && (c[5] == 0x2b)
@@ -1494,13 +1463,13 @@ if test "x$fp_layout_type" = "xunknown"; then
               uint64_t i1;
               uint8_t c[8];
               double d;
-              
+
               d = 8.642135e130;
               memcpy ((void *) &i0, (void *) &d, 8);
-              
+
               i1 = intswap (i0);
               memcpy ((void *) c, (void *) &i1, 8);
-              
+
               if ((c[0] == 0x2f) && (c[1] == 0x25)
                   && (c[2] == 0xc0) && (c[3] == 0xc7)
                   && (c[4] == 0x43) && (c[5] == 0x2b)
@@ -2378,6 +2347,57 @@ AC_SUBST(BUILD_WITH_LIBDBI_LDFLAGS)
 AC_SUBST(BUILD_WITH_LIBDBI_LIBS)
 # }}}
 
+# --with-libdpdk {{{
+AC_ARG_VAR([LIBDPDK_CPPFLAGS], [Preprocessor flags for libdpdk])
+AC_ARG_VAR([LIBDPDK_LDFLAGS], [Linker flags for libdpdk])
+
+AC_ARG_WITH([libdpdk],
+  [AS_HELP_STRING([--without-libdpdk], [Disable libdpdk.])],
+  [with_libdpdk="$withval"],
+  [with_libdpdk="yes"]
+)
+
+if test "x$with_libdpdk" != "xno"; then
+  if test "x$LIBDPDK_CPPFLAGS" = "x"; then
+    LIBDPDK_CPPFLAGS="-I/usr/include/dpdk"
+  fi
+  SAVE_CPPFLAGS="$CPPFLAGS"
+  CPPFLAGS="$LIBDPDK_CPPFLAGS $CPPFLAGS"
+  AC_CHECK_HEADERS([rte_config.h],
+    [
+      with_libdpdk="yes"
+      AC_PREPROC_IFELSE(
+        [
+          AC_LANG_SOURCE(
+            [[
+              #include <rte_version.h>
+              #if RTE_VERSION < RTE_VERSION_NUM(16,7,0,0)
+              #error "required DPDK >= 16.07"
+              #endif
+            ]]
+          )
+        ],
+        [dpdk_keepalive="yes"],
+        [dpdk_keepalive="no (DPDK version < 16.07)"]
+      )
+    ],
+    [with_libdpdk="no (rte_config.h not found)"]
+  )
+  CPPFLAGS="$SAVE_CPPFLAGS"
+fi
+
+if test "x$with_libdpdk" = "xyes"; then
+  SAVE_LDFLAGS="$LDFLAGS"
+  LDFLAGS="$LIBDPDK_LDFLAGS $LDFLAGS"
+  AC_CHECK_LIB([dpdk], [rte_eal_init],
+    [with_libdpdk="yes"],
+    [with_libdpdk="no (symbol 'rte_eal_init' not found)"]
+  )
+  LDFLAGS="$SAVE_LDFLAGS"
+fi
+
+# }}}
+
 # --with-libesmtp {{{
 AC_ARG_WITH([libesmtp],
   [AS_HELP_STRING([--with-libesmtp@<:@=PREFIX@:>@], [Path to libesmtp.])],
@@ -2790,56 +2810,6 @@ AC_SUBST([BUILD_WITH_LIBIPTC_CPPFLAGS])
 AC_SUBST([BUILD_WITH_LIBIPTC_LDFLAGS])
 # }}}
 
-# --with-libdpdk {{{
-AC_ARG_VAR([LIBDPDK_CPPFLAGS], [Preprocessor flags for libdpdk])
-AC_ARG_VAR([LIBDPDK_LDFLAGS], [Linker flags for libdpdk])
-
-AC_ARG_WITH([libdpdk], [AS_HELP_STRING([--without-libdpdk], [Disable libdpdk.])])
-
-if test "x$with_libdpdk" != "xno"; then
-  if test "x$LIBDPDK_CPPFLAGS" = "x"; then
-    LIBDPDK_CPPFLAGS="-I/usr/include/dpdk"
-  fi
-  SAVE_CPPFLAGS="$CPPFLAGS"
-  CPPFLAGS="$LIBDPDK_CPPFLAGS $CPPFLAGS"
-  AC_CHECK_HEADERS([rte_config.h],
-    [
-      with_libdpdk="yes"
-      AC_COMPILE_IFELSE(
-        [
-          AC_LANG_PROGRAM(
-            [[
-              #include <rte_version.h>
-              #if RTE_VERSION < RTE_VERSION_NUM(16,7,0,0)
-              #error "required DPDK >= 16.07"
-              #endif
-            ]],
-            [[
-              return 0;
-            ]]
-          )
-        ],
-        [dpdk_keepalive="yes"],
-        [dpdk_keepalive="no (DPDK version < 16.07)"]
-      )
-    ],
-    [with_libdpdk="no (rte_config.h not found)"]
-  )
-  CPPFLAGS="$SAVE_CPPFLAGS"
-fi
-
-if test "x$with_libdpdk" = "xyes"; then
-  SAVE_LDFLAGS="$LDFLAGS"
-  LDFLAGS="$LIBDPDK_LDFLAGS $LDFLAGS"
-  AC_CHECK_LIB([dpdk], [rte_eal_init],
-    [with_libdpdk="yes"],
-    [with_libdpdk="no (symbol 'rte_eal_init' not found)"]
-  )
-  LDFLAGS="$SAVE_LDFLAGS"
-fi
-
-# }}}
-
 # --with-java {{{
 with_java_home="$JAVA_HOME"
 if test "x$with_java_home" = "x"; then
@@ -3769,69 +3739,131 @@ AC_SUBST([LIBNETAPP_LIBS])
 # }}}
 
 # --with-libnetsnmp {{{
-with_libnetsnmpagent="no"
-AC_ARG_WITH(libnetsnmp, [AS_HELP_STRING([--with-libnetsnmp@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
-[
-       if test "x$withval" = "xno"
-       then
-               with_libnetsnmp="no"
-       else if test "x$withval" = "xyes"
-       then
-               with_libnetsnmp="yes"
-       else
-               with_libnetsnmp_cppflags="-I$withval/include"
-               with_libnetsnmp_ldflags="-I$withval/lib"
-               with_libnetsnmp="yes"
-               with_libnetsnmpagent="yes"
-       fi; fi
-],
-[with_libnetsnmp="yes"])
-if test "x$with_libnetsnmp" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       CPPFLAGS="$CPPFLAGS $with_libnetsnmp_cppflags"
+AC_ARG_WITH([libnetsnmp],
+  [AS_HELP_STRING([--with-libnetsnmp@<:@=PREFIX@:>@], [Path to libnetsnmp.])],
+  [
+    if test "x$withval" = "xno"; then
+     with_libnetsnmp="no"
+    else if test "x$withval" = "xyes"; then
+     with_libnetsnmp="yes"
+    else
+      with_libnetsnmp_cppflags="-I$withval/include"
+      with_libnetsnmp_ldflags="-I$withval/lib"
+      with_libnetsnmp="yes"
+    fi; fi
+  ],
+  [with_libnetsnmp="yes"]
+)
 
-    AC_CHECK_HEADERS([net-snmp/net-snmp-config.h],
-      [with_libnetsnmp="yes"],
-      [with_libnetsnmp="no (net-snmp/net-snmp-config.h not found)"]
-    )
-    AC_CHECK_HEADERS(net-snmp/agent/agent_module_config.h,
-      [],
-      [with_libnetsnmpagent="no (net-snmp/agent/agent_module_config.h not found)"]
-    )
+if test "x$with_libnetsnmp" = "xyes"; then
+  SAVE_CPPFLAGS="$CPPFLAGS"
+  CPPFLAGS="$CPPFLAGS $with_libnetsnmp_cppflags"
+
+  AC_CHECK_HEADERS([net-snmp/net-snmp-config.h],
+    [with_libnetsnmp="yes"],
+    [with_libnetsnmp="no (net-snmp/net-snmp-config.h not found)"]
+  )
+
+  AC_CHECK_HEADERS([net-snmp/net-snmp-includes.h],
+    [with_libnetsnmp="yes"],
+    [with_libnetsnmp="no (net-snmp/net-snmp-includes.h not found)"],
+    [[
+      #if HAVE_NET_SNMP_NET_SNMP_CONFIG_H
+      # include <net-snmp/net-snmp-config.h>
+      #endif
+    ]]
+  )
 
-       CPPFLAGS="$SAVE_CPPFLAGS"
+  CPPFLAGS="$SAVE_CPPFLAGS"
 fi
-if test "x$with_libnetsnmp" = "xyes"
-then
-       SAVE_LDFLAGS="$LDFLAGS"
-       LDFLAGS="$LDFLAGS $with_libnetsnmp_ldflags"
 
-       AC_CHECK_LIB(netsnmp, init_snmp,
-               [with_libnetsnmp="yes"],
-               [with_libnetsnmp="no (libnetsnmp not found)"],
-               [$with_snmp_libs])
+if test "x$with_libnetsnmp" = "xyes"; then
+  SAVE_LDFLAGS="$LDFLAGS"
+  LDFLAGS="$LDFLAGS $with_libnetsnmp_ldflags"
+
+  AC_CHECK_LIB([netsnmp], [init_snmp],
+    [with_libnetsmp="yes"],
+    [with_libnetsnmp="no (libnetsnmp not found)"]
+  )
 
-       AC_CHECK_LIB(netsnmpagent, init_agent,
-               [with_libnetsnmpagent="yes"],
-               [with_libnetsnmpagent="no (libnetsnmpagent not found)"],
-               [$with_snmp_libs])
+  LDFLAGS="$SAVE_LDFLAGS"
+fi
 
-       LDFLAGS="$SAVE_LDFLAGS"
+if test "x$with_libnetsnmp" = "xyes"; then
+  BUILD_WITH_LIBNETSNMP_CPPFLAGS="$with_libnetsnmp_cppflags"
+  BUILD_WITH_LIBNETSNMP_LDFLAGS="$with_libnetsnmp_ldflags"
+  BUILD_WITH_LIBNETSNMP_LIBS="-lnetsnmp"
 fi
-if test "x$with_libnetsnmp" = "xyes"
-then
-       BUILD_WITH_LIBNETSNMP_CPPFLAGS="$with_libnetsnmp_cppflags"
-       BUILD_WITH_LIBNETSNMP_LDFLAGS="$with_libnetsnmp_ldflags"
-       BUILD_WITH_LIBNETSNMP_LIBS="-lnetsnmp"
+
+AC_SUBST([BUILD_WITH_LIBNETSNMP_CPPFLAGS])
+AC_SUBST([BUILD_WITH_LIBNETSNMP_LDFLAGS])
+AC_SUBST([BUILD_WITH_LIBNETSNMP_LIBS])
+# }}}
+
+# --with-libnetsmpagent {{{
+AC_ARG_WITH([libnetsnmpagent],
+  [AS_HELP_STRING([--with-libnetsnmpagent@<:@=PREFIX@:>@], [Path to libnetsnmpagent.])],
+  [
+    if test "x$withval" = "xno"; then
+      with_libnetsnmpagent="no"
+    else if test "x$withval" = "xyes"; then
+      with_libnetsnmpagent="yes"
+    else
+      with_libnetsnmpagent_cppflags="-I$withval/include"
+      with_libnetsnmpagent_ldflags="-I$withval/lib"
+      with_libnetsnmpagent="yes"
+    fi; fi
+  ],
+  [with_libnetsnmpagent="yes"]
+)
+
+if test "x$with_libnetsnmpagent" = "xyes"; then
+  SAVE_CPPFLAGS="$CPPFLAGS"
+  CPPFLAGS="$CPPFLAGS $with_libnetsnmpagent_cppflags"
+
+  AC_CHECK_HEADERS([net-snmp/agent/net-snmp-agent-includes.h],
+    [],
+    [with_libnetsnmpagent="no (net-snmp/agent/net-snmp-agent-includes.h not found)"],
+    [[
+      #if HAVE_NET_SNMP_NET_SNMP_CONFIG_H
+      # include <net-snmp/net-snmp-config.h>
+      #endif
+      #if HAVE_NET_SNMP_NET_SNMP_INCLUDES_H
+      # include <net-snmp/net-snmp-includes.h>
+      #endif
+    ]]
+  )
+
+  CPPFLAGS="$SAVE_CPPFLAGS"
 fi
-if test "x$with_libnetsnmpagent" = "xyes"
-then
-       BUILD_WITH_LIBNETSNMP_LIBS+=" -lnetsnmpagent"
+
+if test "x$with_libnetsnmpagent" = "xyes"; then
+  SAVE_LDFLAGS="$LDFLAGS"
+  LDFLAGS="$LDFLAGS $with_libnetsnmpagent_ldflags"
+
+  # older versions of libnetsnmpagent fail to link
+  # against the helpers library, so do that explicitly
+  AC_CHECK_LIB([netsnmphelpers], [netsnmp_init_helpers],
+    [libnetsnmphelpers="-lnetsnmphelpers"],
+    [libnetsnmphelpers=""]
+  )
+
+  AC_CHECK_LIB([netsnmpagent], [init_agent],
+    [with_libnetsnmpagent="yes"],
+    [with_libnetsnmpagent="no (libnetsnmpagent not found)"],
+    [$libnetsnmphelpers]
+  )
+
+  LDFLAGS="$SAVE_LDFLAGS"
+fi
+
+if test "x$with_libnetsnmpagent" = "xyes"; then
+  BUILD_WITH_LIBNETSNMPAGENT_LIBS="-lnetsnmpagent $libnetsnmphelpers"
 fi
-AC_SUBST(BUILD_WITH_LIBNETSNMP_CPPFLAGS)
-AC_SUBST(BUILD_WITH_LIBNETSNMP_LDFLAGS)
-AC_SUBST(BUILD_WITH_LIBNETSNMP_LIBS)
+
+AC_SUBST([BUILD_WITH_LIBNETSNMPAGENT_CPPFLAGS])
+AC_SUBST([BUILD_WITH_LIBNETSNMPAGENT_LDFLAGS])
+AC_SUBST([BUILD_WITH_LIBNETSNMPAGENT_LIBS])
 # }}}
 
 # --with-liboping {{{
@@ -4327,62 +4359,74 @@ AC_SUBST([BUILD_WITH_LIBPQ_LIBS])
 # }}}
 
 # --with-libpqos {{{
-with_libpqos_cppflags=""
-with_libpqos_ldflags=""
-AC_ARG_WITH(libpqos, [AS_HELP_STRING([--with-libpqos@<:@=PREFIX@:>@], [Path to libpqos.])],
-[
-       if test "x$withval" != "xno" && test "x$withval" != "xyes"
-       then
-               with_libpqos_cppflags="-I$withval/include"
-               with_libpqos_ldflags="-L$withval/lib"
-               with_libpqos="yes"
-       else
-               with_libpqos="$withval"
-       fi
-],
-[
-       with_libpqos="yes"
-])
-if test "x$with_libpqos" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       CPPFLAGS="$CPPFLAGS $with_libpqos_cppflags"
+AC_ARG_WITH([libpqos],
+  [AS_HELP_STRING([--with-libpqos@<:@=PREFIX@:>@], [Path to libpqos.])],
+  [
+    if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
+      with_libpqos_cppflags="-I$withval/include"
+      with_libpqos_ldflags="-L$withval/lib"
+      with_libpqos="yes"
+    else
+      with_libpqos="$withval"
+    fi
+  ],
+  [with_libpqos="yes"]
+)
+
+if test "x$with_libpqos" = "xyes"; then
+  SAVE_CPPFLAGS="$CPPFLAGS"
+  CPPFLAGS="$CPPFLAGS $with_libpqos_cppflags"
 
-       AC_CHECK_HEADERS(pqos.h, [with_libpqos="yes"], [with_libpqos="no (pqos.h not found)"])
+  AC_CHECK_HEADERS([pqos.h],
+    [with_libpqos="yes"],
+    [with_libpqos="no (pqos.h not found)"]
+  )
 
-       CPPFLAGS="$SAVE_CPPFLAGS"
+  CPPFLAGS="$SAVE_CPPFLAGS"
 fi
-if test "x$with_libpqos" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       SAVE_LDFLAGS="$LDFLAGS"
-       CPPFLAGS="$CPPFLAGS $with_libpqos_cppflags"
-       LDFLAGS="$LDFLAGS $with_libpqos_ldflags"
 
-       AC_CHECK_LIB(pqos, pqos_init, [with_libpqos="yes"], [with_libpqos="no (Can't find libpqos)"])
+if test "x$with_libpqos" = "xyes"; then
+  SAVE_LDFLAGS="$LDFLAGS"
+  LDFLAGS="$LDFLAGS $with_libpqos_ldflags"
 
-       CPPFLAGS="$SAVE_CPPFLAGS"
-       LDFLAGS="$SAVE_LDFLAGS"
+  AC_CHECK_LIB([pqos], [pqos_init],
+    [with_libpqos="yes"],
+    [with_libpqos="no (Can't find libpqos)"]
+  )
+
+  LDFLAGS="$SAVE_LDFLAGS"
 fi
-if test "x$with_libpqos" = "xyes"
-then
+
+if test "x$with_libpqos" = "xyes"; then
   SAVE_CPPFLAGS="$CPPFLAGS"
   CPPFLAGS="$CPPFLAGS $with_libpqos_cppflags"
-  AC_RUN_IFELSE([AC_LANG_PROGRAM(
-    [[#include <pqos.h>]],
-    [[return !(PQOS_VERSION >= 106)]])],
-    [with_libpqos="yes"], [with_libpqos="no (pqos library version 1.06 or higher is required)"])
+  AC_PREPROC_IFELSE(
+    [
+      AC_LANG_SOURCE(
+        [[
+          #include <pqos.h>
+          #if PQOS_VERSION < 106
+          #error "required PQOS version >= 1.06"
+          #endif
+        ]]
+      )
+    ],
+    [with_libpqos="yes"],
+    [with_libpqos="no (pqos library version 1.06 or higher is required)"]
+  )
+
   CPPFLAGS="$SAVE_CPPFLAGS"
 fi
-if test "x$with_libpqos" = "xyes"
-then
-       BUILD_WITH_LIBPQOS_CPPFLAGS="$with_libpqos_cppflags"
-       BUILD_WITH_LIBPQOS_LDFLAGS="$with_libpqos_ldflags"
-       BUILD_WITH_LIBPQOS_LIBS="-lpqos"
-       AC_SUBST(BUILD_WITH_LIBPQOS_CPPFLAGS)
-       AC_SUBST(BUILD_WITH_LIBPQOS_LDFLAGS)
-       AC_SUBST(BUILD_WITH_LIBPQOS_LIBS)
+
+if test "x$with_libpqos" = "xyes"; then
+  BUILD_WITH_LIBPQOS_CPPFLAGS="$with_libpqos_cppflags"
+  BUILD_WITH_LIBPQOS_LDFLAGS="$with_libpqos_ldflags"
+  BUILD_WITH_LIBPQOS_LIBS="-lpqos"
 fi
+
+AC_SUBST([BUILD_WITH_LIBPQOS_CPPFLAGS])
+AC_SUBST([BUILD_WITH_LIBPQOS_LDFLAGS])
+AC_SUBST([BUILD_WITH_LIBPQOS_LIBS])
 # }}}
 
 # --with-libprotobuf {{{
@@ -6056,7 +6100,6 @@ plugin_processes="no"
 plugin_protocols="no"
 plugin_python="no"
 plugin_serial="no"
-plugin_snmp_agent="no"
 plugin_smart="no"
 plugin_swap="no"
 plugin_tape="no"
@@ -6111,14 +6154,14 @@ if test "x$ac_system" = "xLinux"; then
   plugin_wireless="yes"
   plugin_zfs_arc="yes"
 
-  if test "x$have_linux_ip_vs_h" = "xyes" || test "x$have_net_ip_vs_h" = "xyes" || test "x$have_ip_vs_h" = "xyes"; then
+  if test "x$ac_cv_header_linux_ip_vs_h" = "xyes"; then
     plugin_ipvs="yes"
   fi
 
   if test "x$c_cv_have_usable_asm_msrindex_h" = "xyes" && test "x$have_cpuid_h" = "xyes"; then
     plugin_turbostat="yes"
   fi
-  
+
   if test "x$c_cv_have_clock_boottime_monotonic" = "xyes"; then
     plugin_cpusleep="yes"
   fi
@@ -6350,10 +6393,6 @@ if test "x$with_kvm_getswapinfo" = "xyes"; then
   plugin_swap="yes"
 fi
 
-if test "x$with_libnetsnmp" = "xyes" && test "x$with_libnetsnmpagent" = "xyes"; then
-  plugin_snmp_agent="yes"
-fi
-
 if test "x$have_swapctl" = "xyes" && test "x$c_cv_have_swapctl_two_args" = "xyes"; then
   plugin_swap="yes"
 fi
@@ -6516,7 +6555,7 @@ AC_PLUGIN([serial],              [$plugin_serial],          [serial port traffic
 AC_PLUGIN([sigrok],              [$with_libsigrok],         [sigrok acquisition sources])
 AC_PLUGIN([smart],               [$plugin_smart],           [SMART statistics])
 AC_PLUGIN([snmp],                [$with_libnetsnmp],        [SNMP querying plugin])
-AC_PLUGIN([snmp_agent],          [$plugin_snmp_agent],      [SNMP agent plugin])
+AC_PLUGIN([snmp_agent],          [$with_libnetsnmpagent],   [SNMP agent plugin])
 AC_PLUGIN([statsd],              [yes],                     [StatsD plugin])
 AC_PLUGIN([swap],                [$plugin_swap],            [Swap usage statistics])
 AC_PLUGIN([syslog],              [$have_syslog],            [Syslog logging plugin])
@@ -6597,8 +6636,7 @@ AC_SUBST([LOAD_PLUGIN_SYSLOG])
 AC_SUBST([LOAD_PLUGIN_LOGFILE])
 AC_SUBST([LOAD_PLUGIN_LOG_LOGSTASH])
 
-if test "x$enable_debug" = "xyes"
-then
+if test "x$enable_debug" = "xyes"; then
   DEFAULT_LOG_LEVEL="debug"
 else
   DEFAULT_LOG_LEVEL="info"
@@ -6643,21 +6681,11 @@ AC_SUBST([LOAD_PLUGIN_RRDTOOL])
 AC_SUBST([LOAD_PLUGIN_NETWORK])
 AC_SUBST([LOAD_PLUGIN_CSV])
 
-dnl ip_vs.h
-if test "x$ac_system" = "xLinux" && test "x$have_linux_ip_vs_h" = "xno" && "x$have_net_ip_vs_h" = "xno" && "x$have_ip_vs_h" = "xno"; then
-  enable_ipvs="$enable_ipvs (ip_vs.h not found)"
-fi
-
-if test "x$ip_vs_h_needs_kernel_cflags" = "xyes"; then
-  enable_ipvs="$enable_ipvs (needs $KERNEL_CFLAGS)"
-fi
-
 dnl Perl bindings
 PERL_BINDINGS_OPTIONS="PREFIX=${prefix}"
 AC_ARG_WITH(perl-bindings, [AS_HELP_STRING([--with-perl-bindings@<:@=OPTIONS@:>@], [Options passed to "perl Makefile.PL".])],
 [
-  if test "x$withval" != "xno" && test "x$withval" != "xyes"
-  then
+  if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
     PERL_BINDINGS_OPTIONS="$withval"
     with_perl_bindings="yes"
   else
@@ -6665,27 +6693,24 @@ AC_ARG_WITH(perl-bindings, [AS_HELP_STRING([--with-perl-bindings@<:@=OPTIONS@:>@
   fi
 ],
 [
-  if test "x$PERL" != "x"
-  then
+  if test "x$PERL" != "x"; then
     with_perl_bindings="yes"
   else
     with_perl_bindings="no (no perl interpreter found)"
   fi
 ])
 
-if test "x$with_perl_bindings" = "xyes"
-then
-       AC_MSG_CHECKING([for the ExtUtils::MakeMaker module])
-       if $PERL -MExtUtils::MakeMaker -e '' 2>/dev/null; then
-               AC_MSG_RESULT([yes])
-       else
-               AC_MSG_RESULT([no])
-               with_perl_bindings="no (ExtUtils::MakeMaker not found)"
-       fi
+if test "x$with_perl_bindings" = "xyes"; then
+  AC_MSG_CHECKING([for the ExtUtils::MakeMaker module])
+  if $PERL -MExtUtils::MakeMaker -e '' 2>/dev/null; then
+    AC_MSG_RESULT([yes])
+  else
+    AC_MSG_RESULT([no])
+    with_perl_bindings="no (ExtUtils::MakeMaker not found)"
+  fi
 fi
 
-if test "x$with_perl_bindings" = "xyes"
-then
+if test "x$with_perl_bindings" = "xyes"; then
   PERL_BINDINGS="perl"
 else
   PERL_BINDINGS=""
@@ -6751,6 +6776,7 @@ AC_MSG_RESULT()
 AC_MSG_RESULT([Configuration:])
 AC_MSG_RESULT([  Build:])
 AC_MSG_RESULT([    Platform  . . . . . . $ac_system])
+AC_MSG_RESULT([    Compiler vendor . . . $ax_cv_c_compiler_vendor])
 AC_MSG_RESULT([    CC  . . . . . . . . . $CC])
 AC_MSG_RESULT([    CFLAGS  . . . . . . . $AM_CFLAGS $CFLAGS])
 AC_MSG_RESULT([    CXXFLAGS  . . . . . . $AM_CXXFLAGS $CXXFLAGS])
@@ -6794,6 +6820,7 @@ AC_MSG_RESULT([    libmosquitto  . . . . $with_libmosquitto])
 AC_MSG_RESULT([    libmysql  . . . . . . $with_libmysql])
 AC_MSG_RESULT([    libnetapp . . . . . . $with_libnetapp])
 AC_MSG_RESULT([    libnetsnmp  . . . . . $with_libnetsnmp])
+AC_MSG_RESULT([    libnetsnmpagent . . . $with_libnetsnmpagent])
 AC_MSG_RESULT([    libnotify . . . . . . $with_libnotify])
 AC_MSG_RESULT([    libopenipmi . . . . . $with_libopenipmipthread])
 AC_MSG_RESULT([    liboping  . . . . . . $with_liboping])
diff --git a/m4/ax_compiler_vendor.m4 b/m4/ax_compiler_vendor.m4
new file mode 100644 (file)
index 0000000..ee24c12
--- /dev/null
@@ -0,0 +1,87 @@
+# ===========================================================================
+#    http://www.gnu.org/software/autoconf-archive/ax_compiler_vendor.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_COMPILER_VENDOR
+#
+# DESCRIPTION
+#
+#   Determine the vendor of the C/C++ compiler, e.g., gnu, intel, ibm, sun,
+#   hp, borland, comeau, dec, cray, kai, lcc, metrowerks, sgi, microsoft,
+#   watcom, etc. The vendor is returned in the cache variable
+#   $ax_cv_c_compiler_vendor for C and $ax_cv_cxx_compiler_vendor for C++.
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
+#   Copyright (c) 2008 Matteo Frigo
+#
+#   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
+#   Free Software Foundation, either version 3 of the License, or (at your
+#   option) any later version.
+#
+#   This program is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+#   Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License along
+#   with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+#   As a special exception, the respective Autoconf Macro's copyright owner
+#   gives unlimited permission to copy, distribute and modify the configure
+#   scripts that are the output of Autoconf when processing the Macro. You
+#   need not follow the terms of the GNU General Public License when using
+#   or distributing such scripts, even though portions of the text of the
+#   Macro appear in them. The GNU General Public License (GPL) does govern
+#   all other use of the material that constitutes the Autoconf Macro.
+#
+#   This special exception to the GPL applies to versions of the Autoconf
+#   Macro released by the Autoconf Archive. When you make and distribute a
+#   modified version of the Autoconf Macro, you may extend this special
+#   exception to the GPL to apply to your modified version as well.
+
+#serial 15
+
+AC_DEFUN([AX_COMPILER_VENDOR],
+[AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor,
+  dnl Please add if possible support to ax_compiler_version.m4
+  [# note: don't check for gcc first since some other compilers define __GNUC__
+  vendors="intel:     __ICC,__ECC,__INTEL_COMPILER
+           ibm:       __xlc__,__xlC__,__IBMC__,__IBMCPP__
+           pathscale: __PATHCC__,__PATHSCALE__
+           clang:     __clang__
+           cray:      _CRAYC
+           fujitsu:   __FUJITSU
+           gnu:       __GNUC__
+           sun:       __SUNPRO_C,__SUNPRO_CC
+           hp:        __HP_cc,__HP_aCC
+           dec:       __DECC,__DECCXX,__DECC_VER,__DECCXX_VER
+           borland:   __BORLANDC__,__CODEGEARC__,__TURBOC__
+           comeau:    __COMO__
+           kai:       __KCC
+           lcc:       __LCC__
+           sgi:       __sgi,sgi
+           microsoft: _MSC_VER
+           metrowerks: __MWERKS__
+           watcom:    __WATCOMC__
+           portland:  __PGI
+           tcc:       __TINYC__
+           unknown:   UNKNOWN"
+  for ventest in $vendors; do
+    case $ventest in
+      *:) vendor=$ventest; continue ;;
+      *)  vencpp="defined("`echo $ventest | sed 's/,/) || defined(/g'`")" ;;
+    esac
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[
+      #if !($vencpp)
+        thisisanerror;
+      #endif
+    ])], [break])
+  done
+  ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=`echo $vendor | cut -d: -f1`
+ ])
+])
index 583e4e3..1adc627 100644 (file)
@@ -901,7 +901,7 @@ static int camqp_config_connection(oconfig_item_t *ci, /* {{{ */
       status = cf_util_get_string(child, &conf->password);
     else if (strcasecmp("Exchange", child->key) == 0)
       status = cf_util_get_string(child, &conf->exchange);
-    else if ((strcasecmp("ExchangeType", child->key) == 0) && !publish)
+    else if (strcasecmp("ExchangeType", child->key) == 0)
       status = cf_util_get_string(child, &conf->exchange_type);
     else if ((strcasecmp("Queue", child->key) == 0) && !publish)
       status = cf_util_get_string(child, &conf->queue);
index 02bffd3..b7308ad 100644 (file)
@@ -522,8 +522,10 @@ static int bind_parse_generic_name_value(const char *xpath_expression, /* {{{ */
         status = bind_xml_read_gauge(doc, counter, &value.gauge);
       else
         status = bind_xml_read_derive(doc, counter, &value.derive);
-      if (status != 0)
+      if (status != 0) {
+        xmlFree(name);
         continue;
+      }
 
       status = (*list_callback)(name, value, current_time, user_data);
       if (status == 0)
@@ -655,12 +657,16 @@ static int bind_parse_generic_name_attr_value_list(
         status = bind_xml_read_gauge(doc, child, &value.gauge);
       else
         status = bind_xml_read_derive(doc, child, &value.derive);
-      if (status != 0)
+      if (status != 0) {
+        xmlFree(attr_name);
         continue;
+      }
 
       status = (*list_callback)(attr_name, value, current_time, user_data);
       if (status == 0)
         num_entries++;
+
+      xmlFree(attr_name);
     }
   }
 
index c246f1d..edb9506 100644 (file)
@@ -44,7 +44,7 @@ collectd-snmp - Documentation of collectd's C<snmp plugin>
       Collect "std_traffic" "hr_users"
     </Host>
     <Host "secure.router.mydomain.org">
-      Address "192.168.0.7"
+      Address "192.168.0.7:165"
       Version 3
       SecurityLevel "authPriv"
       Username "cosmo"
@@ -55,7 +55,7 @@ collectd-snmp - Documentation of collectd's C<snmp plugin>
       Collect "std_traffic"
     </Host>
     <Host "some.ups.mydomain.org">
-      Address "192.168.0.3"
+      Address "tcp:192.168.0.3"
       Version 1
       Community "more_communities"
       Collect "powerplus_voltge_input"
@@ -228,7 +228,8 @@ stored by collectd.
 
 =item B<Address> I<IP-Address>|I<Hostname>
 
-Set the address to connect to.
+Set the address to connect to. Address may include transport specifier and/or
+port number.
 
 =item B<Version> B<1>|B<2>|B<3>
 
index 058edf2..ceb6a13 100644 (file)
@@ -3153,7 +3153,7 @@ See F</"IGNORELISTS"> for details.
 
 =item B<IgnoreSelected> I<true>|I<false>
 
-If no configuration if given, the B<interface>-plugin will collect data from
+If no configuration is given, the B<interface>-plugin will collect data from
 all interfaces. This may not be practical, especially for loopback- and
 similar interfaces. Thus, you can use the B<Interface>-option to pick the
 interfaces you're interested in. Sometimes, however, it's easier/preferred
index 18aa66b..7d6e8fd 100644 (file)
@@ -222,8 +222,6 @@ int uc_init(void) {
 } /* int uc_init */
 
 int uc_check_timeout(void) {
-  cdtime_t now = cdtime();
-
   struct {
     char *key;
     cdtime_t time;
@@ -232,6 +230,7 @@ int uc_check_timeout(void) {
   size_t expired_num = 0;
 
   pthread_mutex_lock(&cache_lock);
+  cdtime_t now = cdtime();
 
   /* Build a list of entries to be flushed */
   c_avl_iterator_t *iter = c_avl_get_iterator(cache_tree);
@@ -423,6 +422,9 @@ int uc_get_rate_by_name(const char *name, gauge_t **ret_values,
 
     /* remove missing values from getval */
     if (ce->state == STATE_MISSING) {
+      DEBUG("utils_cache: uc_get_rate_by_name: requested metric \"%s\" is in "
+            "state \"missing\".",
+            name);
       status = -1;
     } else {
       ret_num = ce->values_num;
@@ -466,7 +468,7 @@ gauge_t *uc_get_rate(const data_set_t *ds, const value_list_t *vl) {
 
   /* This is important - the caller has no other way of knowing how many
    * values are returned. */
-  if (ret_num != (size_t)ds->ds_num) {
+  if (ret_num != ds->ds_num) {
     ERROR("utils_cache: uc_get_rate: ds[%s] has %zu values, "
           "but uc_get_rate_by_name returned %zu.",
           ds->type, ds->ds_num, ret_num);
index 871ddf8..e5f015b 100644 (file)
@@ -159,18 +159,18 @@ static type_list_t list_check_copy;
  * Private functions
  */
 static int email_config(const char *key, const char *value) {
-  if (0 == strcasecmp(key, "SocketFile")) {
-    if (NULL != sock_file)
+  if (strcasecmp(key, "SocketFile") == 0) {
+    if (sock_file != NULL)
       free(sock_file);
     sock_file = sstrdup(value);
-  } else if (0 == strcasecmp(key, "SocketGroup")) {
-    if (NULL != sock_group)
+  } else if (strcasecmp(key, "SocketGroup") == 0) {
+    if (sock_group != NULL)
       free(sock_group);
     sock_group = sstrdup(value);
-  } else if (0 == strcasecmp(key, "SocketPerms")) {
+  } else if (strcasecmp(key, "SocketPerms") == 0) {
     /* the user is responsible for providing reasonable values */
     sock_perms = (int)strtol(value, NULL, 8);
-  } else if (0 == strcasecmp(key, "MaxConns")) {
+  } else if (strcasecmp(key, "MaxConns") == 0) {
     long int tmp = strtol(value, NULL, 0);
 
     if (tmp < 1) {
@@ -200,7 +200,7 @@ static int email_config(const char *key, const char *value) {
 
 /* Increment the value of the given name in the given list by incr. */
 static void type_list_incr(type_list_t *list, char *name, int incr) {
-  if (NULL == list->head) {
+  if (list->head == NULL) {
     list->head = smalloc(sizeof(*list->head));
 
     list->head->name = sstrdup(name);
@@ -212,11 +212,11 @@ static void type_list_incr(type_list_t *list, char *name, int incr) {
     type_t *ptr;
 
     for (ptr = list->head; NULL != ptr; ptr = ptr->next) {
-      if (0 == strcmp(name, ptr->name))
+      if (strcmp(name, ptr->name) == 0)
         break;
     }
 
-    if (NULL == ptr) {
+    if (ptr == NULL) {
       list->tail->next = smalloc(sizeof(*list->tail->next));
       list->tail = list->tail->next;
 
@@ -238,14 +238,14 @@ static void *collect(void *arg) {
 
     pthread_mutex_lock(&conns_mutex);
 
-    while (NULL == conns.head) {
+    while (conns.head == NULL) {
       pthread_cond_wait(&conn_available, &conns_mutex);
     }
 
     connection = conns.head;
     conns.head = conns.head->next;
 
-    if (NULL == conns.head) {
+    if (conns.head == NULL) {
       conns.tail = NULL;
     }
 
@@ -263,8 +263,8 @@ static void *collect(void *arg) {
       int len = 0;
 
       errno = 0;
-      if (NULL == fgets(line, sizeof(line), this->socket)) {
-        if (0 != errno) {
+      if (fgets(line, sizeof(line), this->socket) == NULL) {
+        if (errno != 0) {
           char errbuf[1024];
           log_err("collect: reading from socket (fd #%i) "
                   "failed: %s",
@@ -275,13 +275,13 @@ static void *collect(void *arg) {
       }
 
       len = strlen(line);
-      if (('\n' != line[len - 1]) && ('\r' != line[len - 1])) {
+      if ((line[len - 1] != '\n') && (line[len - 1] != '\r')) {
         log_warn("collect: line too long (> %zu characters): "
                  "'%s' (truncated)",
                  sizeof(line) - 1, line);
 
-        while (NULL != fgets(line, sizeof(line), this->socket))
-          if (('\n' == line[len - 1]) || ('\r' == line[len - 1]))
+        while (fgets(line, sizeof(line), this->socket) != NULL)
+          if ((line[len - 1] == '\n') || (line[len - 1] == '\r'))
             break;
         continue;
       }
@@ -293,18 +293,18 @@ static void *collect(void *arg) {
 
       log_debug("collect: line = '%s'", line);
 
-      if (':' != line[1]) {
+      if (line[1] != ':') {
         log_err("collect: syntax error in line '%s'", line);
         continue;
       }
 
-      if ('e' == line[0]) { /* e:<type>:<bytes> */
+      if (line[0] == 'e') { /* e:<type>:<bytes> */
         char *ptr = NULL;
         char *type = strtok_r(line + 2, ":", &ptr);
         char *tmp = strtok_r(NULL, ":", &ptr);
         int bytes = 0;
 
-        if (NULL == tmp) {
+        if (tmp == NULL) {
           log_err("collect: syntax error in line '%s'", line);
           continue;
         }
@@ -320,13 +320,13 @@ static void *collect(void *arg) {
           type_list_incr(&list_size, type, /* increment = */ bytes);
           pthread_mutex_unlock(&size_mutex);
         }
-      } else if ('s' == line[0]) { /* s:<value> */
+      } else if (line[0] == 's') { /* s:<value> */
         pthread_mutex_lock(&score_mutex);
         score = (score * (double)score_count + atof(line + 2)) /
                 (double)(score_count + 1);
         ++score_count;
         pthread_mutex_unlock(&score_mutex);
-      } else if ('c' == line[0]) { /* c:<type1>[,<type2>,...] */
+      } else if (line[0] == 'c') { /* c:<type1>[,<type2>,...] */
         char *dummy = line + 2;
         char *endptr = NULL;
         char *type;
@@ -366,7 +366,7 @@ static void *open_connection(void __attribute__((unused)) * arg) {
 
   /* create UNIX socket */
   errno = 0;
-  if (-1 == (connector_socket = socket(PF_UNIX, SOCK_STREAM, 0))) {
+  if ((connector_socket = socket(PF_UNIX, SOCK_STREAM, 0)) == -1) {
     char errbuf[1024];
     disabled = 1;
     log_err("socket() failed: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
@@ -379,9 +379,8 @@ static void *open_connection(void __attribute__((unused)) * arg) {
   sstrncpy(addr.sun_path, path, (size_t)(UNIX_PATH_MAX - 1));
 
   errno = 0;
-  if (-1 ==
-      bind(connector_socket, (struct sockaddr *)&addr,
-           offsetof(struct sockaddr_un, sun_path) + strlen(addr.sun_path))) {
+  if (bind(connector_socket, (struct sockaddr *)&addr,
+           offsetof(struct sockaddr_un, sun_path) + strlen(addr.sun_path)) == -1) {
     char errbuf[1024];
     disabled = 1;
     close(connector_socket);
@@ -391,7 +390,7 @@ static void *open_connection(void __attribute__((unused)) * arg) {
   }
 
   errno = 0;
-  if (-1 == listen(connector_socket, 5)) {
+  if (listen(connector_socket, 5) == -1) {
     char errbuf[1024];
     disabled = 1;
     close(connector_socket);
@@ -403,7 +402,7 @@ static void *open_connection(void __attribute__((unused)) * arg) {
   {
     struct group sg;
     struct group *grp;
-    char grbuf[2048];
+    char grbuf[4096];
     int status;
 
     grp = NULL;
@@ -411,7 +410,7 @@ static void *open_connection(void __attribute__((unused)) * arg) {
     if (status != 0) {
       char errbuf[1024];
       log_warn("getgrnam_r (%s) failed: %s", group,
-               sstrerror(errno, errbuf, sizeof(errbuf)));
+               sstrerror(status, errbuf, sizeof(errbuf)));
     } else if (grp == NULL) {
       log_warn("No such group: `%s'", group);
     } else {
@@ -425,7 +424,7 @@ static void *open_connection(void __attribute__((unused)) * arg) {
   }
 
   errno = 0;
-  if (0 != chmod(path, sock_perms)) {
+  if (chmod(path, sock_perms) != 0) {
     char errbuf[1024];
     log_warn("chmod() failed: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
   }
@@ -466,7 +465,7 @@ static void *open_connection(void __attribute__((unused)) * arg) {
 
     pthread_mutex_lock(&available_mutex);
 
-    while (0 == available_collectors) {
+    while (available_collectors == 0) {
       pthread_cond_wait(&collector_available, &available_mutex);
     }
 
@@ -505,7 +504,7 @@ static void *open_connection(void __attribute__((unused)) * arg) {
     connection->socket = fdopen(remote, "r");
     connection->next = NULL;
 
-    if (NULL == connection->socket) {
+    if (connection->socket == NULL) {
       close(remote);
       sfree(connection);
       continue;
@@ -513,7 +512,7 @@ static void *open_connection(void __attribute__((unused)) * arg) {
 
     pthread_mutex_lock(&conns_mutex);
 
-    if (NULL == conns.head) {
+    if (conns.head == NULL) {
       conns.head = connection;
       conns.tail = connection;
     } else {
@@ -605,7 +604,7 @@ static int email_shutdown(void) {
   type_list_free(&list_check);
   type_list_free(&list_check_copy);
 
-  unlink((NULL == sock_file) ? SOCK_PATH : sock_file);
+  unlink((sock_file == NULL) ? SOCK_PATH : sock_file);
 
   sfree(sock_file);
   sfree(sock_group);
@@ -632,14 +631,14 @@ static void email_submit(const char *type, const char *type_instance,
 static void copy_type_list(type_list_t *l1, type_list_t *l2) {
   type_t *last = NULL;
 
-  for (type_t *ptr1 = l1->head, *ptr2 = l2->head; NULL != ptr1;
+  for (type_t *ptr1 = l1->head, *ptr2 = l2->head; ptr1 != NULL;
        ptr1 = ptr1->next, last = ptr2, ptr2 = ptr2->next) {
-    if (NULL == ptr2) {
+    if (ptr2 == NULL) {
       ptr2 = smalloc(sizeof(*ptr2));
       ptr2->name = NULL;
       ptr2->next = NULL;
 
-      if (NULL == last) {
+      if (last == NULL) {
         l2->head = ptr2;
       } else {
         last->next = ptr2;
@@ -648,7 +647,7 @@ static void copy_type_list(type_list_t *l1, type_list_t *l2) {
       l2->tail = ptr2;
     }
 
-    if (NULL == ptr2->name) {
+    if (ptr2->name == NULL) {
       ptr2->name = sstrdup(ptr1->name);
     }
 
@@ -672,7 +671,7 @@ static int email_read(void) {
 
   pthread_mutex_unlock(&count_mutex);
 
-  for (type_t *ptr = list_count_copy.head; NULL != ptr; ptr = ptr->next) {
+  for (type_t *ptr = list_count_copy.head; ptr != NULL; ptr = ptr->next) {
     email_submit("email_count", ptr->name, ptr->value);
   }
 
@@ -683,7 +682,7 @@ static int email_read(void) {
 
   pthread_mutex_unlock(&size_mutex);
 
-  for (type_t *ptr = list_size_copy.head; NULL != ptr; ptr = ptr->next) {
+  for (type_t *ptr = list_size_copy.head; ptr != NULL; ptr = ptr->next) {
     email_submit("email_size", ptr->name, ptr->value);
   }
 
@@ -707,7 +706,7 @@ static int email_read(void) {
 
   pthread_mutex_unlock(&check_mutex);
 
-  for (type_t *ptr = list_check_copy.head; NULL != ptr; ptr = ptr->next)
+  for (type_t *ptr = list_check_copy.head; ptr != NULL; ptr = ptr->next)
     email_submit("spam_check", ptr->name, ptr->value);
 
   return 0;
index f10b816..3d12a2d 100644 (file)
@@ -369,7 +369,7 @@ static int fork_child(program_list_t *pl, int *fd_in, int *fd_out,
 
   struct passwd *sp_ptr;
   struct passwd sp;
-  char nambuf[2048];
+  char nambuf[4096];
 
   if (pl->pid != 0)
     return -1;
@@ -382,7 +382,7 @@ static int fork_child(program_list_t *pl, int *fd_in, int *fd_out,
   status = getpwnam_r(pl->user, &sp, nambuf, sizeof(nambuf), &sp_ptr);
   if (status != 0) {
     ERROR("exec plugin: Failed to get user information for user ``%s'': %s",
-          pl->user, sstrerror(errno, errbuf, sizeof(errbuf)));
+          pl->user, sstrerror(status, errbuf, sizeof(errbuf)));
     goto failed;
   }
 
@@ -401,19 +401,19 @@ static int fork_child(program_list_t *pl, int *fd_in, int *fd_out,
   /* The group configured in the configfile is set as effective group, because
    * this way the forked process can (re-)gain the user's primary group. */
   egid = -1;
-  if (NULL != pl->group) {
-    if ('\0' != *pl->group) {
+  if (pl->group != NULL) {
+    if (*pl->group != '\0') {
       struct group *gr_ptr = NULL;
       struct group gr;
 
       status = getgrnam_r(pl->group, &gr, nambuf, sizeof(nambuf), &gr_ptr);
-      if (0 != status) {
+      if (status != 0) {
         ERROR("exec plugin: Failed to get group information "
               "for group ``%s'': %s",
-              pl->group, sstrerror(errno, errbuf, sizeof(errbuf)));
+              pl->group, sstrerror(status, errbuf, sizeof(errbuf)));
         goto failed;
       }
-      if (NULL == gr_ptr) {
+      if (gr_ptr == NULL) {
         ERROR("exec plugin: No such group: `%s'", pl->group);
         goto failed;
       }
index 2e0fe0f..7966daa 100644 (file)
@@ -544,43 +544,36 @@ rdt_preinit_error1:
 }
 
 static int rdt_config(oconfig_item_t *ci) {
-  int ret = 0;
-
-  ret = rdt_preinit();
-  if (ret != 0) {
+  if (rdt_preinit() != 0) {
     g_state = CONFIGURATION_ERROR;
     /* if we return -1 at this point collectd
       reports a failure in configuration and
       aborts
     */
-    goto exit;
+    return (0);
   }
 
   for (int i = 0; i < ci->children_num; i++) {
     oconfig_item_t *child = ci->children + i;
 
     if (strcasecmp("Cores", child->key) == 0) {
-
-      ret = rdt_config_cgroups(child);
-      if (ret != 0) {
+      if (rdt_config_cgroups(child) != 0) {
         g_state = CONFIGURATION_ERROR;
         /* if we return -1 at this point collectd
            reports a failure in configuration and
            aborts
          */
-        goto exit;
+        return (0);
       }
 
 #if COLLECT_DEBUG
       rdt_dump_cgroups();
 #endif /* COLLECT_DEBUG */
-
     } else {
       ERROR(RDT_PLUGIN ": Unknown configuration parameter \"%s\".", child->key);
     }
   }
 
-exit:
   return 0;
 }
 
index e614b93..da67970 100644 (file)
 #include <netinet/in.h>
 #endif /* HAVE_NETINET_IN_H */
 
-/* this can probably only be found in the kernel sources */
-#if HAVE_LINUX_IP_VS_H
 #include <linux/ip_vs.h>
-#elif HAVE_NET_IP_VS_H
-#include <net/ip_vs.h>
-#elif HAVE_IP_VS_H
-#include <ip_vs.h>
-#endif /* HAVE_IP_VS_H */
 
 #define log_err(...) ERROR("ipvs: " __VA_ARGS__)
 #define log_info(...) INFO("ipvs: " __VA_ARGS__)
@@ -64,68 +57,67 @@ static int sockfd = -1;
  */
 static struct ip_vs_get_services *ipvs_get_services(void) {
   struct ip_vs_getinfo ipvs_info;
-  struct ip_vs_get_services *ret;
+  struct ip_vs_get_services *services;
 
-  socklen_t len;
+  socklen_t len = sizeof(ipvs_info);
 
-  len = sizeof(ipvs_info);
-
-  if (0 != getsockopt(sockfd, IPPROTO_IP, IP_VS_SO_GET_INFO, (void *)&ipvs_info,
-                      &len)) {
+  if (getsockopt(sockfd, IPPROTO_IP, IP_VS_SO_GET_INFO, &ipvs_info, &len) ==
+      -1) {
     char errbuf[1024];
     log_err("ip_vs_get_services: getsockopt() failed: %s",
             sstrerror(errno, errbuf, sizeof(errbuf)));
     return NULL;
   }
 
-  len = sizeof(*ret) +
+  len = sizeof(*services) +
         sizeof(struct ip_vs_service_entry) * ipvs_info.num_services;
 
-  if (NULL == (ret = malloc(len))) {
+  services = malloc(len);
+  if (services == NULL) {
     log_err("ipvs_get_services: Out of memory.");
-    exit(3);
+    return NULL;
   }
 
-  ret->num_services = ipvs_info.num_services;
+  services->num_services = ipvs_info.num_services;
 
-  if (0 != getsockopt(sockfd, IPPROTO_IP, IP_VS_SO_GET_SERVICES, (void *)ret,
-                      &len)) {
+  if (getsockopt(sockfd, IPPROTO_IP, IP_VS_SO_GET_SERVICES, services, &len) ==
+      -1) {
     char errbuf[1024];
     log_err("ipvs_get_services: getsockopt failed: %s",
             sstrerror(errno, errbuf, sizeof(errbuf)));
 
-    free(ret);
+    free(services);
     return NULL;
   }
-  return ret;
+  return services;
 } /* ipvs_get_services */
 
 static struct ip_vs_get_dests *ipvs_get_dests(struct ip_vs_service_entry *se) {
-  struct ip_vs_get_dests *ret;
-  socklen_t len;
+  struct ip_vs_get_dests *dests;
 
-  len = sizeof(*ret) + sizeof(struct ip_vs_dest_entry) * se->num_dests;
+  socklen_t len =
+      sizeof(*dests) + sizeof(struct ip_vs_dest_entry) * se->num_dests;
 
-  if (NULL == (ret = malloc(len))) {
+  dests = malloc(len);
+  if (dests == NULL) {
     log_err("ipvs_get_dests: Out of memory.");
-    exit(3);
+    return NULL;
   }
 
-  ret->fwmark = se->fwmark;
-  ret->protocol = se->protocol;
-  ret->addr = se->addr;
-  ret->port = se->port;
-  ret->num_dests = se->num_dests;
+  dests->fwmark = se->fwmark;
+  dests->protocol = se->protocol;
+  dests->addr = se->addr;
+  dests->port = se->port;
+  dests->num_dests = se->num_dests;
 
-  if (0 !=
-      getsockopt(sockfd, IPPROTO_IP, IP_VS_SO_GET_DESTS, (void *)ret, &len)) {
+  if (getsockopt(sockfd, IPPROTO_IP, IP_VS_SO_GET_DESTS, dests, &len) == -1) {
     char errbuf[1024];
     log_err("ipvs_get_dests: getsockopt() failed: %s",
             sstrerror(errno, errbuf, sizeof(errbuf)));
-    free(ret);
+    free(dests);
     return NULL;
   }
-  return ret;
+  return dests;
 } /* ip_vs_get_dests */
 
 /*
@@ -134,19 +126,17 @@ static struct ip_vs_get_dests *ipvs_get_dests(struct ip_vs_service_entry *se) {
 static int cipvs_init(void) {
   struct ip_vs_getinfo ipvs_info;
 
-  socklen_t len;
-
-  if (-1 == (sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW))) {
+  if ((sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) == -1) {
     char errbuf[1024];
     log_err("cipvs_init: socket() failed: %s",
             sstrerror(errno, errbuf, sizeof(errbuf)));
     return -1;
   }
 
-  len = sizeof(ipvs_info);
+  socklen_t len = sizeof(ipvs_info);
 
-  if (0 != getsockopt(sockfd, IPPROTO_IP, IP_VS_SO_GET_INFO, (void *)&ipvs_info,
-                      &len)) {
+  if (getsockopt(sockfd, IPPROTO_IP, IP_VS_SO_GET_INFO, &ipvs_info, &len) ==
+      -1) {
     char errbuf[1024];
     log_err("cipvs_init: getsockopt() failed: %s",
             sstrerror(errno, errbuf, sizeof(errbuf)));
@@ -176,21 +166,16 @@ static int cipvs_init(void) {
 
 /* plugin instance */
 static int get_pi(struct ip_vs_service_entry *se, char *pi, size_t size) {
-  struct in_addr addr;
-  int len = 0;
-
-  if ((NULL == se) || (NULL == pi))
+  if ((se == NULL) || (pi == NULL))
     return 0;
 
-  addr.s_addr = se->addr;
+  struct in_addr addr = {.s_addr = se->addr};
 
-  /* inet_ntoa() returns a pointer to a statically allocated buffer
-   * I hope non-glibc systems behave the same */
-  len =
+  int len =
       ssnprintf(pi, size, "%s_%s%u", inet_ntoa(addr),
                 (se->protocol == IPPROTO_TCP) ? "TCP" : "UDP", ntohs(se->port));
 
-  if ((0 > len) || (size <= ((size_t)len))) {
+  if ((len < 0) || (size <= ((size_t)len))) {
     log_err("plugin instance truncated: %s", pi);
     return -1;
   }
@@ -199,19 +184,14 @@ static int get_pi(struct ip_vs_service_entry *se, char *pi, size_t size) {
 
 /* type instance */
 static int get_ti(struct ip_vs_dest_entry *de, char *ti, size_t size) {
-  struct in_addr addr;
-  int len = 0;
-
-  if ((NULL == de) || (NULL == ti))
+  if ((de == NULL) || (ti == NULL))
     return 0;
 
-  addr.s_addr = de->addr;
+  struct in_addr addr = {.s_addr = de->addr};
 
-  /* inet_ntoa() returns a pointer to a statically allocated buffer
-   * I hope non-glibc systems behave the same */
-  len = ssnprintf(ti, size, "%s_%u", inet_ntoa(addr), ntohs(de->port));
+  int len = ssnprintf(ti, size, "%s_%u", inet_ntoa(addr), ntohs(de->port));
 
-  if ((0 > len) || (size <= ((size_t)len))) {
+  if ((len < 0) || (size <= ((size_t)len))) {
     log_err("type instance truncated: %s", ti);
     return -1;
   }
@@ -228,11 +208,10 @@ static void cipvs_submit_connections(const char *pi, const char *ti,
   sstrncpy(vl.plugin, "ipvs", sizeof(vl.plugin));
   sstrncpy(vl.plugin_instance, pi, sizeof(vl.plugin_instance));
   sstrncpy(vl.type, "connections", sizeof(vl.type));
-  sstrncpy(vl.type_instance, (NULL != ti) ? ti : "total",
+  sstrncpy(vl.type_instance, (ti != NULL) ? ti : "total",
            sizeof(vl.type_instance));
 
   plugin_dispatch_values(&vl);
-  return;
 } /* cipvs_submit_connections */
 
 static void cipvs_submit_if(const char *pi, const char *t, const char *ti,
@@ -248,11 +227,10 @@ static void cipvs_submit_if(const char *pi, const char *t, const char *ti,
   sstrncpy(vl.plugin, "ipvs", sizeof(vl.plugin));
   sstrncpy(vl.plugin_instance, pi, sizeof(vl.plugin_instance));
   sstrncpy(vl.type, t, sizeof(vl.type));
-  sstrncpy(vl.type_instance, (NULL != ti) ? ti : "total",
+  sstrncpy(vl.type_instance, (ti != NULL) ? ti : "total",
            sizeof(vl.type_instance));
 
   plugin_dispatch_values(&vl);
-  return;
 } /* cipvs_submit_if */
 
 static void cipvs_submit_dest(const char *pi, struct ip_vs_dest_entry *de) {
@@ -260,13 +238,12 @@ static void cipvs_submit_dest(const char *pi, struct ip_vs_dest_entry *de) {
 
   char ti[DATA_MAX_NAME_LEN];
 
-  if (0 != get_ti(de, ti, sizeof(ti)))
+  if (get_ti(de, ti, sizeof(ti)) != 0)
     return;
 
   cipvs_submit_connections(pi, ti, stats.conns);
   cipvs_submit_if(pi, "if_packets", ti, stats.inpkts, stats.outpkts);
   cipvs_submit_if(pi, "if_octets", ti, stats.inbytes, stats.outbytes);
-  return;
 } /* cipvs_submit_dest */
 
 static void cipvs_submit_service(struct ip_vs_service_entry *se) {
@@ -275,7 +252,7 @@ static void cipvs_submit_service(struct ip_vs_service_entry *se) {
 
   char pi[DATA_MAX_NAME_LEN];
 
-  if (0 != get_pi(se, pi, sizeof(pi))) {
+  if (get_pi(se, pi, sizeof(pi)) != 0) {
     free(dests);
     return;
   }
@@ -292,12 +269,11 @@ static void cipvs_submit_service(struct ip_vs_service_entry *se) {
 } /* cipvs_submit_service */
 
 static int cipvs_read(void) {
-  struct ip_vs_get_services *services = NULL;
-
   if (sockfd < 0)
     return -1;
 
-  if (NULL == (services = ipvs_get_services()))
+  struct ip_vs_get_services *services = ipvs_get_services();
+  if (services == NULL)
     return -1;
 
   for (size_t i = 0; i < services->num_services; ++i)
index 1156169..8053929 100644 (file)
@@ -92,8 +92,9 @@ static int cldap_init_host(cldap_t *st) /* {{{ */
   if (rc != LDAP_SUCCESS) {
     ERROR("openldap plugin: ldap_initialize failed: %s", ldap_err2string(rc));
     st->state = 0;
-    ldap_unbind_ext_s(ld, NULL, NULL);
-    return -1;
+    if (ld != NULL)
+      ldap_unbind_ext_s(ld, NULL, NULL);
+    return (-1);
   }
 
   st->ld = ld;
@@ -119,8 +120,9 @@ static int cldap_init_host(cldap_t *st) /* {{{ */
       ERROR("openldap plugin: Failed to start tls on %s: %s", st->url,
             ldap_err2string(rc));
       st->state = 0;
-      ldap_unbind_ext_s(st->ld, NULL, NULL);
-      return -1;
+      if (st->ld != NULL)
+        ldap_unbind_ext_s(st->ld, NULL, NULL);
+      return (-1);
     }
   }
 
@@ -139,8 +141,9 @@ static int cldap_init_host(cldap_t *st) /* {{{ */
     ERROR("openldap plugin: Failed to bind to %s: %s", st->url,
           ldap_err2string(rc));
     st->state = 0;
-    ldap_unbind_ext_s(st->ld, NULL, NULL);
-    return -1;
+    if (st->ld != NULL)
+      ldap_unbind_ext_s(st->ld, NULL, NULL);
+    return (-1);
   } else {
     DEBUG("openldap plugin: Successfully connected to %s", st->url);
     st->state = 1;
@@ -214,8 +217,9 @@ static int cldap_read_host(user_data_t *ud) /* {{{ */
     ERROR("openldap plugin: Failed to execute search: %s", ldap_err2string(rc));
     ldap_msgfree(result);
     st->state = 0;
-    ldap_unbind_ext_s(st->ld, NULL, NULL);
-    return -1;
+    if (st->ld != NULL)
+      ldap_unbind_ext_s(st->ld, NULL, NULL);
+    return (-1);
   }
 
   for (LDAPMessage *e = ldap_first_entry(st->ld, result); e != NULL;
index 6cbe881..d7aea2d 100644 (file)
@@ -163,7 +163,7 @@ static void snmp_agent_dump_data(void) {
         DEBUG(PLUGIN_NAME ":     Type: %s", dd->type);
       if (dd->type_instance)
         DEBUG(PLUGIN_NAME ":     TypeInstance: %s", dd->type_instance);
-      for (int i = 0; i < dd->oids_len; i++) {
+      for (size_t i = 0; i < dd->oids_len; i++) {
         snmp_agent_oid_to_string(oid_str, sizeof(oid_str), &dd->oids[i]);
         DEBUG(PLUGIN_NAME ":     OID[%d]: %s", i, oid_str);
       }
@@ -187,7 +187,7 @@ static void snmp_agent_dump_data(void) {
       DEBUG(PLUGIN_NAME ":   Type: %s", dd->type);
     if (dd->type_instance)
       DEBUG(PLUGIN_NAME ":   TypeInstance: %s", dd->type_instance);
-    for (int i = 0; i < dd->oids_len; i++) {
+    for (size_t i = 0; i < dd->oids_len; i++) {
       snmp_agent_oid_to_string(oid_str, sizeof(oid_str), &dd->oids[i]);
       DEBUG(PLUGIN_NAME ":   OID[%d]: %s", i, oid_str);
     }
@@ -282,7 +282,7 @@ static int snmp_agent_validate_data(void) {
   return 0;
 }
 
-static void snmp_agent_generate_oid2string(oid_t *oid, int offset, char *key) {
+static void snmp_agent_generate_oid2string(oid_t *oid, size_t offset, char *key) {
   int key_len = oid->oid[offset];
   int i;
 
@@ -352,7 +352,7 @@ static int snmp_agent_table_row_remove(table_definition_t *td,
   for (llentry_t *de = llist_head(td->columns); de != NULL; de = de->next) {
     data_definition_t *dd = de->value;
 
-    for (int i = 0; i < dd->oids_len; i++)
+    for (size_t i = 0; i < dd->oids_len; i++)
       if (td->index_oid.oid_len)
         snmp_agent_unregister_oid_index(&dd->oids[i], *index);
       else
@@ -417,7 +417,7 @@ static void snmp_agent_free_data(data_definition_t **dd) {
 
   /* unregister scalar type OID */
   if ((*dd)->table == NULL) {
-    for (int i = 0; i < (*dd)->oids_len; i++)
+    for (size_t i = 0; i < (*dd)->oids_len; i++)
       unregister_mib((*dd)->oids[i].oid, (*dd)->oids[i].oid_len);
   }
   if (!(*dd)->table->index_oid.oid_len) {
@@ -426,7 +426,7 @@ static void snmp_agent_free_data(data_definition_t **dd) {
     c_avl_iterator_t *iter = c_avl_get_iterator((*dd)->table->instance_index);
     while (c_avl_iterator_next(iter, (void *)&instance, (void *)&instance) ==
            0) {
-      for (int i = 0; i < (*dd)->oids_len; i++)
+      for (size_t i = 0; i < (*dd)->oids_len; i++)
         snmp_agent_unregister_oid_string(&(*dd)->oids[i], instance);
     }
     c_avl_iterator_destroy(iter);
@@ -437,7 +437,7 @@ static void snmp_agent_free_data(data_definition_t **dd) {
 
     c_avl_iterator_t *iter = c_avl_get_iterator((*dd)->table->index_instance);
     while (c_avl_iterator_next(iter, (void *)&index, (void *)&value) == 0) {
-      for (int i = 0; i < (*dd)->oids_len; i++)
+      for (size_t i = 0; i < (*dd)->oids_len; i++)
         snmp_agent_unregister_oid_index(&(*dd)->oids[i], *index);
     }
     c_avl_iterator_destroy(iter);
@@ -529,7 +529,7 @@ static int snmp_agent_form_reply(struct netsnmp_request_info_s *requests,
   }
 
   assert(ds->ds_num == values_num);
-  assert(oid_index < values_num);
+  assert(oid_index < (int)values_num);
 
   char data[DATA_MAX_NAME_LEN];
   size_t data_len = sizeof(data);
@@ -545,8 +545,8 @@ static int snmp_agent_form_reply(struct netsnmp_request_info_s *requests,
   }
 
   requests->requestvb->type = dd->oids[oid_index].type;
-  snmp_set_var_typed_value(requests->requestvb, requests->requestvb->type, data,
-                           data_len);
+  snmp_set_var_typed_value(requests->requestvb, requests->requestvb->type,
+                           (const u_char *)data, data_len);
 
   return SNMP_ERR_NOERROR;
 }
@@ -581,7 +581,7 @@ snmp_agent_table_oid_handler(struct netsnmp_mib_handler_s *handler,
     for (llentry_t *de = llist_head(td->columns); de != NULL; de = de->next) {
       data_definition_t *dd = de->value;
 
-      for (int i = 0; i < dd->oids_len; i++) {
+      for (size_t i = 0; i < dd->oids_len; i++) {
         int ret = snmp_oid_ncompare(oid.oid, oid.oid_len, dd->oids[i].oid,
                                     dd->oids[i].oid_len,
                                     MIN(oid.oid_len, dd->oids[i].oid_len));
@@ -617,7 +617,7 @@ snmp_agent_table_oid_handler(struct netsnmp_mib_handler_s *handler,
         if (dd->is_instance) {
           requests->requestvb->type = ASN_OCTET_STR;
           snmp_set_var_typed_value(requests->requestvb,
-                                   requests->requestvb->type, instance,
+                                   requests->requestvb->type, (const u_char *)instance,
                                    strlen((instance)));
 
           pthread_mutex_unlock(&g_agent->lock);
@@ -678,7 +678,7 @@ static int snmp_agent_table_index_oid_handler(
 
       requests->requestvb->type = ASN_INTEGER;
       snmp_set_var_typed_value(requests->requestvb, requests->requestvb->type,
-                               &index, sizeof(index));
+                               (const u_char *)&index, sizeof(index));
 
       pthread_mutex_unlock(&g_agent->lock);
 
@@ -724,7 +724,7 @@ static int snmp_agent_table_size_oid_handler(
 
       requests->requestvb->type = td->size_oid.type;
       snmp_set_var_typed_value(requests->requestvb, requests->requestvb->type,
-                               &size, sizeof(size));
+                               (const u_char *)&size, sizeof(size));
 
       pthread_mutex_unlock(&g_agent->lock);
 
@@ -765,7 +765,7 @@ snmp_agent_scalar_oid_handler(struct netsnmp_mib_handler_s *handler,
        de = de->next) {
     data_definition_t *dd = de->value;
 
-    for (int i = 0; i < dd->oids_len; i++) {
+    for (size_t i = 0; i < dd->oids_len; i++) {
 
       int ret = snmp_oid_compare(oid.oid, oid.oid_len, dd->oids[i].oid,
                                  dd->oids[i].oid_len);
@@ -803,7 +803,7 @@ static int snmp_agent_register_table_oids(void) {
     for (llentry_t *de = llist_head(td->columns); de != NULL; de = de->next) {
       data_definition_t *dd = de->value;
 
-      for (int i = 0; i < dd->oids_len; i++) {
+      for (size_t i = 0; i < dd->oids_len; i++) {
         dd->oids[i].type =
             snmp_agent_get_asn_type(dd->oids[i].oid, dd->oids[i].oid_len);
       }
@@ -818,7 +818,7 @@ static int snmp_agent_register_scalar_oids(void) {
   for (llentry_t *e = llist_head(g_agent->scalars); e != NULL; e = e->next) {
     data_definition_t *dd = e->value;
 
-    for (int i = 0; i < dd->oids_len; i++) {
+    for (size_t i = 0; i < dd->oids_len; i++) {
 
       dd->oids[i].type =
           snmp_agent_get_asn_type(dd->oids[i].oid, dd->oids[i].oid_len);
@@ -1284,7 +1284,7 @@ static int snmp_agent_update_index(table_definition_t *td,
   for (llentry_t *de = llist_head(td->columns); de != NULL; de = de->next) {
     data_definition_t *dd = de->value;
 
-    for (int i = 0; i < dd->oids_len; i++) {
+    for (size_t i = 0; i < dd->oids_len; i++) {
       if (td->index_oid.oid_len) {
         ret = snmp_agent_register_oid_index(&dd->oids[i], *index,
                                             snmp_agent_table_oid_handler);
index 8ccde80..00b930e 100644 (file)
@@ -134,7 +134,7 @@ static int us_open_socket(void) {
     const char *grpname;
     struct group *g;
     struct group sg;
-    char grbuf[2048];
+    char grbuf[4096];
 
     grpname = (sock_group != NULL) ? sock_group : COLLECTD_GRP_NAME;
     g = NULL;
@@ -143,7 +143,7 @@ static int us_open_socket(void) {
     if (status != 0) {
       char errbuf[1024];
       WARNING("unixsock plugin: getgrnam_r (%s) failed: %s", grpname,
-              sstrerror(errno, errbuf, sizeof(errbuf)));
+              sstrerror(status, errbuf, sizeof(errbuf)));
       break;
     }
     if (g == NULL) {
index fd6c4e2..f124ba1 100644 (file)
@@ -180,8 +180,13 @@ int format_graphite(char *buffer, size_t buffer_size, data_set_t const *ds,
   int buffer_pos = 0;
 
   gauge_t *rates = NULL;
-  if (flags & GRAPHITE_STORE_RATES)
+  if (flags & GRAPHITE_STORE_RATES) {
     rates = uc_get_rate(ds, vl);
+    if (rates == NULL) {
+      ERROR("format_graphite: error with uc_get_rate");
+      return -1;
+    }
+  }
 
   for (size_t i = 0; i < ds->ds_num; i++) {
     char const *ds_name = NULL;
index 3cdc3d1..33f9bd5 100644 (file)
@@ -78,7 +78,7 @@ static bson_t *wm_create_bson(const data_set_t *ds, /* {{{ */
     rates = uc_get_rate(ds, vl);
     if (rates == NULL) {
       ERROR("write_mongodb plugin: uc_get_rate() failed.");
-      bson_free(ret);
+      bson_destroy(ret);
       return NULL;
     }
   } else {
@@ -111,7 +111,7 @@ static bson_t *wm_create_bson(const data_set_t *ds, /* {{{ */
     else {
       ERROR("write_mongodb plugin: Unknown ds_type %d for index %d",
             ds->ds[i].type, i);
-      bson_free(ret);
+      bson_destroy(ret);
       return NULL;
     }
   }
@@ -145,7 +145,7 @@ static bson_t *wm_create_bson(const data_set_t *ds, /* {{{ */
   if (!bson_validate(ret, BSON_VALIDATE_UTF8, &error_location)) {
     ERROR("write_mongodb plugin: Error in generated BSON document "
         "at byte %zu", error_location);
-    bson_free(ret);
+    bson_destroy(ret);
     return NULL;
   }
 
@@ -249,7 +249,7 @@ static int wm_write(const data_set_t *ds, /* {{{ */
   if (wm_initialize(node) < 0) {
     ERROR("write_mongodb plugin: error making connection to server");
     pthread_mutex_unlock(&node->lock);
-    bson_free(bson_record);
+    bson_destroy(bson_record);
     return -1;
   }
 
@@ -263,7 +263,7 @@ static int wm_write(const data_set_t *ds, /* {{{ */
     node->client = NULL;
     node->connected = 0;
     pthread_mutex_unlock(&node->lock);
-    bson_free(bson_record);
+    bson_destroy(bson_record);
     return -1;
   }
 
@@ -278,7 +278,7 @@ static int wm_write(const data_set_t *ds, /* {{{ */
     node->client = NULL;
     node->connected = 0;
     pthread_mutex_unlock(&node->lock);
-    bson_free(bson_record);
+    bson_destroy(bson_record);
     mongoc_collection_destroy(collection);
     return -1;
   }
@@ -288,7 +288,7 @@ static int wm_write(const data_set_t *ds, /* {{{ */
 
   pthread_mutex_unlock(&node->lock);
 
-  bson_free(bson_record);
+  bson_destroy(bson_record);
 
   return 0;
 } /* }}} int wm_write */
index bdbb847..2c7a2e5 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-DEFAULT_VERSION="5.7.1.git"
+DEFAULT_VERSION="5.7.2.git"
 
 if [ -d .git ]; then
        VERSION="`git describe --dirty=+ --abbrev=7 2> /dev/null | grep collectd | sed -e 's/^collectd-//' -e 's/-/./g'`"