Merge remote-tracking branch 'github/pr/2258'
authorFlorian Forster <octo@collectd.org>
Wed, 30 Aug 2017 11:34:28 +0000 (13:34 +0200)
committerFlorian Forster <octo@collectd.org>
Wed, 30 Aug 2017 11:34:28 +0000 (13:34 +0200)
1  2 
Makefile.am
configure.ac
src/collectd-nagios.c
src/collectd-tg.c
src/collectdctl.c
src/libcollectdclient/client.c

diff --combined Makefile.am
@@@ -89,9 -89,12 +89,12 @@@ nodist_pkgconfig_DATA = 
  
  pkginclude_HEADERS = \
        src/libcollectdclient/collectd/client.h \
-       src/libcollectdclient/collectd/network.h \
+       src/libcollectdclient/collectd/lcc_features.h \
        src/libcollectdclient/collectd/network_buffer.h \
-       src/libcollectdclient/collectd/lcc_features.h
+       src/libcollectdclient/collectd/network.h \
+       src/libcollectdclient/collectd/network_parse.h \
+       src/libcollectdclient/collectd/server.h \
+       src/libcollectdclient/collectd/types.h
  
  lib_LTLIBRARIES = libcollectdclient.la
  
@@@ -114,15 -117,11 +117,15 @@@ noinst_LTLIBRARIES = 
        libformat_graphite.la \
        libformat_json.la \
        libheap.la \
 +      libignorelist.la \
        liblatency.la \
        liblookup.la \
        libmetadata.la \
        libmount.la \
 -      liboconfig.la \
 +      liboconfig.la
 +
 +
 +check_LTLIBRARIES = \
        libplugin_mock.la
  
  
@@@ -137,7 -136,8 +140,8 @@@ check_PROGRAMS = 
        test_utils_mount \
        test_utils_subst \
        test_utils_time \
-       test_utils_vl_lookup
+       test_utils_vl_lookup \
+       test_libcollectd_network_parse
  
  
  TESTS = $(check_PROGRAMS)
@@@ -203,6 -203,8 +207,6 @@@ collectd_SOURCES = 
        src/daemon/utils_cache.h \
        src/daemon/utils_complain.c \
        src/daemon/utils_complain.h \
 -      src/daemon/utils_ignorelist.c \
 -      src/daemon/utils_ignorelist.h \
        src/daemon/utils_llist.c \
        src/daemon/utils_llist.h \
        src/daemon/utils_random.c \
@@@ -246,8 -248,8 +250,8 @@@ collectdmon_SOURCES = src/collectdmon.
  
  collectd_nagios_SOURCES = src/collectd-nagios.c
  collectd_nagios_CPPFLAGS = $(AM_CPPFLAGS) \
-       -I$(srcdir)/src/libcollectdclient/collectd \
-       -I$(top_builddir)/src/libcollectdclient/collectd
+       -I$(srcdir)/src/libcollectdclient \
+       -I$(top_builddir)/src/libcollectdclient
  collectd_nagios_LDADD = libcollectdclient.la
  if BUILD_WITH_LIBSOCKET
  collectd_nagios_LDADD += -lsocket
@@@ -259,8 -261,8 +263,8 @@@ endi
  
  collectdctl_SOURCES = src/collectdctl.c
  collectdctl_CPPFLAGS = $(AM_CPPFLAGS) \
-       -I$(srcdir)/src/libcollectdclient/collectd \
-       -I$(top_builddir)/src/libcollectdclient/collectd
+       -I$(srcdir)/src/libcollectdclient \
+       -I$(top_builddir)/src/libcollectdclient
  collectdctl_LDADD = libcollectdclient.la
  if BUILD_WITH_LIBSOCKET
  collectdctl_LDADD += -lsocket
@@@ -272,8 -274,8 +276,8 @@@ endi
  
  collectd_tg_SOURCES = src/collectd-tg.c
  collectd_tg_CPPFLAGS = $(AM_CPPFLAGS) \
-       -I$(srcdir)/src/libcollectdclient/collectd \
-       -I$(top_builddir)/src/libcollectdclient/collectd
+       -I$(srcdir)/src/libcollectdclient \
+       -I$(top_builddir)/src/libcollectdclient
  collectd_tg_LDADD = \
        $(PTHREAD_LIBS) \
        libheap.la \
@@@ -333,10 -335,6 +337,10 @@@ libheap_la_SOURCES = 
        src/daemon/utils_heap.c \
        src/daemon/utils_heap.h
  
 +libignorelist_la_SOURCES = \
 +      src/utils_ignorelist.c \
 +      src/utils_ignorelist.h
 +
  libmetadata_la_SOURCES = \
        src/daemon/meta_data.c \
        src/daemon/meta_data.h
@@@ -346,11 -344,13 +350,11 @@@ libplugin_mock_la_SOURCES = 
        src/daemon/utils_cache_mock.c \
        src/daemon/utils_complain.c \
        src/daemon/utils_complain.h \
 -      src/daemon/utils_ignorelist.c \
 -      src/daemon/utils_ignorelist.h \
        src/daemon/utils_time.c \
        src/daemon/utils_time.h
  
  libplugin_mock_la_CPPFLAGS = $(AM_CPPFLAGS) -DMOCK_TIME
 -libplugin_mock_la_LIBADD = libcommon.la $(COMMON_LIBS)
 +libplugin_mock_la_LIBADD = libcommon.la libignorelist.la $(COMMON_LIBS)
  
  libformat_graphite_la_SOURCES = \
        src/utils_format_graphite.c \
@@@ -475,20 -475,34 +479,34 @@@ endi
  libcollectdclient_la_SOURCES = \
        src/libcollectdclient/client.c \
        src/libcollectdclient/network.c \
-       src/libcollectdclient/network_buffer.c
+       src/libcollectdclient/network_buffer.c \
+       src/libcollectdclient/network_parse.c \
+       src/libcollectdclient/server.c
  libcollectdclient_la_CPPFLAGS = \
        $(AM_CPPFLAGS) \
-       -I$(srcdir)/src/libcollectdclient/collectd \
-       -I$(top_builddir)/src/libcollectdclient/collectd \
+       -I$(srcdir)/src/libcollectdclient \
+       -I$(top_builddir)/src/libcollectdclient \
        -I$(srcdir)/src/daemon
- libcollectdclient_la_LDFLAGS = -version-info 1:0:0
- libcollectdclient_la_LIBADD = 
+ libcollectdclient_la_LDFLAGS = -version-info 2:0:1
+ libcollectdclient_la_LIBADD = -lm
  if BUILD_WITH_LIBGCRYPT
  libcollectdclient_la_CPPFLAGS += $(GCRYPT_CPPFLAGS)
  libcollectdclient_la_LDFLAGS += $(GCRYPT_LDFLAGS)
  libcollectdclient_la_LIBADD += $(GCRYPT_LIBS)
  endif
  
+ # network_parse_test.c includes network_parse.c, so no need to link with
+ # libcollectdclient.so.
+ test_libcollectd_network_parse_SOURCES = src/libcollectdclient/network_parse_test.c
+ test_libcollectd_network_parse_CPPFLAGS = \
+       $(AM_CPPFLAGS) \
+       -I$(srcdir)/src/libcollectdclient \
+       -I$(top_builddir)/src/libcollectdclient
+ if BUILD_WITH_LIBGCRYPT
+ test_libcollectd_network_parse_CPPFLAGS += $(GCRYPT_CPPFLAGS)
+ test_libcollectd_network_parse_LDFLAGS = $(GCRYPT_LDFLAGS)
+ test_libcollectd_network_parse_LDADD = $(GCRYPT_LIBS)
+ endif
  
  liboconfig_la_SOURCES = \
        src/liboconfig/oconfig.c \
@@@ -606,7 -620,7 +624,7 @@@ if BUILD_PLUGIN_CGROUP
  pkglib_LTLIBRARIES += cgroups.la
  cgroups_la_SOURCES = src/cgroups.c
  cgroups_la_LDFLAGS = $(PLUGIN_LDFLAGS)
 -cgroups_la_LIBADD = libmount.la
 +cgroups_la_LIBADD = libignorelist.la libmount.la
  endif
  
  if BUILD_PLUGIN_CHRONY
@@@ -694,15 -708,6 +712,15 @@@ curl_json_la_CFLAGS = $(AM_CFLAGS) $(BU
  curl_json_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBYAJL_CPPFLAGS)
  curl_json_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBYAJL_LDFLAGS)
  curl_json_la_LIBADD = $(BUILD_WITH_LIBCURL_LIBS) $(BUILD_WITH_LIBYAJL_LIBS)
 +
 +test_plugin_curl_json_SOURCES = src/curl_json_test.c \
 +                              src/utils_curl_stats.c \
 +                              src/daemon/configfile.c \
 +                              src/daemon/types_list.c
 +test_plugin_curl_json_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBYAJL_CPPFLAGS)
 +test_plugin_curl_json_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBYAJL_LDFLAGS)
 +test_plugin_curl_json_LDADD = libavltree.la liboconfig.la libplugin_mock.la $(BUILD_WITH_LIBCURL_LIBS) $(BUILD_WITH_LIBYAJL_LIBS)
 +check_PROGRAMS += test_plugin_curl_json
  endif
  
  if BUILD_PLUGIN_CURL_XML
@@@ -732,7 -737,7 +750,7 @@@ if BUILD_PLUGIN_D
  pkglib_LTLIBRARIES += df.la
  df_la_SOURCES = src/df.c
  df_la_LDFLAGS = $(PLUGIN_LDFLAGS)
 -df_la_LIBADD = libmount.la
 +df_la_LIBADD = libignorelist.la libmount.la
  endif
  
  if BUILD_PLUGIN_DISK
