From: Florian Forster Date: Thu, 8 Dec 2016 14:42:05 +0000 (+0100) Subject: Merge branch 'collectd-5.7' X-Git-Tag: collectd-5.8.0~279 X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=c6baff42e7e8e547eb7ca7817c0e0e07ccea95db;hp=27d117edf8dd7ae0b0f85772361f3df7ac933ae6;p=collectd.git Merge branch 'collectd-5.7' --- diff --git a/ChangeLog b/ChangeLog index 771ce9c6..e42b231f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,39 @@ +2016-11-30, Version 5.6.2 + * collectd: A compile error on AIX has been fixed: "MSG_DONTWAIT" is not + available on AIX. Thanks to Chao Yang. + * collectd: The capability checking has been rewritten to be more + portable. Thanks to Florian Forster. #2009 + * collectd.conf(5): Various typos have been fixed. Thanks to Marc + Fournier. + * collectd-tg: Incorrect usage of "nanosleep()" has been fixed which + caused the tool to sleep (almost) indefinitely. Thanks to Florian + Forster. + * Build system: Detection of the Java environment has been made + deterministic to allow for reproducible builds. Thanks to Marc + Fournier. #1523 + * Build system: Detection of the Lua headers has been improved. Thanks + to Ruben Kerkhof. + * APC UPS plugin: Unavailable metrics are now skipped instead of + reported as 0 (zero). Thanks to Florian Forster. #2025 + * Modbus plugin: Build issues on FreeBSD have been fixed. Thanks to + Florian Forster. + * OpenVPN plugin: Gracefully handle empty configurations. Thanks to + Pavel Rochnyack. #1932 + * PowerDNS plugin: The "recursor command" has been fixed so PowerDNS can + correctly parse all requested fields. Thanks to Ruben Kerkhof. + * Write Graphite and AMQP plugins: A bug that could lead to a missing + null-termination has been fixed. Thanks to Markus Linnala. + * Write HTTP plugin: A logic error when checking the correctness of the + data set has been fixed. Thanks to Pavel Rochnyack. #1996 + * Write Kafka plugin: The "Key Random" config option has been fixed. + Thanks to Florian Forster. #1977 + * Write Kafka plugin: Support for librdkafka 0.9.0 has been added. + Thanks to Florian Forster. + * Write Riemann plugin: Build issues on Solaris have been fixed. Thanks + to Florian Forster. + * ZFS ARC plugin: A duplicate metric has been removed. Thanks to Ruben + Kerkhof. #1963 + 2016-10-07, Version 5.6.1 * Build system: Unnecessary linking of the Write Graphite plugin with libyajl has been removed. Thanks to Marc Fournier. diff --git a/src/Makefile.am b/src/Makefile.am index b48ea279..0fab4b38 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -57,18 +57,19 @@ test_utils_latency_LDADD = liblatency.la daemon/libplugin_mock.la -lm noinst_LTLIBRARIES += libcmds.la libcmds_la_SOURCES = utils_cmds.c utils_cmds.h \ - utils_cmd_flush.c utils_cmd_flush.h \ - utils_cmd_getval.c utils_cmd_getval.h \ - utils_cmd_listval.c utils_cmd_listval.h \ - utils_cmd_putval.c utils_cmd_putval.h \ - utils_parse_option.c -libcmds_la_LIBADD = daemon/libcommon.la daemon/libmetadata.la \ - daemon/libplugin_mock.la -lm + utils_cmd_flush.c utils_cmd_flush.h \ + utils_cmd_getthreshold.c utils_cmd_getthreshold.h \ + utils_cmd_getval.c utils_cmd_getval.h \ + utils_cmd_listval.c utils_cmd_listval.h \ + utils_cmd_putnotif.c utils_cmd_putnotif.h \ + utils_cmd_putval.c utils_cmd_putval.h \ + utils_parse_option.c utils_parse_option.h +libcmds_la_LIBADD = daemon/libcommon.la daemon/libmetadata.la -lm check_PROGRAMS += test_utils_cmds TESTS += test_utils_cmds test_utils_cmds_SOURCES = utils_cmds_test.c testing.h test_utils_cmds_LDADD = libcmds.la \ - daemon/libplugin_mock.la daemon/libmetadata.la + daemon/libplugin_mock.la noinst_LTLIBRARIES += liblookup.la liblookup_la_SOURCES = utils_vl_lookup.c utils_vl_lookup.h @@ -174,13 +175,11 @@ endif if BUILD_PLUGIN_AMQP pkglib_LTLIBRARIES += amqp.la -amqp_la_SOURCES = amqp.c \ - utils_cmds.c utils_cmds.h \ - utils_cmd_putval.c utils_cmd_putval.h \ - utils_parse_option.c utils_parse_option.h +amqp_la_SOURCES = amqp.c amqp_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBRABBITMQ_LDFLAGS) amqp_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBRABBITMQ_CPPFLAGS) -amqp_la_LIBADD = $(BUILD_WITH_LIBRABBITMQ_LIBS) libformat_graphite.la libformat_json.la +amqp_la_LIBADD = $(BUILD_WITH_LIBRABBITMQ_LIBS) \ + libcmds.la libformat_graphite.la libformat_json.la endif if BUILD_PLUGIN_APACHE @@ -442,12 +441,8 @@ endif if BUILD_PLUGIN_EXEC pkglib_LTLIBRARIES += exec.la -exec_la_SOURCES = exec.c \ - utils_cmds.c utils_cmds.h \ - utils_cmd_putnotif.c utils_cmd_putnotif.h \ - utils_cmd_putval.c utils_cmd_putval.h \ - utils_parse_option.h utils_parse_option.c -exec_la_LDFLAGS = $(PLUGIN_LDFLAGS) +exec_la_SOURCES = exec.c +exec_la_LDFLAGS = $(PLUGIN_LDFLAGS) libcmds.la endif if BUILD_PLUGIN_ETHSTAT @@ -1215,16 +1210,8 @@ endif if BUILD_PLUGIN_UNIXSOCK pkglib_LTLIBRARIES += unixsock.la -unixsock_la_SOURCES = unixsock.c \ - utils_cmds.c utils_cmds.h \ - utils_cmd_flush.h utils_cmd_flush.c \ - utils_cmd_getval.h utils_cmd_getval.c \ - utils_cmd_getthreshold.h utils_cmd_getthreshold.c \ - utils_cmd_listval.h utils_cmd_listval.c \ - utils_cmd_putval.h utils_cmd_putval.c \ - utils_cmd_putnotif.h utils_cmd_putnotif.c \ - utils_parse_option.h utils_parse_option.c -unixsock_la_LDFLAGS = $(PLUGIN_LDFLAGS) +unixsock_la_SOURCES = unixsock.c +unixsock_la_LDFLAGS = $(PLUGIN_LDFLAGS) libcmds.la endif if BUILD_PLUGIN_UPTIME @@ -1326,12 +1313,11 @@ endif if BUILD_PLUGIN_WRITE_KAFKA pkglib_LTLIBRARIES += write_kafka.la write_kafka_la_SOURCES = write_kafka.c \ - utils_cmds.c utils_cmds.h \ - utils_cmd_putval.c utils_cmd_putval.h \ - utils_crc32.c utils_crc32.h + utils_crc32.c utils_crc32.h write_kafka_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBRDKAFKA_CPPFLAGS) write_kafka_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBRDKAFKA_LDFLAGS) -write_kafka_la_LIBADD = $(BUILD_WITH_LIBRDKAFKA_LIBS) libformat_graphite.la libformat_json.la +write_kafka_la_LIBADD = $(BUILD_WITH_LIBRDKAFKA_LIBS) \ + libcmds.la libformat_graphite.la libformat_json.la endif if BUILD_PLUGIN_WRITE_LOG diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index 597bbe8c..6a76e45c 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -4878,7 +4878,7 @@ so the values will not loop. =item B B|B The network plugin cannot only receive and send statistics, it can also create -statistics about itself. Collected data included the number of received and +statistics about itself. Collectd data included the number of received and sent octets and packets, the length of the receive queue and the number of values handled. When set to B, the I will make these statistics available. Defaults to B. diff --git a/src/daemon/utils_random.c b/src/daemon/utils_random.c index 34cf5b80..d490986d 100644 --- a/src/daemon/utils_random.c +++ b/src/daemon/utils_random.c @@ -50,7 +50,7 @@ static void cdrand_seed(void) { have_seed = 1; } -double cdrand_d(void) { +double cdrand_d() { double r; pthread_mutex_lock(&lock); @@ -61,6 +61,17 @@ double cdrand_d(void) { return (r); } +uint32_t cdrand_u() { + long r; + + pthread_mutex_lock(&lock); + cdrand_seed(); + r = jrand48(seed); + pthread_mutex_unlock(&lock); + + return (uint32_t)r; +} + long cdrand_range(long min, long max) { long range; long r; diff --git a/src/daemon/utils_random.h b/src/daemon/utils_random.h index d56bcf6a..e25ae9b6 100644 --- a/src/daemon/utils_random.h +++ b/src/daemon/utils_random.h @@ -29,7 +29,15 @@ * * This function is thread- and reentrant-safe. */ -double cdrand_d(void); +double cdrand_d(); + +/** + * cdrand_u returns a random uint32_t value uniformly distributed in the range + * [0-2^32). + * + * This function is thread- and reentrant-safe. + */ +uint32_t cdrand_u(); /** * Returns a random long between min and max, inclusively. diff --git a/src/smart.c b/src/smart.c index 373839e1..9395945b 100644 --- a/src/smart.c +++ b/src/smart.c @@ -82,10 +82,9 @@ static void smart_submit(const char *dev, const char *type, plugin_dispatch_values(&vl); } -static void smart_handle_disk_attribute(SkDisk *d, - const SkSmartAttributeParsedData *a, - void *userdata) { - const char *dev = userdata; +static void handle_attribute(SkDisk *d, const SkSmartAttributeParsedData *a, + void *userdata) { + char const *name = userdata; if (!a->current_value_valid || !a->worst_value_valid) return; @@ -101,7 +100,7 @@ static void smart_handle_disk_attribute(SkDisk *d, vl.values = values; vl.values_len = STATIC_ARRAY_SIZE(values); sstrncpy(vl.plugin, "smart", sizeof(vl.plugin)); - sstrncpy(vl.plugin_instance, dev, sizeof(vl.plugin_instance)); + sstrncpy(vl.plugin_instance, name, sizeof(vl.plugin_instance)); sstrncpy(vl.type, "smart_attribute", sizeof(vl.type)); sstrncpy(vl.type_instance, a->name, sizeof(vl.type_instance)); @@ -111,7 +110,7 @@ static void smart_handle_disk_attribute(SkDisk *d, notification_t notif = {NOTIF_WARNING, cdtime(), "", "", "smart", "", "smart_attribute", "", NULL}; sstrncpy(notif.host, hostname_g, sizeof(notif.host)); - sstrncpy(notif.plugin_instance, dev, sizeof(notif.plugin_instance)); + sstrncpy(notif.plugin_instance, name, sizeof(notif.plugin_instance)); sstrncpy(notif.type_instance, a->name, sizeof(notif.type_instance)); ssnprintf(notif.message, sizeof(notif.message), "attribute %s is below allowed threshold (%d < %d)", a->name, @@ -120,86 +119,87 @@ static void smart_handle_disk_attribute(SkDisk *d, } } -static void smart_handle_disk(const char *dev, const char *serial) { - SkDisk *d = NULL; - SkBool awake = FALSE; +static void smart_read_disk(SkDisk *d, char const *name) { SkBool available = FALSE; - const char *shortname; - const SkSmartParsedData *spd; - uint64_t poweron, powercycles, badsectors, temperature; - - if (use_serial && serial) { - shortname = serial; - } else { - shortname = strrchr(dev, '/'); - if (!shortname) - return; - shortname++; - } - if (ignorelist_match(ignorelist, shortname) != 0) { - DEBUG("smart plugin: ignoring %s.", dev); - return; - } - - DEBUG("smart plugin: checking SMART status of %s.", dev); - - if (sk_disk_open(dev, &d) < 0) { - ERROR("smart plugin: unable to open %s.", dev); - return; - } if (sk_disk_identify_is_available(d, &available) < 0 || !available) { - DEBUG("smart plugin: disk %s cannot be identified.", dev); - goto end; + DEBUG("smart plugin: disk %s cannot be identified.", name); + return; } if (sk_disk_smart_is_available(d, &available) < 0 || !available) { - DEBUG("smart plugin: disk %s has no SMART support.", dev); - goto end; + DEBUG("smart plugin: disk %s has no SMART support.", name); + return; } if (!ignore_sleep_mode) { + SkBool awake = FALSE; if (sk_disk_check_sleep_mode(d, &awake) < 0 || !awake) { - DEBUG("smart plugin: disk %s is sleeping.", dev); - goto end; + DEBUG("smart plugin: disk %s is sleeping.", name); + return; } } if (sk_disk_smart_read_data(d) < 0) { - ERROR("smart plugin: unable to get SMART data for disk %s.", dev); - goto end; + ERROR("smart plugin: unable to get SMART data for disk %s.", name); + return; } - if (sk_disk_smart_parse(d, &spd) < 0) { - ERROR("smart plugin: unable to parse SMART data for disk %s.", dev); - goto end; + + if (sk_disk_smart_parse(d, &(SkSmartParsedData const *){NULL}) < 0) { + ERROR("smart plugin: unable to parse SMART data for disk %s.", name); + return; } /* Get some specific values */ - if (sk_disk_smart_get_power_on(d, &poweron) < 0) { - WARNING("smart plugin: unable to get milliseconds since power on for %s.", - dev); - } else - smart_submit(shortname, "smart_poweron", "", poweron / 1000.); - - if (sk_disk_smart_get_power_cycle(d, &powercycles) < 0) { - WARNING("smart plugin: unable to get number of power cycles for %s.", dev); - } else - smart_submit(shortname, "smart_powercycles", "", powercycles); - - if (sk_disk_smart_get_bad(d, &badsectors) < 0) { - WARNING("smart plugin: unable to get number of bad sectors for %s.", dev); - } else - smart_submit(shortname, "smart_badsectors", "", badsectors); - - if (sk_disk_smart_get_temperature(d, &temperature) < 0) { - WARNING("smart plugin: unable to get temperature for %s.", dev); - } else - smart_submit(shortname, "smart_temperature", "", - temperature / 1000. - 273.15); + uint64_t value; + if (sk_disk_smart_get_power_on(d, &value) >= 0) + smart_submit(name, "smart_poweron", "", ((gauge_t)value) / 1000.); + else + DEBUG("smart plugin: unable to get milliseconds since power on for %s.", + name); + + if (sk_disk_smart_get_power_cycle(d, &value) >= 0) + smart_submit(name, "smart_powercycles", "", (gauge_t)value); + else + DEBUG("smart plugin: unable to get number of power cycles for %s.", name); + + if (sk_disk_smart_get_bad(d, &value) >= 0) + smart_submit(name, "smart_badsectors", "", (gauge_t)value); + else + DEBUG("smart plugin: unable to get number of bad sectors for %s.", name); + + if (sk_disk_smart_get_temperature(d, &value) >= 0) + smart_submit(name, "smart_temperature", "", + ((gauge_t)value) / 1000. - 273.15); + else + DEBUG("smart plugin: unable to get temperature for %s.", name); /* Grab all attributes */ - if (sk_disk_smart_parse_attributes(d, smart_handle_disk_attribute, - (char *)shortname) < 0) { - ERROR("smart plugin: unable to handle SMART attributes for %s.", dev); + if (sk_disk_smart_parse_attributes(d, handle_attribute, (void *)name) < 0) { + ERROR("smart plugin: unable to handle SMART attributes for %s.", name); + } +} + +static void smart_handle_disk(const char *dev, const char *serial) { + SkDisk *d = NULL; + const char *name; + + if (use_serial && serial) { + name = serial; + } else { + name = strrchr(dev, '/'); + if (!name) + return; + name++; + } + if (ignorelist_match(ignorelist, name) != 0) { + DEBUG("smart plugin: ignoring %s.", dev); + return; + } + + DEBUG("smart plugin: checking SMART status of %s.", dev); + if (sk_disk_open(dev, &d) < 0) { + ERROR("smart plugin: unable to open %s.", dev); + return; } -end: + smart_read_disk(d, name); sk_disk_free(d); } diff --git a/src/utils_cmd_flush.c b/src/utils_cmd_flush.c index 88951281..9e8950bb 100644 --- a/src/utils_cmd_flush.c +++ b/src/utils_cmd_flush.c @@ -31,7 +31,6 @@ #include "common.h" #include "plugin.h" #include "utils_cmd_flush.h" -#include "utils_parse_option.h" cmd_status_t cmd_parse_flush(size_t argc, char **argv, cmd_flush_t *ret_flush, const cmd_options_t *opts, diff --git a/src/utils_cmd_flush.h b/src/utils_cmd_flush.h index 5dc88f95..129aa85e 100644 --- a/src/utils_cmd_flush.h +++ b/src/utils_cmd_flush.h @@ -27,10 +27,10 @@ #ifndef UTILS_CMD_FLUSH_H #define UTILS_CMD_FLUSH_H 1 -#include - #include "utils_cmds.h" +#include + cmd_status_t cmd_parse_flush(size_t argc, char **argv, cmd_flush_t *ret_flush, const cmd_options_t *opts, cmd_error_handler_t *err); diff --git a/src/utils_cmd_putval.c b/src/utils_cmd_putval.c index e0455335..817f954b 100644 --- a/src/utils_cmd_putval.c +++ b/src/utils_cmd_putval.c @@ -29,12 +29,7 @@ #include "collectd.h" #include "common.h" -#include "plugin.h" - -#include "utils_cmd_putval.h" #include "utils_cmd_putval.h" -#include "utils_cmds.h" -#include "utils_parse_option.h" /* * private helper functions diff --git a/src/utils_cmd_putval.h b/src/utils_cmd_putval.h index 75cd190c..bc6e193e 100644 --- a/src/utils_cmd_putval.h +++ b/src/utils_cmd_putval.h @@ -27,11 +27,11 @@ #ifndef UTILS_CMD_PUTVAL_H #define UTILS_CMD_PUTVAL_H 1 -#include - #include "plugin.h" #include "utils_cmds.h" +#include + cmd_status_t cmd_parse_putval(size_t argc, char **argv, cmd_putval_t *ret_putval, const cmd_options_t *opts, diff --git a/src/write_kafka.c b/src/write_kafka.c index e3fc5a26..306d92cc 100644 --- a/src/write_kafka.c +++ b/src/write_kafka.c @@ -31,6 +31,7 @@ #include "utils_cmd_putval.h" #include "utils_format_graphite.h" #include "utils_format_json.h" +#include "utils_random.h" #include #include @@ -88,7 +89,7 @@ static uint32_t kafka_hash(const char *keydata, size_t keylen) { #define KAFKA_RANDOM_KEY_BUFFER \ (char[KAFKA_RANDOM_KEY_SIZE]) { "" } static char *kafka_random_key(char buffer[static KAFKA_RANDOM_KEY_SIZE]) { - ssnprintf(buffer, KAFKA_RANDOM_KEY_SIZE, "%08lX", (unsigned long)mrand48()); + ssnprintf(buffer, KAFKA_RANDOM_KEY_SIZE, "%08" PRIX32, cdrand_u()); return buffer; } diff --git a/version-gen.sh b/version-gen.sh index e106d805..56daf44b 100755 --- a/version-gen.sh +++ b/version-gen.sh @@ -1,6 +1,6 @@ #!/bin/sh -DEFAULT_VERSION="5.6.1.git" +DEFAULT_VERSION="5.6.2.git" if [ -d .git ]; then VERSION="`git describe --dirty=+ --abbrev=7 2> /dev/null | grep collectd | sed -e 's/^collectd-//' -e 's/-/./g'`"