From: Florian Forster Date: Mon, 7 Nov 2016 07:52:38 +0000 (+0100) Subject: Merge branch 'collectd-5.6' X-Git-Tag: collectd-5.7.0~36 X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=41288c6a9ed050b41ad47184aa1b53668c3588cc;hp=-c;p=collectd.git Merge branch 'collectd-5.6' --- 41288c6a9ed050b41ad47184aa1b53668c3588cc diff --combined configure.ac index 5d3fcaec,b0373ed0..b697ab92 --- a/configure.ac +++ b/configure.ac @@@ -2544,81 -2544,6 +2544,81 @@@ the fi # }}} +# --with-libdpdk {{{ +AC_ARG_WITH(libdpdk, [AS_HELP_STRING([--with-libdpdk@<:@=PREFIX@:>@], [Path to the DPDK build directory.])], +[ + if test "x$withval" != "xno" && test "x$withval" != "xyes" + then + RTE_BUILD="$withval" + with_libdpdk="yes" + else + RTE_BUILD="/usr" + with_libdpdk="$withval" + fi + DPDK_INCLUDE="$RTE_BUILD/include" + DPDK_LIB_DIR="$RTE_BUILD/lib" + FOUND_DPDK=yes +], [with_libdpdk="no"]) + +if test "x$with_libdpdk" = "xyes" +then + LOCAL_DPDK_INSTALL="no" + AC_CHECK_HEADER([$DPDK_INCLUDE/rte_config.h], [LOCAL_DPDK_INSTALL=yes], + [AC_CHECK_HEADER([$DPDK_INCLUDE/dpdk/rte_config.h], + [], + [FOUND_DPDK=no], [])], []) + + if test "x$LOCAL_DPDK_INSTALL" = "xno" + then + DPDK_INCLUDE=$DPDK_INCLUDE/dpdk + fi + + if test "x$FOUND_DPDK" = "xno" + then + AC_MSG_ERROR([libdpdk error: rte_config.h not found]) + fi +fi + +if test "x$with_libdpdk" = "xyes" +then + SAVE_LDFLAGS="$LDFLAGS" + + if test "x$LOCAL_DPDK_INSTALL" != "xyes" + then + LDFLAGS="$LDFLAGS -L$DPDK_LIB_DIR" + fi + + AC_CHECK_LIB(dpdk, rte_eal_init, + [BUILD_WITH_DPDK_LIBS="-Wl,-ldpdk"], + [FOUND_DPDK=no]) + + LDFLAGS="$SAVE_LDFLAGS" + if test "x$FOUND_DPDK" = "xno" + then + AC_MSG_ERROR([libdpdk error: cannot link with dpdk in $DPDK_LIB_DIR]) + fi +fi + +# +# Note: An issue on Ubuntu 14.04 necessitates the use of -Wl,--no-as-needed: +# If you try compile with the older linker, the dpdk symbols will be undefined. +# This workaround should be removed when no longer necessary. +# +if test "x$with_libdpdk" = "xyes" +then + BUILD_WITH_DPDK_CFLAGS+="-I$DPDK_INCLUDE" + if test "x$LOCAL_DPDK_INSTALL" != "xyes" + then + BUILD_WITH_DPDK_LDFLAGS="-Wl,--no-as-needed" + else + BUILD_WITH_DPDK_LDFLAGS="-L$DPDK_LIB_DIR -Wl,--no-as-needed" + fi + AC_SUBST(BUILD_WITH_DPDK_CFLAGS) + AC_SUBST(BUILD_WITH_DPDK_LDFLAGS) + AC_SUBST(BUILD_WITH_DPDK_LIBS) +fi +# }}} + # --with-java {{{ with_java_home="$JAVA_HOME" if test "x$with_java_home" = "x" @@@ -4111,55 -4036,6 +4111,55 @@@ f AM_CONDITIONAL(BUILD_WITH_LIBPQ, test "x$with_libpq" = "xyes") # }}} +# --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_CHECK_HEADERS(pqos.h, [with_libpqos="yes"], [with_libpqos="no (pqos.h not found)"]) + + 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)"]) + + CPPFLAGS="$SAVE_CPPFLAGS" + LDFLAGS="$SAVE_LDFLAGS" +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) +fi +# }}} + # --with-libprotobuf {{{ with_libprotobuf_cppflags="" with_libprotobuf_ldflags="" @@@ -4503,11 -4379,10 +4503,10 @@@ the if test "x$with_librdkafka_log_cb" = "xyes" then AC_DEFINE(HAVE_LIBRDKAFKA_LOG_CB, 1, [Define if librdkafka log facility is present and usable.]) - fi - if test "x$with_librdkafka_logger" = "xyes" + else if test "x$with_librdkafka_logger" = "xyes" then AC_DEFINE(HAVE_LIBRDKAFKA_LOGGER, 1, [Define if librdkafka log facility is present and usable.]) - fi + fi; fi fi CPPFLAGS="$SAVE_CPPFLAGS" LDFLAGS="$SAVE_LDFLAGS" @@@ -5840,15 -5715,12 +5839,15 @@@ plugin_curl_xml="no plugin_df="no" plugin_disk="no" plugin_drbd="no" +plugin_dpdk="no" plugin_entropy="no" plugin_ethstat="no" plugin_fhcount="no" plugin_fscache="no" plugin_gps="no" plugin_grpc="no" +plugin_hugepages="no" +plugin_intel_rdt="no" plugin_interface="no" plugin_ipmi="no" plugin_ipvs="no" @@@ -5897,7 -5769,6 +5896,7 @@@ the plugin_entropy="yes" plugin_fhcount="yes" plugin_fscache="yes" + plugin_hugepages="yes" plugin_interface="yes" plugin_ipc="yes" plugin_irq="yes" @@@ -6292,7 -6163,6 +6291,7 @@@ AC_PLUGIN([dbi], [$with AC_PLUGIN([df], [$plugin_df], [Filesystem usage statistics]) AC_PLUGIN([disk], [$plugin_disk], [Disk usage statistics]) AC_PLUGIN([dns], [$with_libpcap], [DNS traffic analysis]) +AC_PLUGIN([dpdkstat], [$with_libdpdk], [Stats & Status from DPDK]) AC_PLUGIN([drbd], [$plugin_drbd], [DRBD statistics]) AC_PLUGIN([email], [yes], [EMail statistics]) AC_PLUGIN([entropy], [$plugin_entropy], [Entropy statistics]) @@@ -6305,8 -6175,6 +6304,8 @@@ AC_PLUGIN([gmond], [$with AC_PLUGIN([gps], [$plugin_gps], [GPS plugin]) AC_PLUGIN([grpc], [$plugin_grpc], [gRPC plugin]) AC_PLUGIN([hddtemp], [yes], [Query hddtempd]) +AC_PLUGIN([hugepages], [$plugin_hugepages], [Hugepages statistics]) +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]) AC_PLUGIN([ipmi], [$plugin_ipmi], [IPMI sensor statistics]) @@@ -6634,7 -6502,6 +6633,7 @@@ AC_MSG_RESULT([ libaquaero5 . . . . AC_MSG_RESULT([ libatasmart . . . . . $with_libatasmart]) AC_MSG_RESULT([ libcurl . . . . . . . $with_libcurl]) AC_MSG_RESULT([ libdbi . . . . . . . $with_libdbi]) +AC_MSG_RESULT([ libdpdk . . . . . . . $with_libdpdk]) AC_MSG_RESULT([ libesmtp . . . . . . $with_libesmtp]) AC_MSG_RESULT([ libganglia . . . . . $with_libganglia]) AC_MSG_RESULT([ libgcrypt . . . . . . $with_libgcrypt]) @@@ -6668,7 -6535,6 +6667,7 @@@ AC_MSG_RESULT([ libpcap . . . . . . AC_MSG_RESULT([ libperfstat . . . . . $with_perfstat]) AC_MSG_RESULT([ libperl . . . . . . . $with_libperl]) AC_MSG_RESULT([ libpq . . . . . . . . $with_libpq]) +AC_MSG_RESULT([ libpqos . . . . . . . $with_libpqos]) AC_MSG_RESULT([ libprotobuf . . . . . $with_libprotobuf]) AC_MSG_RESULT([ libprotobuf-c . . . . $with_libprotobuf_c]) AC_MSG_RESULT([ libpython . . . . . . $with_libpython]) @@@ -6727,7 -6593,6 +6726,7 @@@ AC_MSG_RESULT([ dbi . . . . . . . . AC_MSG_RESULT([ df . . . . . . . . . $enable_df]) AC_MSG_RESULT([ disk . . . . . . . . $enable_disk]) AC_MSG_RESULT([ dns . . . . . . . . . $enable_dns]) +AC_MSG_RESULT([ dpdkstat . . . . . . .$enable_dpdkstat]) AC_MSG_RESULT([ drbd . . . . . . . . $enable_drbd]) AC_MSG_RESULT([ email . . . . . . . . $enable_email]) AC_MSG_RESULT([ entropy . . . . . . . $enable_entropy]) @@@ -6740,8 -6605,6 +6739,8 @@@ AC_MSG_RESULT([ gmond . . . . . . . AC_MSG_RESULT([ gps . . . . . . . . . $enable_gps]) AC_MSG_RESULT([ grpc . . . . . . . . $enable_grpc]) AC_MSG_RESULT([ hddtemp . . . . . . . $enable_hddtemp]) +AC_MSG_RESULT([ hugepages . . . . . . $enable_hugepages]) +AC_MSG_RESULT([ intel_rdt. . . . . . $enable_intel_rdt]) AC_MSG_RESULT([ interface . . . . . . $enable_interface]) AC_MSG_RESULT([ ipc . . . . . . . . . $enable_ipc]) AC_MSG_RESULT([ ipmi . . . . . . . . $enable_ipmi]) diff --combined src/apcups.c index 937f2a06,70e7fcea..50c45e7b --- a/src/apcups.c +++ b/src/apcups.c @@@ -55,17 -55,17 +55,17 @@@ /* * Private data types */ - struct apc_detail_s + typedef struct { - double linev; - double loadpct; - double bcharge; - double timeleft; - double outputv; - double itemp; - double battv; - double linefreq; - }; + gauge_t linev; + gauge_t loadpct; + gauge_t bcharge; + gauge_t timeleft; + gauge_t outputv; + gauge_t itemp; + gauge_t battv; + gauge_t linefreq; + } apc_detail_t; /* * Private variables @@@ -253,14 -253,12 +253,12 @@@ static int net_send (int *sockfd, cons /* Get and print status from apcupsd NIS server */ static int apc_query_server (char const *node, char const *service, - struct apc_detail_s *apcups_detail) + apc_detail_t *apcups_detail) { int n; char recvline[1024]; char *tokptr; char *toksaveptr; - char *key; - double value; _Bool retry = 1; int status; @@@ -329,10 -327,13 +327,13 @@@ tokptr = strtok_r (recvline, " :\t", &toksaveptr); while (tokptr != NULL) { - key = tokptr; + char *key = tokptr; if ((tokptr = strtok_r (NULL, " :\t", &toksaveptr)) == NULL) continue; - value = atof (tokptr); + + gauge_t value; + if (strtogauge (tokptr, &value) != 0) + continue; PRINT_VALUE (key, value); @@@ -414,20 -415,28 +415,22 @@@ static int apcups_config (oconfig_item_ return (0); } /* int apcups_config */ - static void apc_submit_generic (const char *type, const char *type_inst, double value) + static void apc_submit_generic (const char *type, const char *type_inst, gauge_t value) { - value_t values[1]; -- value_list_t vl = VALUE_LIST_INIT; - + if (isnan (value)) + return; - values[0].gauge = value; - - vl.values = values; ++ value_list_t vl = VALUE_LIST_INIT; + vl.values = &(value_t) { .gauge = value }; vl.values_len = 1; - sstrncpy (vl.host, hostname_g, sizeof (vl.host)); sstrncpy (vl.plugin, "apcups", sizeof (vl.plugin)); - sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance)); sstrncpy (vl.type, type, sizeof (vl.type)); sstrncpy (vl.type_instance, type_inst, sizeof (vl.type_instance)); plugin_dispatch_values (&vl); } - static void apc_submit (struct apc_detail_s *apcups_detail) + static void apc_submit (apc_detail_t const *apcups_detail) { apc_submit_generic ("voltage", "input", apcups_detail->linev); apc_submit_generic ("voltage", "output", apcups_detail->outputv); @@@ -441,33 -450,27 +444,27 @@@ static int apcups_read (void) { - struct apc_detail_s apcups_detail; - int status; + apc_detail_t apcups_detail = { + .linev = NAN, + .outputv = NAN, + .battv = NAN, + .loadpct = NAN, + .bcharge = NAN, + .timeleft = NAN, + .itemp = NAN, + .linefreq = NAN, + }; - apcups_detail.linev = -1.0; - apcups_detail.outputv = -1.0; - apcups_detail.battv = -1.0; - apcups_detail.loadpct = -1.0; - apcups_detail.bcharge = -1.0; - apcups_detail.timeleft = NAN; - apcups_detail.itemp = -300.0; - apcups_detail.linefreq = -1.0; - - status = apc_query_server ((conf_node == NULL) ? APCUPS_DEFAULT_NODE : conf_node, - (conf_service == NULL) ? APCUPS_DEFAULT_SERVICE : conf_service, - &apcups_detail); - - /* - * if we did not connect then do not bother submitting - * zeros. We want rrd files to have NAN. - */ + int status = apc_query_server (conf_node == NULL + ? APCUPS_DEFAULT_NODE + : conf_node, + conf_service, &apcups_detail); if (status != 0) { - DEBUG ("apcups plugin: apc_query_server (%s, %s) = %i", - (conf_node == NULL) ? APCUPS_DEFAULT_NODE : conf_node, - (conf_service == NULL) ? APCUPS_DEFAULT_SERVICE : conf_service, - status); - return (-1); + DEBUG ("apcups plugin: apc_query_server (\"%s\", \"%s\") = %d", + conf_node == NULL ? APCUPS_DEFAULT_NODE : conf_node, + conf_service, status); + return (status); } apc_submit (&apcups_detail); diff --combined src/modbus.c index a7d1b582,473a4ee4..589ce90f --- a/src/modbus.c +++ b/src/modbus.c @@@ -23,11 -23,12 +23,12 @@@ #include "collectd.h" #include "common.h" + #include "configfile.h" #include "plugin.h" - #include - #include + #include + #include #ifndef LIBMODBUS_VERSION_CHECK /* Assume version 2.0.3 */ @@@ -470,12 -471,9 +471,11 @@@ static int mb_read_data (mb_host_t *hos } else if (host->conntype == MBCONN_TCP) { + /* getpeername() is used only to determine if the socket is connected, not + * because we're really interested in the peer's IP address. */ - status = getpeername (modbus_get_socket (host->connection), - (struct sockaddr *) &(struct sockaddr_storage) { 0 }, - &(socklen_t) { sizeof (struct sockaddr_storage) }); - if (status != 0) + if (getpeername (modbus_get_socket (host->connection), + (void *) &(struct sockaddr_storage) {0}, + &(socklen_t) {sizeof(struct sockaddr_storage)}) != 0) status = errno; } @@@ -1003,17 -1001,18 +1003,17 @@@ static int mb_config_add_host (oconfig_ if (status == 0) { - user_data_t ud; char name[1024]; - ud.data = host; - ud.free_func = host_free; - ssnprintf (name, sizeof (name), "modbus-%s", host->host); plugin_register_complex_read (/* group = */ NULL, name, /* callback = */ mb_read, /* interval = */ host->interval, - &ud); + &(user_data_t) { + .data = host, + .free_func = host_free, + }); } else { diff --combined src/write_kafka.c index 654db0a4,6d826c25..6018fea0 --- a/src/write_kafka.c +++ b/src/write_kafka.c @@@ -60,7 -60,14 +60,14 @@@ static int kafka_write(const data_set_ static int32_t kafka_partition(const rd_kafka_topic_t *, const void *, size_t, int32_t, void *, void *); - #if defined HAVE_LIBRDKAFKA_LOGGER || defined HAVE_LIBRDKAFKA_LOG_CB + /* Version 0.9.0 of librdkafka deprecates rd_kafka_set_logger() in favor of + * rd_kafka_conf_set_log_cb(). This is to make sure we're not using the + * deprecated function. */ + #ifdef HAVE_LIBRDKAFKA_LOG_CB + # undef HAVE_LIBRDKAFKA_LOGGER + #endif + + #if defined(HAVE_LIBRDKAFKA_LOGGER) || defined(HAVE_LIBRDKAFKA_LOG_CB) static void kafka_log(const rd_kafka_t *, int, const char *, const char *); static void kafka_log(const rd_kafka_t *rkt, int level, @@@ -181,9 -188,9 +188,9 @@@ static int kafka_write(const data_set_ switch (ctx->format) { case KAFKA_FORMAT_COMMAND: - status = create_putval(buffer, sizeof(buffer), ds, vl); + status = cmd_create_putval(buffer, sizeof(buffer), ds, vl); if (status != 0) { - ERROR("write_kafka plugin: create_putval failed with status %i.", + ERROR("write_kafka plugin: cmd_create_putval failed with status %i.", status); return status; } @@@ -395,11 -402,12 +402,11 @@@ static void kafka_config_topic(rd_kafka ssnprintf(callback_name, sizeof(callback_name), "write_kafka/%s", tctx->topic_name); - user_data_t ud = { - .data = tctx, - .free_func = kafka_topic_context_free - }; - - status = plugin_register_write (callback_name, kafka_write, &ud); + status = plugin_register_write (callback_name, kafka_write, + &(user_data_t) { + .data = tctx, + .free_func = kafka_topic_context_free, + }); if (status != 0) { WARNING ("write_kafka plugin: plugin_register_write (\"%s\") " "failed with status %i.",