@@@ -741,7 -746,7 +759,7 @@@ disk_la_SOURCES = src/disk.
  disk_la_CFLAGS = $(AM_CFLAGS)
  disk_la_CPPFLAGS = $(AM_CPPFLAGS)
  disk_la_LDFLAGS = $(PLUGIN_LDFLAGS)
 -disk_la_LIBADD =
 +disk_la_LIBADD = libignorelist.la
  if BUILD_WITH_LIBKSTAT
  disk_la_LIBADD += -lkstat
  endif
@@@ -783,18 -788,16 +801,18 @@@ if BUILD_PLUGIN_DPDKEVENT
  pkglib_LTLIBRARIES += dpdkevents.la
  dpdkevents_la_SOURCES = src/dpdkevents.c src/utils_dpdk.c src/utils_dpdk.h
  dpdkevents_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBDPDK_CPPFLAGS)
 +dpdkevents_la_CFLAGS = $(AM_CFLAGS) $(LIBDPDK_CFLAGS)
  dpdkevents_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(LIBDPDK_LDFLAGS)
 -dpdkevents_la_LIBADD = -ldpdk
 +dpdkevents_la_LIBADD = $(LIBDPDK_LIBS)
  endif
  
  if BUILD_PLUGIN_DPDKSTAT
  pkglib_LTLIBRARIES += dpdkstat.la
  dpdkstat_la_SOURCES = src/dpdkstat.c src/utils_dpdk.c src/utils_dpdk.h
  dpdkstat_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBDPDK_CPPFLAGS)
 +dpdkstat_la_CFLAGS = $(AM_CFLAGS) $(LIBDPDK_CFLAGS)
  dpdkstat_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(LIBDPDK_LDFLAGS)
 -dpdkstat_la_LIBADD = -ldpdk
 +dpdkstat_la_LIBADD = $(LIBDPDK_LIBS)
  endif
  
  if BUILD_PLUGIN_DRBD
@@@ -890,14 -893,6 +908,14 @@@ hugepages_la_SOURCES = src/hugepages.
  hugepages_la_LDFLAGS = $(PLUGIN_LDFLAGS)
  endif
  
 +if BUILD_PLUGIN_INTEL_PMU
 +pkglib_LTLIBRARIES += intel_pmu.la
 +intel_pmu_la_SOURCES = src/intel_pmu.c
 +intel_pmu_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBJEVENTS_CPPFLAGS)
 +intel_pmu_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBJEVENTS_LDFLAGS)
 +intel_pmu_la_LIBADD = $(BUILD_WITH_LIBJEVENTS_LIBS)
 +endif
 +
  if BUILD_PLUGIN_INTEL_RDT
  pkglib_LTLIBRARIES += intel_rdt.la
  intel_rdt_la_SOURCES = src/intel_rdt.c
@@@ -911,7 -906,7 +929,7 @@@ pkglib_LTLIBRARIES += interface.l
  interface_la_SOURCES = src/interface.c
  interface_la_CFLAGS = $(AM_CFLAGS)
  interface_la_LDFLAGS = $(PLUGIN_LDFLAGS)
 -interface_la_LIBADD =
 +interface_la_LIBADD = libignorelist.la
  if BUILD_WITH_LIBSTATGRAB
  interface_la_CFLAGS += $(BUILD_WITH_LIBSTATGRAB_CFLAGS)
  interface_la_LIBADD += $(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
@@@ -947,12 -942,16 +965,12 @@@ pkglib_LTLIBRARIES += ipmi.l
  ipmi_la_SOURCES = src/ipmi.c
  ipmi_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_OPENIPMI_CFLAGS)
  ipmi_la_LDFLAGS = $(PLUGIN_LDFLAGS)
 -ipmi_la_LIBADD = $(BUILD_WITH_OPENIPMI_LIBS)
 +ipmi_la_LIBADD = libignorelist.la $(BUILD_WITH_OPENIPMI_LIBS)
  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
  
@@@ -960,7 -959,6 +978,7 @@@ if BUILD_PLUGIN_IR
  pkglib_LTLIBRARIES += irq.la
  irq_la_SOURCES = src/irq.c
  irq_la_LDFLAGS = $(PLUGIN_LDFLAGS)
 +irq_la_LIBADD = libignorelist.la
  endif
  
  if BUILD_PLUGIN_JAVA
@@@ -1033,7 -1031,6 +1051,7 @@@ madwifi_la_SOURCES = 
        src/madwifi.c \
        src/madwifi.h
  madwifi_la_LDFLAGS = $(PLUGIN_LDFLAGS)
 +madwifi_la_LIBADD = libignorelist.la
  endif
  
  if BUILD_PLUGIN_MATCH_EMPTY_COUNTER
@@@ -1086,7 -1083,6 +1104,7 @@@ if BUILD_PLUGIN_M
  pkglib_LTLIBRARIES += md.la
  md_la_SOURCES = src/md.c
  md_la_LDFLAGS = $(PLUGIN_LDFLAGS)
 +md_la_LIBADD = libignorelist.la
  endif
  
  if BUILD_PLUGIN_MEMCACHEC
@@@ -1136,7 -1132,7 +1154,7 @@@ pkglib_LTLIBRARIES += mic.l
  mic_la_SOURCES = src/mic.c
  mic_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_MIC_CPPFLAGS)
  mic_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_MIC_LDFLAGS)
 -mic_la_LIBADD = $(BUILD_WITH_MIC_LIBS)
 +mic_la_LIBADD = libignorelist.la $(BUILD_WITH_MIC_LIBS)
  endif
  
  if BUILD_PLUGIN_MODBUS
@@@ -1174,7 -1170,7 +1192,7 @@@ pkglib_LTLIBRARIES += netapp.l
  netapp_la_SOURCES = src/netapp.c
  netapp_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBNETAPP_CPPFLAGS)
  netapp_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(LIBNETAPP_LDFLAGS)
 -netapp_la_LIBADD = $(LIBNETAPP_LIBS)
 +netapp_la_LIBADD = libignorelist.la $(LIBNETAPP_LIBS)
  endif
  
  if BUILD_PLUGIN_NETLINK
@@@ -1279,8 -1275,8 +1297,8 @@@ if BUILD_PLUGIN_ONEWIR
  pkglib_LTLIBRARIES += onewire.la
  onewire_la_SOURCES = src/onewire.c
  onewire_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBOWCAPI_CPPFLAGS)
 -onewire_la_LIBADD = $(BUILD_WITH_LIBOWCAPI_LIBS)
  onewire_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBOWCAPI_LDFLAGS)
 +onewire_la_LIBADD = libignorelist.la $(BUILD_WITH_LIBOWCAPI_LIBS)
  endif
  
  if BUILD_PLUGIN_OPENLDAP
@@@ -1398,6 -1394,9 +1416,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
  
@@@ -1415,7 -1414,6 +1433,7 @@@ if BUILD_PLUGIN_PROTOCOL
  pkglib_LTLIBRARIES += protocols.la
  protocols_la_SOURCES = src/protocols.c
  protocols_la_LDFLAGS = $(PLUGIN_LDFLAGS)
 +protocols_la_LIBADD = libignorelist.la
  endif
  
  if BUILD_PLUGIN_REDIS
@@@ -1461,7 -1459,7 +1479,7 @@@ pkglib_LTLIBRARIES += sensors.l
  sensors_la_SOURCES = src/sensors.c
  sensors_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBSENSORS_CPPFLAGS)
  sensors_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBSENSORS_LDFLAGS)
 -sensors_la_LIBADD = $(BUILD_WITH_LIBSENSORS_LIBS)
 +sensors_la_LIBADD = libignorelist.la $(BUILD_WITH_LIBSENSORS_LIBS)
  endif
  
  if BUILD_PLUGIN_SERIAL
@@@ -1484,7 -1482,7 +1502,7 @@@ pkglib_LTLIBRARIES += smart.l
  smart_la_SOURCES = src/smart.c
  smart_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBATASMART_CPPFLAGS) $(BUILD_WITH_LIBUDEV_CPPFLAGS)
  smart_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBATASMART_LDFLAGS) $(BUILD_WITH_LIBUDEV_LDFLAGS)
 -smart_la_LIBADD = $(BUILD_WITH_LIBATASMART_LIBS) $(BUILD_WITH_LIBUDEV_LIBS)
 +smart_la_LIBADD = libignorelist.la $(BUILD_WITH_LIBATASMART_LIBS) $(BUILD_WITH_LIBUDEV_LIBS)
  endif
  endif
  
@@@ -1496,14 -1494,6 +1514,14 @@@ snmp_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(B
  snmp_la_LIBADD = $(BUILD_WITH_LIBNETSNMP_LIBS)
  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_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
  pkglib_LTLIBRARIES += statsd.la
  statsd_la_SOURCES = src/statsd.c
@@@ -1634,7 -1624,6 +1652,7 @@@ if BUILD_PLUGIN_THERMA
  pkglib_LTLIBRARIES += thermal.la
  thermal_la_SOURCES = src/thermal.c
  thermal_la_LDFLAGS = $(PLUGIN_LDFLAGS)
 +thermal_la_LIBADD = libignorelist.la
  endif
  
  if BUILD_PLUGIN_THRESHOLD
@@@ -1712,8 -1701,8 +1730,8 @@@ pkglib_LTLIBRARIES += virt.l
  virt_la_SOURCES = src/virt.c
  virt_la_CFLAGS = $(AM_CFLAGS) \
        $(BUILD_WITH_LIBVIRT_CFLAGS) $(BUILD_WITH_LIBXML2_CFLAGS)
 -virt_la_LIBADD = $(BUILD_WITH_LIBVIRT_LIBS) $(BUILD_WITH_LIBXML2_LIBS)
  virt_la_LDFLAGS = $(PLUGIN_LDFLAGS)
 +virt_la_LIBADD = libignorelist.la $(BUILD_WITH_LIBVIRT_LIBS) $(BUILD_WITH_LIBXML2_LIBS)
  
  # TODO: enable once we support only modern libvirts which depends on libnl-3
  # the libvirt on wheezy is linked in libnl v1, and there is a small leak here,
@@@ -1787,8 -1776,9 +1805,8 @@@ endi
  if BUILD_PLUGIN_WRITE_MONGODB
  pkglib_LTLIBRARIES += write_mongodb.la
  write_mongodb_la_SOURCES = src/write_mongodb.c
 -write_mongodb_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBMONGOC_CPPFLAGS)
 +write_mongodb_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBMONGOC_CFLAGS)
  write_mongodb_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBMONGOC_LDFLAGS)
 -write_mongodb_la_LIBADD = -lmongoc
  endif
  
  if BUILD_PLUGIN_WRITE_PROMETHEUS
