From: Marc Fournier Date: Tue, 10 Jan 2017 22:40:43 +0000 (+0100) Subject: Merge pull request #2122 from octo/issue/2108 X-Git-Tag: collectd-5.7.1~1 X-Git-Url: https://git.octo.it/?p=collectd.git;a=commitdiff_plain;h=6397cdc3596af7438a9b351ac13d7eaac279554a;hp=30ec92514946bd0b94e09b0cc6d065c6dda878d4 Merge pull request #2122 from octo/issue/2108 src/daemon/plugin.c: Register plugin_update_internal_statistics() as … --- diff --git a/configure.ac b/configure.ac index 993e319e..ab6f2298 100644 --- a/configure.ac +++ b/configure.ac @@ -4235,6 +4235,16 @@ then fi if test "x$with_libpqos" = "xyes" then + SAVE_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $with_libpqos_cppflags" + AC_RUN_IFELSE([AC_LANG_PROGRAM( + [[#include ]], + [[return !(PQOS_VERSION >= 106)]])], + [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" diff --git a/contrib/redhat/collectd.spec b/contrib/redhat/collectd.spec index 4fc76e11..bed3cc5e 100644 --- a/contrib/redhat/collectd.spec +++ b/contrib/redhat/collectd.spec @@ -150,6 +150,7 @@ %define with_write_log 0%{!?_without_write_log:1} %define with_write_prometheus 0%{!?_without_write_prometheus:1} %define with_write_redis 0%{!?_without_write_redis:1} +%define with_write_riemann 0%{!?_without_write_riemann:1} %define with_write_sensu 0%{!?_without_write_sensu:1} %define with_write_tsdb 0%{!?_without_write_tsdb:1} %define with_xmms 0%{!?_without_xmms:0%{?_has_xmms}} @@ -195,8 +196,6 @@ %define with_write_kafka 0%{!?_without_write_kafka:0} # plugin write_mongodb disabled, requires libmongoc %define with_write_mongodb 0%{!?_without_write_mongodb:0} -# plugin write_riemann disabled, requires a new enough riemann_c_client -%define with_write_riemann 0%{!?_without_write_riemann:0} # plugin xencpu disabled, requires xen-devel from non-default repo %define with_xencpu 0%{!?_without_xencpu:0} # plugin zone disabled, requires Solaris @@ -220,6 +219,7 @@ %define with_turbostat 0 %define with_write_prometheus 0 %define with_write_redis 0 +%define with_write_riemann 0 %endif # Plugins not buildable on RHEL < 7 @@ -230,6 +230,7 @@ %define with_redis 0 %define with_rrdcached 0 %define with_write_redis 0 +%define with_write_riemann 0 %define with_xmms 0 %endif @@ -858,7 +859,7 @@ The Write Redis plugin stores values in Redis, a “data structures server”. Summary: riemann plugin for collectd Group: System Environment/Daemons Requires: %{name}%{?_isa} = %{version}-%{release} -BuildRequires: protobuf-c-devel +BuildRequires: riemann-c-client-devel >= 1.6 %description write_riemann The riemann plugin submits values to Riemann, an event stream processor. %endif diff --git a/src/Makefile.am b/src/Makefile.am index bec7ca93..be4162be 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -273,6 +273,7 @@ if BUILD_PLUGIN_CHRONY pkglib_LTLIBRARIES += chrony.la chrony_la_SOURCES = chrony.c chrony_la_LDFLAGS = $(PLUGIN_LDFLAGS) +chrony_la_LIBADD = -lm endif if BUILD_PLUGIN_CONNTRACK diff --git a/src/curl_json.c b/src/curl_json.c index aa1ae797..e6c0b513 100644 --- a/src/curl_json.c +++ b/src/curl_json.c @@ -600,7 +600,7 @@ static int cj_init_curl(cj_t *db) /* {{{ */ curl_easy_setopt(db->curl, CURLOPT_TIMEOUT_MS, (long)db->timeout); else if (db->interval > 0) curl_easy_setopt(db->curl, CURLOPT_TIMEOUT_MS, - (long)CDTIME_T_TO_MS(db->timeout)); + (long)CDTIME_T_TO_MS(db->interval)); else curl_easy_setopt(db->curl, CURLOPT_TIMEOUT_MS, (long)CDTIME_T_TO_MS(plugin_get_interval())); diff --git a/src/daemon/common.c b/src/daemon/common.c index 0aa5345b..1fa99eb2 100644 --- a/src/daemon/common.c +++ b/src/daemon/common.c @@ -271,8 +271,10 @@ ssize_t swrite(int fd, const void *buf, size_t count) { ptr = (const char *)buf; nleft = count; - if (fd < 0) - return (-1); + if (fd < 0) { + errno = EINVAL; + return errno; + } /* checking for closed peer connection */ pfd.fd = fd; @@ -281,10 +283,9 @@ ssize_t swrite(int fd, const void *buf, size_t count) { if (poll(&pfd, 1, 0) > 0) { char buffer[32]; if (recv(fd, buffer, sizeof(buffer), MSG_PEEK | MSG_DONTWAIT) == 0) { - // if recv returns zero (even though poll() said there is data to be - // read), - // that means the connection has been closed - return -1; + /* if recv returns zero (even though poll() said there is data to be + * read), that means the connection has been closed */ + return errno ? errno : -1; } } @@ -295,7 +296,7 @@ ssize_t swrite(int fd, const void *buf, size_t count) { continue; if (status < 0) - return (status); + return errno ? errno : status; nleft = nleft - ((size_t)status); ptr = ptr + ((size_t)status); diff --git a/src/daemon/configfile.c b/src/daemon/configfile.c index d5f01e07..3934e1f9 100644 --- a/src/daemon/configfile.c +++ b/src/daemon/configfile.c @@ -1119,14 +1119,36 @@ int cf_util_get_boolean(const oconfig_item_t *ci, _Bool *ret_bool) /* {{{ */ if ((ci == NULL) || (ret_bool == NULL)) return (EINVAL); - if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN)) { + if ((ci->values_num != 1) || ((ci->values[0].type != OCONFIG_TYPE_BOOLEAN) && + (ci->values[0].type != OCONFIG_TYPE_STRING))) { ERROR("cf_util_get_boolean: The %s option requires " "exactly one boolean argument.", ci->key); return (-1); } - *ret_bool = ci->values[0].value.boolean ? 1 : 0; + switch (ci->values[0].type) { + case OCONFIG_TYPE_BOOLEAN: + *ret_bool = ci->values[0].value.boolean ? 1 : 0; + break; + case OCONFIG_TYPE_STRING: + WARNING("cf_util_get_boolean: Using string value `%s' for boolean option " + "`%s' is deprecated and will be removed in future releases. " + "Use unquoted true or false instead.", + ci->values[0].value.string, ci->key); + + if (IS_TRUE(ci->values[0].value.string)) + *ret_bool = 1; + else if (IS_FALSE(ci->values[0].value.string)) + *ret_bool = 0; + else { + ERROR("cf_util_get_boolean: Cannot parse string value `%s' of the `%s' " + "option as a boolean value.", + ci->values[0].value.string, ci->key); + return (-1); + } + break; + } return (0); } /* }}} int cf_util_get_boolean */ diff --git a/src/netapp.c b/src/netapp.c index 4d458793..45144bf1 100644 --- a/src/netapp.c +++ b/src/netapp.c @@ -674,7 +674,7 @@ static int submit_double(const char *host, const char *plugin_inst, /* {{{ */ const char *type, const char *type_inst, double d, cdtime_t timestamp, cdtime_t interval) { return (submit_values(host, plugin_inst, type, type_inst, - &(value_t){.gauge = counter}, 1, timestamp, interval)); + &(value_t){.gauge = d}, 1, timestamp, interval)); } /* }}} int submit_uint64 */ /* Calculate hit ratio from old and new counters and submit the resulting @@ -1910,15 +1910,13 @@ static int cna_query_quota(host_config_t *host) /* {{{ */ static int cna_handle_snapvault_data(const char *hostname, /* {{{ */ cfg_snapvault_t *cfg_snapvault, na_elem_t *data, cdtime_t interval) { - na_elem_iter_t status_iter; - - status = na_elem_child(data, "status-list"); - if (!status) { + na_elem_t *status_list = na_elem_child(data, "status-list"); + if (status_list == NULL) { ERROR("netapp plugin: SnapVault status record missing status-list"); return (0); } - status_iter = na_child_iterator(status); + na_elem_iter_t status_iter = na_child_iterator(status_list); for (na_elem_t *status = na_iterator_next(&status_iter); status != NULL; status = na_iterator_next(&status_iter)) { const char *dest_sys, *dest_path, *src_sys, *src_path;