@@@ -2025,10 -2015,10 +2043,10 @@@ dist_noinst_JAVA = 
        bindings/java/org/collectd/java/GenericJMXConfValue.java \
        bindings/java/org/collectd/java/JMXMemory.java
  
 -collectd-api.jar: classnoinst.stamp
 +collectd-api.jar: $(JAVA_TIMESTAMP_FILE)
        $(JAR) cf $(JARFLAGS) $@ org/collectd/api/*.class
  
 -generic-jmx.jar: classnoinst.stamp
 +generic-jmx.jar: $(JAVA_TIMESTAMP_FILE)
        $(JAR) cf $(JARFLAGS) $@ org/collectd/java/*.class
  
  jar_DATA = collectd-api.jar generic-jmx.jar
diff --combined configure.ac
@@@ -27,9 -27,6 +27,9 @@@ AC_SYS_LARGEFIL
  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
@@@ -37,6 -34,7 +37,6 @@@ AC_PROG_INSTAL
  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 -60,9 +62,9 @@@ if test "x$collectd_cv_prog_bison" = "x
    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,6 -110,15 +112,6 @@@ AM_CONDITIONAL([BUILD_LINUX], [test "x$
  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.])
@@@ -168,6 -175,7 +168,7 @@@ AC_CHECK_HEADERS_ONCE([ 
    pthread_np.h \
    pwd.h \
    regex.h \
+   sys/endian.h \
    sys/fs_types.h \
    sys/fstyp.h \
    sys/ioctl.h \
@@@ -352,7 -360,7 +353,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 \
        IOKit/ps/IOPSKeys.h \
        IOKit/IOBSD.h \
        IOKit/storage/IOBlockStorageDriver.h
 -    ]]
 +    ]
    )
  
    # For the battery plugin
@@@ -452,7 -460,7 +453,7 @@@ if test "x$ac_system" = "xLinux"; the
        #endif
      ]]
    )
 -  
 +
    AC_CHECK_HEADERS([linux/inet_diag.h], [], [],
      [[
        #if HAVE_SYS_TYPES_H
        #endif
      ]]
    )
 -  
 +
    AC_CHECK_HEADERS([linux/netdevice.h], [], [],
      [[
        #if HAVE_SYS_TYPES_H
        #endif
      ]]
    )
 -  
 +
    # For ethstat module
    AC_CHECK_HEADERS([linux/sockios.h],
      [have_linux_sockios_h="yes"],
        #endif
      ]]
    )
 -  
 +
    AC_CHECK_HEADERS([linux/ethtool.h],
      [have_linux_ethtool_h="yes"],
      [have_linux_ethtool_h="no"],
    )
  
    # 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], [], [],
      [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],
        ]
      )
    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)"]
@@@ -580,6 -609,7 +581,6 @@@ els
    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
@@@ -1010,92 -1040,6 +1011,92 @@@ if test "x$GCC" = "xyes"; the
  fi
  # }}} Check for strptime
  
 +# Check for timegm {{{
 +
 +# These checks need -Werror because implicit function declarations are only a
 +# warning ...
 +SAVE_CFLAGS="$CFLAGS"
 +CFLAGS="$CFLAGS -Werror"
 +
 +AC_CACHE_CHECK([for timegm],
 +  [c_cv_have_timegm],
 +  AC_LINK_IFELSE(
 +    [AC_LANG_PROGRAM(
 +[[[
 +#if STRPTIME_NEEDS_STANDARDS
 +# ifndef _ISOC99_SOURCE
 +#  define _ISOC99_SOURCE 1
 +# endif
 +# ifndef _POSIX_C_SOURCE
 +#  define _POSIX_C_SOURCE 200112L
 +# endif
 +# ifndef _XOPEN_SOURCE
 +#  define _XOPEN_SOURCE 500
 +# endif
 +#endif
 +#include <time.h>
 +]]],
 +[[[
 + time_t t = timegm(&(struct tm){0});
 + if (t == ((time_t) -1)) {
 +   return 1;
 + }
 +]]]
 +    )],
 +    [c_cv_have_timegm="yes"],
 +    [c_cv_have_timegm="no"]
 +  )
 +)
 +
 +if test "x$c_cv_have_timegm" != "xyes"
 +then
 +  AC_CACHE_CHECK([for timegm with _BSD_SOURCE],
 +    [c_cv_have_timegm_bsd],
 +    AC_LINK_IFELSE(
 +      [AC_LANG_PROGRAM(
 +[[[
 +#if STRPTIME_NEEDS_STANDARDS
 +# ifndef _ISOC99_SOURCE
 +#  define _ISOC99_SOURCE 1
 +# endif
 +# ifndef _POSIX_C_SOURCE
 +#  define _POSIX_C_SOURCE 200112L
 +# endif
 +# ifndef _XOPEN_SOURCE
 +#  define _XOPEN_SOURCE 500
 +# endif
 +#endif
 +#ifndef _BSD_SOURCE
 +# define _BSD_SOURCE 1
 +#endif
 +#include <time.h>
 +]]],
 +[[[
 + time_t t = timegm(&(struct tm){0});
 + if (t == ((time_t) -1)) {
 +   return 1;
 + }
 +]]]
 +      )],
 +      [c_cv_have_timegm_bsd="yes"
 +       c_cv_have_timegm="yes"],
 +      [c_cv_have_timegm_bsd="no"]
 +    )
 +  )
 +fi
 +
 +if test "x$c_cv_have_timegm" = "xyes"
 +then
 +  AC_DEFINE(HAVE_TIMEGM, 1, [Define if the timegm(3) function is available.])
 +  if test "x$c_cv_have_timegm_bsd" = "xyes"
 +  then
 +    AC_DEFINE(TIMEGM_NEEDS_BSD, 1, [Set to true if timegm is only exported in BSD mode.])
 +  fi
 +fi
 +
 +CFLAGS="$SAVE_CFLAGS"
 +# }}} Check for timegm
 +
  AC_MSG_CHECKING([for sysctl kern.cp_times])
  if test -x /sbin/sysctl; then
    /sbin/sysctl kern.cp_times >/dev/null 2>&1
@@@ -1370,8 -1314,8 +1371,8 @@@ if test "x$fp_layout_type" = "xunknown"
                    && (c[2] == 0xc0) && (c[3] == 0xc7)
                    && (c[4] == 0x43) && (c[5] == 0x2b)
                    && (c[6] == 0x1f) && (c[7] == 0x5b))
 -                return (0);
 -              return (1);
 +                return 0;
 +              return 1;
              ]]
            )
          ],
@@@ -1414,19 -1358,19 +1415,19 @@@ if test "x$fp_layout_type" = "xunknown"
                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)
                    && (c[6] == 0x1f) && (c[7] == 0x5b))
 -                return (0);
 -              return (1);
 +                return 0;
 +              return 1;
              ]]
            )
          ],
@@@ -1463,19 -1407,19 +1464,19 @@@ if test "x$fp_layout_type" = "xunknown"
                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)
                    && (c[6] == 0x1f) && (c[7] == 0x5b))
 -                return (0);
 -              return (1);
 +                return 0;
 +              return 1;
              ]]
            )
          ],
@@@ -2347,75 -2291,6 +2348,75 @@@ 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_CFLAGS], [Compiler flags for libdpdk])
 +AC_ARG_VAR([LIBDPDK_LDFLAGS], [Linker flags for libdpdk])
 +AC_ARG_VAR([LIBDPDK_LIBS], [Libraries to link 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
 +  PKG_CHECK_MODULES([DPDK], [libdpdk], [],
 +    [AC_MSG_NOTICE([no DPDK pkg-config, using defaults])])
 +  if test "x$LIBDPDK_CPPFLAGS" = "x"; then
 +    LIBDPDK_CPPFLAGS="-I/usr/include/dpdk"
 +  fi
 +  if test "x$LIBDPDK_CFLAGS" = "x"; then
 +    LIBDPDK_CFLAGS="$DPDK_CFLAGS"
 +    LIBDPDK_CPPFLAGS="$LIBDPDK_CPPFLAGS $DPDK_CFLAGS"
 +  fi
 +  if test "x$LIBDPDK_LIBS" = "x"; then
 +    if test "x$DPDK_LIBS" != "x"; then
 +      LIBDPDK_LIBS="$DPDK_LIBS"
 +    else
 +      LIBDPDK_LIBS="-ldpdk"
 +    fi
 +  fi
 +  SAVE_CPPFLAGS="$CPPFLAGS"
 +  CPPFLAGS="$LIBDPDK_CPPFLAGS $CPPFLAGS"
 +  SAVE_CFLAGS="$CFLAGS"
 +  CFLAGS="$LIBDPDK_CFLAGS $CFLAGS"
 +  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"
 +  CFLAGS="$SAVE_CFLAGS"
 +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.])],
@@@ -2828,6 -2703,56 +2829,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
@@@ -2851,9 -2776,6 +2852,9 @@@ AC_ARG_WITH([java]
    [with_java="yes"]
  )
  
 +AX_COMPARE_VERSION([$am__api_version],[lt],[1.12],
 +  [JAVA_TIMESTAMP_FILE="classdist_noinst.stamp"],
 +  [JAVA_TIMESTAMP_FILE="classnoinst.stamp"])
  if test "x$with_java" = "xyes"; then
    if test -d "$with_java_home"; then
      AC_MSG_CHECKING([for jni.h])
@@@ -2990,7 -2912,6 +2991,7 @@@ AC_SUBST([JAVA_CPPFLAGS]
  AC_SUBST([JAVA_CFLAGS])
  AC_SUBST([JAVA_LDFLAGS])
  AC_SUBST([JAVA_LIBS])
 +AC_SUBST([JAVA_TIMESTAMP_FILE])
  AM_CONDITIONAL([BUILD_WITH_JAVA], [test "x$with_java" = "xyes"])
  # }}}
  
@@@ -3390,62 -3311,52 +3391,62 @@@ AC_ARG_WITH([libmongoc]
      else if test "x$withval" = "xno"; then
        with_libmongoc="no"
      else
 -      with_libmongoc="yes"
 -      LIBMONGOC_CPPFLAGS="$LIBMONGOC_CPPFLAGS -I$withval/include"
 -      LIBMONGOC_LDFLAGS="$LIBMONGOC_LDFLAGS -L$withval/lib"
 +      with_libmongoc="no"
      fi; fi
    ],
    [with_libmongoc="yes"]
  )
  
 -SAVE_CPPFLAGS="$CPPFLAGS"
 -SAVE_LDFLAGS="$LDFLAGS"
 -
 -CPPFLAGS="$CPPFLAGS $LIBMONGOC_CPPFLAGS"
 -LDFLAGS="$LDFLAGS $LIBMONGOC_LDFLAGS"
 +if test "x$with_libmongoc" = "xyes"; then
 +  PKG_CHECK_MODULES([LIBMONGOC], [libmongoc-1.0],
 +    [with_libmongoc="yes"],
 +    [with_libmongoc="no (pkg-config could not find libmongoc)"]
 +  )
 +fi
  
  if test "x$with_libmongoc" = "xyes"; then
 -  if test "x$LIBMONGOC_CPPFLAGS" != "x"; then
 -    AC_MSG_NOTICE([libmongoc CPPFLAGS: $LIBMONGOC_CPPFLAGS])
 +  SAVE_CPPFLAGS="$CPPFLAGS"
 +
 +  CPPFLAGS="$CPPFLAGS $LIBMONGOC_CFLAGS"
 +
 +  if test "x$CPPFLAGS" != "x"; then
 +    AC_MSG_NOTICE([libmongoc CPPFLAGS: $LIBMONGOC_CFLAGS])
    fi
  
 -  AC_CHECK_HEADERS([mongo.h],
 +  AC_CHECK_HEADERS([mongoc.h],
      [with_libmongoc="yes"],
 -    [with_libmongoc="no ('mongo.h' not found)"],
 -    [[#define MONGO_HAVE_STDINT 1]]
 +    [with_libmongoc="no ('mongoc.h' not found)"]
    )
 +
 +  CPPFLAGS="$SAVE_CPPFLAGS"
  fi
  
  if test "x$with_libmongoc" = "xyes"; then
 +  SAVE_CPPFLAGS="$CPPFLAGS"
 +  SAVE_LDFLAGS="$LDFLAGS"
 +
 +  CPPFLAGS="$CPPFLAGS $LIBMONGOC_CFLAGS"
 +  LDFLAGS="$LDFLAGS $LIBMONGOC_LDFLAGS"
 +
    if test "x$LIBMONGOC_LDFLAGS" != "x"; then
      AC_MSG_NOTICE([libmongoc LDFLAGS: $LIBMONGOC_LDFLAGS])
    fi
  
 -  AC_CHECK_LIB([mongoc], [mongo_run_command],
 +  AC_CHECK_LIB([mongoc-1.0], [mongoc_init],
      [with_libmongoc="yes"],
 -    [with_libmongoc="no (symbol 'mongo_run_command' not found)"]
 +    [with_libmongoc="no (symbol 'mongoc_init' not found)"]
    )
 -fi
  
 -CPPFLAGS="$SAVE_CPPFLAGS"
 -LDFLAGS="$SAVE_LDFLAGS"
 +  CPPFLAGS="$SAVE_CPPFLAGS"
 +  LDFLAGS="$SAVE_LDFLAGS"
 +fi
  
  if test "x$with_libmongoc" = "xyes"; then
 -  BUILD_WITH_LIBMONGOC_CPPFLAGS="$LIBMONGOC_CPPFLAGS"
 +  BUILD_WITH_LIBMONGOC_CFLAGS="$LIBMONGOC_CFLAGS"
    BUILD_WITH_LIBMONGOC_LDFLAGS="$LIBMONGOC_LDFLAGS"
  fi
  
 -AC_SUBST([BUILD_WITH_LIBMONGOC_CPPFLAGS])
 +AC_SUBST([BUILD_WITH_LIBMONGOC_CFLAGS])
  AC_SUBST([BUILD_WITH_LIBMONGOC_LDFLAGS])
  # }}}
  
@@@ -3647,7 -3558,7 +3648,7 @@@ if test "x$with_libmnl" = "xyes"; the
          ]],
          [[
            int retval = TCA_STATS2;
 -          return (retval);
 +          return retval;
          ]]
        )
      ],
          ]],
          [[
            int retval = TCA_STATS;
 -          return (retval);
 +          return retval;
          ]]
        )
      ],
@@@ -3757,131 -3668,54 +3758,131 @@@ AC_SUBST([LIBNETAPP_LIBS]
  # }}}
  
  # --with-libnetsnmp {{{
 -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"
 -      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)"]
 -    )
 +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)"]
 +  )
  
 -      CPPFLAGS="$SAVE_CPPFLAGS"
 +  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"
  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)"]
 +  )
  
 -      LDFLAGS="$SAVE_LDFLAGS"
 +  LDFLAGS="$SAVE_LDFLAGS"
  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"
 +
 +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
 +
 +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
 +  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
 -AC_SUBST(BUILD_WITH_LIBNETSNMP_CPPFLAGS)
 -AC_SUBST(BUILD_WITH_LIBNETSNMP_LDFLAGS)
 -AC_SUBST(BUILD_WITH_LIBNETSNMP_LIBS)
 +
 +if test "x$with_libnetsnmpagent" = "xyes"; then
 +  BUILD_WITH_LIBNETSNMPAGENT_LIBS="-lnetsnmpagent $libnetsnmphelpers"
 +fi
 +
 +AC_SUBST([BUILD_WITH_LIBNETSNMPAGENT_CPPFLAGS])
 +AC_SUBST([BUILD_WITH_LIBNETSNMPAGENT_LDFLAGS])
 +AC_SUBST([BUILD_WITH_LIBNETSNMPAGENT_LIBS])
  # }}}
  
  # --with-liboping {{{
@@@ -4377,117 -4211,62 +4378,117 @@@ 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"]
 +)
  
 -      AC_CHECK_HEADERS(pqos.h, [with_libpqos="yes"], [with_libpqos="no (pqos.h not found)"])
 +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)"]
 +  )
  
 -      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"
 +
 +  AC_CHECK_LIB([pqos], [pqos_init],
 +    [with_libpqos="yes"],
 +    [with_libpqos="no (Can't find libpqos)"]
 +  )
  
 -      CPPFLAGS="$SAVE_CPPFLAGS"
 -      LDFLAGS="$SAVE_LDFLAGS"
 +  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-libjevents {{{
 +with_libjevents_cppflags=""
 +with_libjevents_ldflags=""
 +AC_ARG_WITH([libjevents],
 +  [AS_HELP_STRING([--with-libjevents@<:@=PREFIX@:>@], [Path to libjevents.])],
 +  [
 +    if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
 +      with_libjevents_cppflags="-I$withval/include"
 +      with_libjevents_ldflags="-L$withval/lib"
 +      with_libjevents="yes"
 +    else
 +      with_libjevents="$withval"
 +    fi
 +  ],
 +  [with_libjevents="yes"]
 +)
 +
 +if test "x$with_libjevents" = "xyes"; then
 +  SAVE_CPPFLAGS="$CPPFLAGS"
 +  CPPFLAGS="$CPPFLAGS $with_libjevents_cppflags"
 +
 +  AC_CHECK_HEADERS([jevents.h], [with_libjevents="yes"], [with_libjevents="no (jevents.h not found)"])
 +
 +  CPPFLAGS="$SAVE_CPPFLAGS"
 +fi
 +if test "x$with_libjevents" = "xyes"; then
 +  SAVE_LDFLAGS="$LDFLAGS"
 +  LDFLAGS="$LDFLAGS $with_libjevents_ldflags"
 +
 +  AC_CHECK_LIB([jevents], [json_events], [with_libjevents="yes"], [with_libjevents="no (Can't find libjevents)"])
 +
 +  LDFLAGS="$SAVE_LDFLAGS"
 +fi
 +if test "x$with_libjevents" = "xyes"; then
 +  BUILD_WITH_LIBJEVENTS_CPPFLAGS="$with_libjevents_cppflags"
 +  BUILD_WITH_LIBJEVENTS_LDFLAGS="$with_libjevents_ldflags"
 +  BUILD_WITH_LIBJEVENTS_LIBS="-ljevents"
 +fi
 +AC_SUBST([BUILD_WITH_LIBJEVENTS_CPPFLAGS])
 +AC_SUBST([BUILD_WITH_LIBJEVENTS_LDFLAGS])
 +AC_SUBST([BUILD_WITH_LIBJEVENTS_LIBS])
  # }}}
  
  # --with-libprotobuf {{{
@@@ -5433,11 -5212,8 +5434,11 @@@ if test "x$with_libupsclient" = "xyes"
    )
  
    AC_CHECK_LIB([upsclient], [upscli_init],
 -    [AC_DEFINE([WITH_UPSCLIENT_27], [1], [At least version 2-7])],
 -    []
 +    [AC_DEFINE([HAVE_UPSCLI_INIT], [1], [Define when upscli_init() (since version 2-7) is available.])]
 +  )
 +
 +  AC_CHECK_LIB([upsclient], [upscli_tryconnect],
 +    [AC_DEFINE([HAVE_UPSCLI_TRYCONNECT], [1], [Define when upscli_tryconnect() (since version 2.6.2) is available.])]
    )
  
    LDFLAGS="$SAVE_LDFLAGS"
@@@ -6144,7 -5920,6 +6145,7 @@@ plugin_fscache="no
  plugin_gps="no"
  plugin_grpc="no"
  plugin_hugepages="no"
 +plugin_intel_pmu="no"
  plugin_intel_rdt="no"
  plugin_interface="no"
  plugin_ipc="no"
@@@ -6220,14 -5995,14 +6221,14 @@@ if test "x$ac_system" = "xLinux"; the
    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
@@@ -6487,7 -6262,8 +6488,7 @@@ if test "x$with_libxenctrl" = "xyes"; t
    plugin_xencpu="yes"
  fi
  
 -if test "x$with_libdpdk" = "xyes"
 -then
 +if test "x$with_libdpdk" = "xyes"; then
    plugin_dpdkevents="$dpdk_keepalive"
    plugin_dpdkstat="yes"
  fi
@@@ -6552,7 -6328,6 +6553,7 @@@ AC_PLUGIN([gps],                 [$plug
  AC_PLUGIN([grpc],                [$plugin_grpc],            [gRPC plugin])
  AC_PLUGIN([hddtemp],             [yes],                     [Query hddtempd])
  AC_PLUGIN([hugepages],           [$plugin_hugepages],       [Hugepages statistics])
 +AC_PLUGIN([intel_pmu],           [$with_libjevents],        [Intel performance monitor plugin])
  AC_PLUGIN([intel_rdt],           [$with_libpqos],           [Intel RDT monitor plugin])
  AC_PLUGIN([interface],           [$plugin_interface],       [Interface traffic statistics])
  AC_PLUGIN([ipc],                 [$plugin_ipc],             [IPC statistics])
@@@ -6621,7 -6396,6 +6622,7 @@@ AC_PLUGIN([serial],              [$plug
  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],          [$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])
@@@ -6702,7 -6476,8 +6703,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"
@@@ -6747,11 -6522,21 +6748,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
    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=""
@@@ -6842,7 -6630,6 +6843,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])
@@@ -6871,7 -6658,6 +6872,7 @@@ AC_MSG_RESULT([    libhiredis  . . . . 
  AC_MSG_RESULT([    libi2c-dev  . . . . . $with_libi2c])
  AC_MSG_RESULT([    libiokit  . . . . . . $with_libiokit])
  AC_MSG_RESULT([    libiptc . . . . . . . $with_libiptc])
 +AC_MSG_RESULT([    libjevents  . . . . . $with_libjevents])
  AC_MSG_RESULT([    libjvm  . . . . . . . $with_java])
  AC_MSG_RESULT([    libkstat  . . . . . . $with_kstat])
  AC_MSG_RESULT([    libkvm  . . . . . . . $with_libkvm])
@@@ -6887,7 -6673,6 +6888,7 @@@ AC_MSG_RESULT([    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])
@@@ -6970,7 -6755,6 +6971,7 @@@ AC_MSG_RESULT([    gps . . . . . . . . 
  AC_MSG_RESULT([    grpc  . . . . . . . . $enable_grpc])
  AC_MSG_RESULT([    hddtemp . . . . . . . $enable_hddtemp])
  AC_MSG_RESULT([    hugepages . . . . . . $enable_hugepages])
 +AC_MSG_RESULT([    intel_pmu . . . . . . $enable_intel_pmu])
  AC_MSG_RESULT([    intel_rdt . . . . . . $enable_intel_rdt])
  AC_MSG_RESULT([    interface . . . . . . $enable_interface])
  AC_MSG_RESULT([    ipc . . . . . . . . . $enable_ipc])
@@@ -7038,7 -6822,6 +7039,7 @@@ AC_MSG_RESULT([    serial  . . . . . . 
  AC_MSG_RESULT([    sigrok  . . . . . . . $enable_sigrok])
  AC_MSG_RESULT([    smart . . . . . . . . $enable_smart])
  AC_MSG_RESULT([    snmp  . . . . . . . . $enable_snmp])
 +AC_MSG_RESULT([    snmp_agent  . . . . . $enable_snmp_agent])
  AC_MSG_RESULT([    statsd  . . . . . . . $enable_statsd])
  AC_MSG_RESULT([    swap  . . . . . . . . $enable_swap])
  AC_MSG_RESULT([    syslog  . . . . . . . $enable_syslog])
diff --combined src/collectd-nagios.c
@@@ -71,7 -71,7 +71,7 @@@
  #endif
  #endif /* NAN_ZERO_ZERO */
  
- #include "libcollectdclient/collectd/client.h"
+ #include "collectd/client.h"
  
  #define RET_OKAY 0
  #define RET_WARNING 1
@@@ -118,7 -118,7 +118,7 @@@ cn_strdup(const char *str) /* {{{ *
    ret = (char *)malloc(strsize);
    if (ret != NULL)
      memcpy(ret, str, strsize);
 -  return (ret);
 +  return ret;
  } /* }}} char *cn_strdup */
  
  static int filter_ds(size_t *values_num, double **values,
    char **new_names;
  
    if (match_ds_g == NULL)
 -    return (RET_OKAY);
 +    return RET_OKAY;
  
    new_values = (gauge_t *)calloc(match_ds_num_g, sizeof(*new_values));
    if (new_values == NULL) {
      fprintf(stderr, "calloc failed: %s\n", strerror(errno));
 -    return (RET_UNKNOWN);
 +    return RET_UNKNOWN;
    }
  
    new_names = (char **)calloc(match_ds_num_g, sizeof(*new_names));
    if (new_names == NULL) {
      fprintf(stderr, "calloc failed: %s\n", strerror(errno));
      free(new_values);
 -    return (RET_UNKNOWN);
 +    return RET_UNKNOWN;
    }
  
    for (size_t i = 0; i < match_ds_num_g; i++) {
        for (j = 0; j < i; j++)
          free(new_names[j]);
        free(new_names);
 -      return (RET_UNKNOWN);
 +      return RET_UNKNOWN;
      }
  
      for (j = 0; j < *values_num; j++)
        for (j = 0; j <= i; j++)
          free(new_names[j]);
        free(new_names);
 -      return (RET_CRITICAL);
 +      return RET_CRITICAL;
      }
  
      new_values[i] = (*values)[j];
    *values = new_values;
    *values_names = new_names;
    *values_num = match_ds_num_g;
 -  return (RET_OKAY);
 +  return RET_OKAY;
  } /* int filter_ds */
  
  static void parse_range(char *string, range_t *range) {
@@@ -227,7 -227,7 +227,7 @@@ static int match_range(range_t *range, 
    if (!isnan(range->max) && (range->max < value))
      ret = 1;
  
 -  return (((ret - range->invert) == 0) ? 0 : 1);
 +  return ((ret - range->invert) == 0) ? 0 : 1;
  } /* int match_range */
  
  __attribute__((noreturn)) static void usage(const char *name) {
@@@ -279,7 -279,7 +279,7 @@@ static int do_listval(lcc_connection_t 
      printf("UNKNOWN: %s\n", lcc_strerror(connection));
      if (ret_ident != NULL)
        free(ret_ident);
 -    return (RET_UNKNOWN);
 +    return RET_UNKNOWN;
    }
  
    status = lcc_sort_identifiers(connection, ret_ident, ret_ident_num);
      printf("UNKNOWN: %s\n", lcc_strerror(connection));
      if (ret_ident != NULL)
        free(ret_ident);
 -    return (RET_UNKNOWN);
 +    return RET_UNKNOWN;
    }
  
    for (size_t i = 0; i < ret_ident_num; ++i) {
  
    free(ret_ident);
    free(hostname);
 -  return (RET_OKAY);
 +  return RET_OKAY;
  } /* int do_listval */
  
  static int do_check_con_none(size_t values_num, double *values,
  
    if ((num_critical == 0) && (num_warning == 0) && (num_okay == 0)) {
      printf("WARNING: No defined values found\n");
 -    return (RET_WARNING);
 +    return RET_WARNING;
    } else if ((num_critical == 0) && (num_warning == 0)) {
      status_str = "OKAY";
      status_code = RET_OKAY;
    }
    printf("\n");
  
 -  return (status_code);
 +  return status_code;
  } /* int do_check_con_none */
  
  static int do_check_con_average(size_t values_num, double *values,
          continue;
  
        printf("CRITICAL: Data source \"%s\" is NaN\n", values_names[i]);
 -      return (RET_CRITICAL);
 +      return RET_CRITICAL;
      }
  
      total += values[i];
  
    if (total_num == 0) {
      printf("WARNING: No defined values found\n");
 -    return (RET_WARNING);
 +    return RET_WARNING;
    }
  
    average = total / total_num;
      printf(" %s=%f;;;;", values_names[i], values[i]);
    printf("\n");
  
 -  return (status_code);
 +  return status_code;
  } /* int do_check_con_average */
  
  static int do_check_con_sum(size_t values_num, double *values,
          continue;
  
        printf("CRITICAL: Data source \"%s\" is NaN\n", values_names[i]);
 -      return (RET_CRITICAL);
 +      return RET_CRITICAL;
      }
  
      total += values[i];
  
    if (total_num == 0) {
      printf("WARNING: No defined values found\n");
 -    return (RET_WARNING);
 +    return RET_WARNING;
    }
  
    if (match_range(&range_critical_g, total) != 0) {
      printf(" %s=%f;;;;", values_names[i], values[i]);
    printf("\n");
  
 -  return (status_code);
 +  return status_code;
  } /* int do_check_con_sum */
  
  static int do_check_con_percentage(size_t values_num, double *values,
  
    if ((values_num < 1) || (isnan(values[0]))) {
      printf("WARNING: The first value is not defined\n");
 -    return (RET_WARNING);
 +    return RET_WARNING;
    }
  
    for (size_t i = 0; i < values_num; i++) {
          continue;
  
        printf("CRITICAL: Data source \"%s\" is NaN\n", values_names[i]);
 -      return (RET_CRITICAL);
 +      return RET_CRITICAL;
      }
  
      sum += values[i];
  
    if (sum == 0.0) {
      printf("WARNING: Values sum up to zero\n");
 -    return (RET_WARNING);
 +    return RET_WARNING;
    }
  
    percentage = 100.0 * values[0] / sum;
    printf("%s: %lf percent |", status_str, percentage);
    for (size_t i = 0; i < values_num; i++)
      printf(" %s=%lf;;;;", values_names[i], values[i]);
 -  return (status_code);
 +  return status_code;
  } /* int do_check_con_percentage */
  
  static int do_check(lcc_connection_t *connection) {
      printf("ERROR: Creating an identifier failed: %s.\n",
             lcc_strerror(connection));
      LCC_DESTROY(connection);
 -    return (RET_CRITICAL);
 +    return RET_CRITICAL;
    }
  
    status = lcc_getval(connection, &ident, &values_num, &values, &values_names);
      printf("ERROR: Retrieving values from the daemon failed: %s.\n",
             lcc_strerror(connection));
      LCC_DESTROY(connection);
 -    return (RET_CRITICAL);
 +    return RET_CRITICAL;
    }
  
    LCC_DESTROY(connection);
  
    status = filter_ds(&values_num, &values, &values_names);
    if (status != RET_OKAY)
 -    return (status);
 +    return status;
  
    status = RET_UNKNOWN;
    if (consolitation_g == CON_NONE)
        free(values_names[i]);
    free(values_names);
  
 -  return (status);
 +  return status;
  } /* int do_check */
  
  int main(int argc, char **argv) {
        tmp = realloc(match_ds_g, (match_ds_num_g + 1) * sizeof(char *));
        if (tmp == NULL) {
          fprintf(stderr, "realloc failed: %s\n", strerror(errno));
 -        return (RET_UNKNOWN);
 +        return RET_UNKNOWN;
        }
        match_ds_g = tmp;
        match_ds_g[match_ds_num_g] = cn_strdup(optarg);
        if (match_ds_g[match_ds_num_g] == NULL) {
          fprintf(stderr, "cn_strdup failed: %s\n", strerror(errno));
 -        return (RET_UNKNOWN);
 +        return RET_UNKNOWN;
        }
        match_ds_num_g++;
        break;
    status = lcc_connect(address, &connection);
    if (status != 0) {
      printf("ERROR: Connecting to daemon at %s failed.\n", socket_file_g);
 -    return (RET_CRITICAL);
 +    return RET_CRITICAL;
    }
  
    if (0 == strcasecmp(value_string_g, "LIST"))
 -    return (do_listval(connection));
 +    return do_listval(connection);
  
 -  return (do_check(connection));
 +  return do_check(connection);
  } /* int main */
diff --combined src/collectd-tg.c
@@@ -44,8 -44,8 +44,8 @@@
  
  #include "utils_heap.h"
  
- #include "libcollectdclient/collectd/client.h"
- #include "libcollectdclient/collectd/network.h"
+ #include "collectd/client.h"
+ #include "collectd/network.h"
  
  #define DEF_NUM_HOSTS 1000
  #define DEF_NUM_PLUGINS 20
@@@ -107,7 -107,7 +107,7 @@@ static double dtime(void) /* {{{ *
    if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0)
      perror("clock_gettime");
  
 -  return ((double)ts.tv_sec) + (((double)ts.tv_nsec) / 1e9);
 +  return (double)ts.tv_sec + (double)ts.tv_nsec / 1e9;
  } /* }}} double dtime */
  #else
  /* Work around for Mac OS X which doesn't have clock_gettime(2). *sigh* */
@@@ -118,7 -118,7 +118,7 @@@ static double dtime(void) /* {{{ *
    if (gettimeofday(&tv, /* timezone = */ NULL) != 0)
      perror("gettimeofday");
  
 -  return ((double)tv.tv_sec) + (((double)tv.tv_usec) / 1e6);
 +  return (double)tv.tv_sec + ((double)tv.tv_usec) / 1e6;
  } /* }}} double dtime */
  #endif
  
@@@ -128,11 -128,11 +128,11 @@@ static int compare_time(const void *v0
    const lcc_value_list_t *vl1 = v1;
  
    if (vl0->time < vl1->time)
 -    return (-1);
 +    return -1;
    else if (vl0->time > vl1->time)
 -    return (1);
 +    return 1;
    else
 -    return (0);
 +    return 0;
  } /* }}} int compare_time */
  
  static int get_boundet_random(int min, int max) /* {{{ */
    int range;
  
    if (min >= max)
 -    return (-1);
 +    return -1;
    if (min == (max - 1))
 -    return (min);
 +    return min;
  
    range = max - min;
  
 -  return (min + ((int)(((double)range) * ((double)random()) /
 -                       (((double)RAND_MAX) + 1.0))));
 +  return min + ((int)(((double)range) * ((double)random()) / (((double)RAND_MAX) + 1.0)));
  } /* }}} int get_boundet_random */
  
  static lcc_value_list_t *create_value_list(void) /* {{{ */
    vl = calloc(1, sizeof(*vl));
    if (vl == NULL) {
      fprintf(stderr, "calloc failed.\n");
 -    return (NULL);
 +    return NULL;
    }
  
    vl->values = calloc(/* nmemb = */ 1, sizeof(*vl->values));
    if (vl->values == NULL) {
      fprintf(stderr, "calloc failed.\n");
      free(vl);
 -    return (NULL);
 +    return NULL;
    }
  
    vl->values_types = calloc(/* nmemb = */ 1, sizeof(*vl->values_types));
      fprintf(stderr, "calloc failed.\n");
      free(vl->values);
      free(vl);
 -    return (NULL);
 +    return NULL;
    }
  
    vl->values_len = 1;
    snprintf(vl->identifier.type_instance, sizeof(vl->identifier.type_instance),
             "ti%li", random());
  
 -  return (vl);
 +  return vl;
  } /* }}} int create_value_list */
  
  static void destroy_value_list(lcc_value_list_t *vl) /* {{{ */
@@@ -227,7 -228,7 +227,7 @@@ static int send_value(lcc_value_list_t 
  
    vl->time += vl->interval;
  
 -  return (0);
 +  return 0;
  } /* }}} int send_value */
  
  static int get_integer_opt(const char *str, int *ret_value) /* {{{ */
    }
  
    *ret_value = tmp;
 -  return (0);
 +  return 0;
  } /* }}} int get_integer_opt */
  
  static int get_double_opt(const char *str, double *ret_value) /* {{{ */
    }
  
    *ret_value = tmp;
 -  return (0);
 +  return 0;
  } /* }}} int get_double_opt */
  
  static int read_options(int argc, char **argv) /* {{{ */
      } /* switch (opt) */
    }   /* while (getopt) */
  
 -  return (0);
 +  return 0;
  } /* }}} int read_options */
  
  int main(int argc, char **argv) /* {{{ */
diff --combined src/collectdctl.c
@@@ -65,7 -65,7 +65,7 @@@
  #endif
  #endif /* NAN_ZERO_ZERO */
  
- #include "libcollectdclient/collectd/client.h"
+ #include "collectd/client.h"
  
  #ifndef PREFIX
  #define PREFIX "/opt/" PACKAGE_NAME
@@@ -138,12 -138,12 +138,12 @@@ static int array_grow(void **array, siz
    tmp = realloc(*array, (*array_len + 1) * elem_size);
    if (tmp == NULL) {
      fprintf(stderr, "ERROR: Failed to allocate memory.\n");
 -    return (-1);
 +    return -1;
    }
  
    *array = tmp;
    ++(*array_len);
 -  return (0);
 +  return 0;
  } /* array_grow */
  
  static int parse_identifier(lcc_connection_t *c, const char *value,
      if (gethostname(hostname, sizeof(hostname)) != 0) {
        fprintf(stderr, "ERROR: Failed to get local hostname: %s",
                strerror(errno));
 -      return (-1);
 +      return -1;
      }
      hostname[sizeof(hostname) - 1] = '\0';
  
    if (status != 0) {
      fprintf(stderr, "ERROR: Failed to parse identifier ``%s'': %s.\n",
              ident_str, lcc_strerror(c));
 -    return (-1);
 +    return -1;
    }
 -  return (0);
 +  return 0;
  } /* parse_identifier */
  
  static int getval(lcc_connection_t *c, int argc, char **argv) {
  
    if (argc != 2) {
      fprintf(stderr, "ERROR: getval: Missing identifier.\n");
 -    return (-1);
 +    return -1;
    }
  
    status = parse_identifier(c, argv[1], &ident);
    if (status != 0)
 -    return (status);
 +    return status;
  
  #define BAIL_OUT(s)                                                            \
    do {                                                                         \
        free(ret_values_names);                                                  \
      }                                                                          \
      ret_values_num = 0;                                                        \
 -    return (s);                                                                \
 +    return s;                                                                  \
    } while (0)
  
    status =
@@@ -249,7 -249,7 +249,7 @@@ static int flush(lcc_connection_t *c, i
      if (plugins != NULL)                                                       \
        free(plugins);                                                           \
      plugins_num = 0;                                                           \
 -    return (s);                                                                \
 +    return s;                                                                  \
    } while (0)
  
    for (int i = 1; i < argc; ++i) {
@@@ -347,7 -347,7 +347,7 @@@ static int listval(lcc_connection_t *c
  
    if (argc != 1) {
      fprintf(stderr, "ERROR: listval: Does not accept any arguments.\n");
 -    return (-1);
 +    return -1;
    }
  
  #define BAIL_OUT(s)                                                            \
      if (ret_ident != NULL)                                                     \
        free(ret_ident);                                                         \
      ret_ident_num = 0;                                                         \
 -    return (s);                                                                \
 +    return s;                                                                  \
    } while (0)
  
    status = lcc_listval(c, &ret_ident, &ret_ident_num);
@@@ -396,7 -396,7 +396,7 @@@ static int putval(lcc_connection_t *c, 
    if (argc < 3) {
      fprintf(stderr, "ERROR: putval: Missing identifier "
                      "and/or value list.\n");
 -    return (-1);
 +    return -1;
    }
  
    vl.values = values;
  
    status = parse_identifier(c, argv[1], &vl.identifier);
    if (status != 0)
 -    return (status);
 +    return status;
  
    for (int i = 2; i < argc; ++i) {
      char *tmp;
          if (endptr == value) {
            fprintf(stderr, "ERROR: Failed to parse interval as number: %s.\n",
                    value);
 -          return (-1);
 +          return -1;
          } else if ((endptr != NULL) && (*endptr != '\0')) {
            fprintf(stderr, "WARNING: Ignoring trailing garbage after "
                            "interval: %s.\n",
          }
        } else {
          fprintf(stderr, "ERROR: putval: Unknown option `%s'.\n", key);
 -        return (-1);
 +        return -1;
        }
      } else { /* value list */
        char *value;
  
        if (tmp == NULL) {
          fprintf(stderr, "ERROR: putval: Invalid value list: %s.\n", argv[i]);
 -        return (-1);
 +        return -1;
        }
  
        *tmp = '\0';
          if (endptr == argv[i]) {
            fprintf(stderr, "ERROR: Failed to parse time as number: %s.\n",
                    argv[i]);
 -          return (-1);
 +          return -1;
          } else if ((endptr != NULL) && (*endptr != '\0')) {
            fprintf(stderr, "ERROR: Garbage after time: %s.\n", endptr);
 -          return (-1);
 +          return -1;
          }
        }
  
          if (endptr == value) {
            fprintf(stderr, "ERROR: Failed to parse value as number: %s.\n",
                    argv[i]);
 -          return (-1);
 +          return -1;
          } else if ((endptr != NULL) && (*endptr != '\0')) {
            fprintf(stderr, "ERROR: Garbage after value: %s.\n", endptr);
 -          return (-1);
 +          return -1;
          }
  
          value = tmp;
        status = lcc_putval(c, &vl);
        if (status != 0) {
          fprintf(stderr, "ERROR: %s\n", lcc_strerror(c));
 -        return (-1);
 +        return -1;
        }
      }
    }
  
    if (values_len == 0) {
      fprintf(stderr, "ERROR: putval: Missing value list(s).\n");
 -    return (-1);
 +    return -1;
    }
 -  return (0);
 +  return 0;
  } /* putval */
  
  int main(int argc, char **argv) {
    if (status != 0) {
      fprintf(stderr, "ERROR: Failed to connect to daemon at %s: %s.\n", address,
              strerror(errno));
 -    return (1);
 +    return 1;
    }
  
    if (strcasecmp(argv[optind], "getval") == 0)
      status = putval(c, argc - optind, argv + optind);
    else {
      fprintf(stderr, "%s: invalid command: %s\n", argv[0], argv[optind]);
 -    return (1);
 +    return 1;
    }
  
    LCC_DESTROY(c);
  
    if (status != 0)
 -    return (status);
 -  return (0);
 +    return status;
 +  return 0;
  } /* main */
@@@ -24,9 -24,7 +24,7 @@@
   *   Florian octo Forster <octo at collectd.org>
   **/
  
- #if HAVE_CONFIG_H
  #include "config.h"
- #endif
  
  #if !defined(__GNUC__) || !__GNUC__
  #define __attribute__(x) /**/
@@@ -92,6 -90,7 +90,6 @@@
  #define LCC_SET_ERRSTR(c, ...)                                                 \
    do {                                                                         \
      snprintf((c)->errbuf, sizeof((c)->errbuf), __VA_ARGS__);                   \
 -    (c)->errbuf[sizeof((c)->errbuf) - 1] = 0;                                  \
    } while (0)
  
  /*
@@@ -99,7 -98,7 +97,7 @@@
   */
  struct lcc_connection_s {
    FILE *fh;
 -  char errbuf[1024];
 +  char errbuf[2048];
  };
  
  struct lcc_response_s {
@@@ -164,18 -163,18 +162,18 @@@ static char *sstrerror(int errnum, cha
  
    buf[buflen - 1] = 0;
  
 -  return (buf);
 +  return buf;
  } /* char *sstrerror */
  
  static int lcc_set_errno(lcc_connection_t *c, int err) /* {{{ */
  {
    if (c == NULL)
 -    return (-1);
 +    return -1;
  
    sstrerror(err, c->errbuf, sizeof(c->errbuf));
    c->errbuf[sizeof(c->errbuf) - 1] = 0;
  
 -  return (0);
 +  return 0;
  } /* }}} int lcc_set_errno */
  
  static char *lcc_strescape(char *dest, const char *src,
    size_t src_pos;
  
    if ((dest == NULL) || (src == NULL))
 -    return (NULL);
 +    return NULL;
  
    dest_pos = 0;
    src_pos = 0;
    dest_pos++;
    src_pos++;
  
 -  return (dest);
 +  return dest;
  } /* }}} char *lcc_strescape */
  
  /* lcc_chomp: Removes all control-characters at the end of a string. */
@@@ -259,11 -258,11 +257,11 @@@ static int lcc_send(lcc_connection_t *c
    status = fprintf(c->fh, "%s\r\n", command);
    if (status < 0) {
      lcc_set_errno(c, errno);
 -    return (-1);
 +    return -1;
    }
    fflush(c->fh);
  
 -  return (0);
 +  return 0;
  } /* }}} int lcc_send */
  
  static int lcc_receive(lcc_connection_t *c, /* {{{ */
    ptr = fgets(buffer, sizeof(buffer), c->fh);
    if (ptr == NULL) {
      lcc_set_errno(c, errno);
 -    return (-1);
 +    return -1;
    }
    lcc_chomp(buffer);
    lcc_tracef("receive: <-- %s\n", buffer);
    res.status = (int)strtol(buffer, &ptr, 0);
    if ((errno != 0) || (ptr == &buffer[0])) {
      lcc_set_errno(c, errno);
 -    return (-1);
 +    return -1;
    }
  
    /* Skip white spaces after the status number */
    /* Error or no lines follow: We're done. */
    if (res.status <= 0) {
      memcpy(ret_res, &res, sizeof(res));
 -    return (0);
 +    return 0;
    }
  
    /* Allocate space for the char-pointers */
    res.lines = malloc(res.lines_num * sizeof(*res.lines));
    if (res.lines == NULL) {
      lcc_set_errno(c, ENOMEM);
 -    return (-1);
 +    return -1;
    }
  
    /* Now receive all the lines */
        free(res.lines[i]);
      }
      free(res.lines);
 -    return (-1);
 +    return -1;
    }
  
    memcpy(ret_res, &res, sizeof(res));
 -  return (0);
 +  return 0;
  } /* }}} int lcc_receive */
  
  static int lcc_sendreceive(lcc_connection_t *c, /* {{{ */
  
    if (c->fh == NULL) {
      lcc_set_errno(c, EBADF);
 -    return (-1);
 +    return -1;
    }
  
    status = lcc_send(c, command);
    if (status != 0)
 -    return (status);
 +    return status;
  
    status = lcc_receive(c, &res);
    if (status == 0)
      memcpy(ret_res, &res, sizeof(*ret_res));
  
 -  return (status);
 +  return status;
  } /* }}} int lcc_sendreceive */
  
  static int lcc_open_unixsocket(lcc_connection_t *c, const char *path) /* {{{ */
    fd = socket(AF_UNIX, SOCK_STREAM, /* protocol = */ 0);
    if (fd < 0) {
      lcc_set_errno(c, errno);
 -    return (-1);
 +    return -1;
    }
  
    sa.sun_family = AF_UNIX;
    if (status != 0) {
      lcc_set_errno(c, errno);
      close(fd);
 -    return (-1);
 +    return -1;
    }
  
    c->fh = fdopen(fd, "r+");
    if (c->fh == NULL) {
      lcc_set_errno(c, errno);
      close(fd);
 -    return (-1);
 +    return -1;
    }
  
 -  return (0);
 +  return 0;
  } /* }}} int lcc_open_unixsocket */
  
  static int lcc_open_netsocket(lcc_connection_t *c, /* {{{ */
      port = strchr(addr, ']');
      if (port == NULL) {
        LCC_SET_ERRSTR(c, "malformed address: %s", addr_orig);
 -      return (-1);
 +      return -1;
      }
      *port = 0;
      port++;
        port = NULL;
      else {
        LCC_SET_ERRSTR(c, "garbage after address: %s", port);
 -      return (-1);
 +      return -1;
      }
    }                                   /* if (*addr = ']') */
    else if (strchr(addr, '.') != NULL) /* Hostname or IPv4 */
                         &ai_res);
    if (status != 0) {
      LCC_SET_ERRSTR(c, "getaddrinfo: %s", gai_strerror(status));
 -    return (-1);
 +    return -1;
    }
  
    for (struct addrinfo *ai_ptr = ai_res; ai_ptr != NULL;
    if (status != 0) {
      lcc_set_errno(c, status);
      freeaddrinfo(ai_res);
 -    return (-1);
 +    return -1;
    }
  
    freeaddrinfo(ai_res);
 -  return (0);
 +  return 0;
  } /* }}} int lcc_open_netsocket */
  
  static int lcc_open_socket(lcc_connection_t *c, const char *addr) /* {{{ */
    int status = 0;
  
    if (addr == NULL)
 -    return (-1);
 +    return -1;
  
    assert(c != NULL);
    assert(c->fh == NULL);
    else
      status = lcc_open_netsocket(c, addr);
  
 -  return (status);
 +  return status;
  } /* }}} int lcc_open_socket */
  
  /*
   */
  unsigned int lcc_version(void) /* {{{ */
  {
 -  return (LCC_VERSION);
 +  return LCC_VERSION;
  } /* }}} unsigned int lcc_version */
  
  const char *lcc_version_string(void) /* {{{ */
  {
 -  return (LCC_VERSION_STRING);
 +  return LCC_VERSION_STRING;
  } /* }}} const char *lcc_version_string */
  
  const char *lcc_version_extra(void) /* {{{ */
  {
 -  return (LCC_VERSION_EXTRA);
 +  return LCC_VERSION_EXTRA;
  } /* }}} const char *lcc_version_extra */
  
  int lcc_connect(const char *address, lcc_connection_t **ret_con) /* {{{ */
    int status;
  
    if (address == NULL)
 -    return (-1);
 +    return -1;
  
    if (ret_con == NULL)
 -    return (-1);
 +    return -1;
  
    c = calloc(1, sizeof(*c));
    if (c == NULL)
 -    return (-1);
 +    return -1;
  
    status = lcc_open_socket(c, address);
    if (status != 0) {
      lcc_disconnect(c);
 -    return (status);
 +    return status;
    }
  
    *ret_con = c;
 -  return (0);
 +  return 0;
  } /* }}} int lcc_connect */
  
  int lcc_disconnect(lcc_connection_t *c) /* {{{ */
  {
    if (c == NULL)
 -    return (-1);
 +    return -1;
  
    if (c->fh != NULL) {
      fclose(c->fh);
    }
  
    free(c);
 -  return (0);
 +  return 0;
  } /* }}} int lcc_disconnect */
  
  int lcc_getval(lcc_connection_t *c, lcc_identifier_t *ident, /* {{{ */
    int status;
  
    if (c == NULL)
 -    return (-1);
 +    return -1;
  
    if (ident == NULL) {
      lcc_set_errno(c, EINVAL);
 -    return (-1);
 +    return -1;
    }
  
    /* Build a commend with an escaped version of the identifier string. */
    status = lcc_identifier_to_string(c, ident_str, sizeof(ident_str), ident);
    if (status != 0)
 -    return (status);
 +    return status;
  
    snprintf(command, sizeof(command), "GETVAL %s",
             lcc_strescape(ident_esc, ident_str, sizeof(ident_esc)));
    /* Send talk to the daemon.. */
    status = lcc_sendreceive(c, command, &res);
    if (status != 0)
 -    return (status);
 +    return status;
  
    if (res.status != 0) {
      LCC_SET_ERRSTR(c, "Server error: %s", res.message);
      lcc_response_free(&res);
 -    return (-1);
 +    return -1;
    }
  
    values_num = res.lines_num;
      }                                                                          \
      free(values_names);                                                        \
      lcc_response_free(&res);                                                   \
 -    return (-1);                                                               \
 +    return -1;                                                                 \
    } while (0)
  
    /* If neither the values nor the names are requested, return here.. */
      if (ret_values_num != NULL)
        *ret_values_num = values_num;
      lcc_response_free(&res);
 -    return (0);
 +    return 0;
    }
  
    /* Allocate space for the values */
  
    lcc_response_free(&res);
  
 -  return (0);
 +  return 0;
  } /* }}} int lcc_getval */
  
  int lcc_putval(lcc_connection_t *c, const lcc_value_list_t *vl) /* {{{ */
    if ((c == NULL) || (vl == NULL) || (vl->values_len < 1) ||
        (vl->values == NULL) || (vl->values_types == NULL)) {
      lcc_set_errno(c, EINVAL);
 -    return (-1);
 +    return -1;
    }
  
    status = lcc_identifier_to_string(c, ident_str, sizeof(ident_str),
                                      &vl->identifier);
    if (status != 0)
 -    return (status);
 +    return status;
  
    SSTRCATF(command, "PUTVAL %s",
             lcc_strescape(ident_esc, ident_str, sizeof(ident_esc)));
  
    status = lcc_sendreceive(c, command, &res);
    if (status != 0)
 -    return (status);
 +    return status;
  
    if (res.status != 0) {
      LCC_SET_ERRSTR(c, "Server error: %s", res.message);
      lcc_response_free(&res);
 -    return (-1);
 +    return -1;
    }
  
    lcc_response_free(&res);
 -  return (0);
 +  return 0;
  } /* }}} int lcc_putval */
  
  int lcc_flush(lcc_connection_t *c, const char *plugin, /* {{{ */
  
    if (c == NULL) {
      lcc_set_errno(c, EINVAL);
 -    return (-1);
 +    return -1;
    }
  
    SSTRCPY(command, "FLUSH");
  
      status = lcc_identifier_to_string(c, ident_str, sizeof(ident_str), ident);
      if (status != 0)
 -      return (status);
 +      return status;
  
      SSTRCATF(command, " identifier=%s",
               lcc_strescape(ident_esc, ident_str, sizeof(ident_esc)));
  
    status = lcc_sendreceive(c, command, &res);
    if (status != 0)
 -    return (status);
 +    return status;
  
    if (res.status != 0) {
      LCC_SET_ERRSTR(c, "Server error: %s", res.message);
      lcc_response_free(&res);
 -    return (-1);
 +    return -1;
    }
  
    lcc_response_free(&res);
 -  return (0);
 +  return 0;
  } /* }}} int lcc_flush */
  
  /* TODO: Implement lcc_putnotif */
@@@ -818,21 -817,21 +816,21 @@@ int lcc_listval(lcc_connection_t *c, /
    size_t ident_num;
  
    if (c == NULL)
 -    return (-1);
 +    return -1;
  
    if ((ret_ident == NULL) || (ret_ident_num == NULL)) {
      lcc_set_errno(c, EINVAL);
 -    return (-1);
 +    return -1;
    }
  
    status = lcc_sendreceive(c, "LISTVAL", &res);
    if (status != 0)
 -    return (status);
 +    return status;
  
    if (res.status != 0) {
      LCC_SET_ERRSTR(c, "Server error: %s", res.message);
      lcc_response_free(&res);
 -    return (-1);
 +    return -1;
    }
  
    ident_num = res.lines_num;
    if (ident == NULL) {
      lcc_response_free(&res);
      lcc_set_errno(c, ENOMEM);
 -    return (-1);
 +    return -1;
    }
  
    for (size_t i = 0; i < res.lines_num; i++) {
  
    if (status != 0) {
      free(ident);
 -    return (-1);
 +    return -1;
    }
  
    *ret_ident = ident;
    *ret_ident_num = ident_num;
  
 -  return (0);
 +  return 0;
  } /* }}} int lcc_listval */
  
  const char *lcc_strerror(lcc_connection_t *c) /* {{{ */
  {
    if (c == NULL)
 -    return ("Invalid object");
 -  return (c->errbuf);
 +    return "Invalid object";
 +  return c->errbuf;
  } /* }}} const char *lcc_strerror */
  
  int lcc_identifier_to_string(lcc_connection_t *c, /* {{{ */
                               const lcc_identifier_t *ident) {
    if ((string == NULL) || (string_size < 6) || (ident == NULL)) {
      lcc_set_errno(c, EINVAL);
 -    return (-1);
 +    return -1;
    }
  
    if (ident->plugin_instance[0] == 0) {
    }
  
    string[string_size - 1] = 0;
 -  return (0);
 +  return 0;
  } /* }}} int lcc_identifier_to_string */
  
  int lcc_string_to_identifier(lcc_connection_t *c, /* {{{ */
    string_copy = strdup(string);
    if (string_copy == NULL) {
      lcc_set_errno(c, ENOMEM);
 -    return (-1);
 +    return -1;
    }
  
    host = string_copy;
    if (plugin == NULL) {
      LCC_SET_ERRSTR(c, "Malformed identifier string: %s", string);
      free(string_copy);
 -    return (-1);
 +    return -1;
    }
    *plugin = 0;
    plugin++;
    if (type == NULL) {
      LCC_SET_ERRSTR(c, "Malformed identifier string: %s", string);
      free(string_copy);
 -    return (-1);
 +    return -1;
    }
    *type = 0;
    type++;
      SSTRCPY(ident->type_instance, type_instance);
  
    free(string_copy);
 -  return (0);
 +  return 0;
  } /* }}} int lcc_string_to_identifier */
  
  int lcc_identifier_compare(const void *a, /* {{{ */
    int status;
  
    if ((i0 == NULL) && (i1 == NULL))
 -    return (0);
 +    return 0;
    else if (i0 == NULL)
 -    return (-1);
 +    return -1;
    else if (i1 == NULL)
 -    return (1);
 +    return 1;
  
  #define CMP_FIELD(f)                                                           \
    do {                                                                         \
      status = strcmp(i0->f, i1->f);                                             \
      if (status != 0)                                                           \
 -      return (status);                                                         \
 +      return status;                                                           \
    } while (0);
  
    CMP_FIELD(host);
  
  #undef CMP_FIELD
  
 -  return (0);
 +  return 0;
  } /* }}} int lcc_identifier_compare */
  
  int lcc_sort_identifiers(lcc_connection_t *c, /* {{{ */
                           lcc_identifier_t *idents, size_t idents_num) {
    if (idents == NULL) {
      lcc_set_errno(c, EINVAL);
 -    return (-1);
 +    return -1;
    }
  
    qsort(idents, idents_num, sizeof(*idents), lcc_identifier_compare);
 -  return (0);
 +  return 0;
  } /* }}} int lcc_sort_identifiers */