From: Florian Forster Date: Thu, 11 Aug 2016 15:10:13 +0000 (+0200) Subject: Merge remote-tracking branch 'github/pr/1530' X-Git-Tag: collectd-5.6.0~57 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=08cf386cb8aa711ef4043d9139d464b38188a44b;hp=8d8d888262e8cc375266ae1fdba03314dbd9149c;p=collectd.git Merge remote-tracking branch 'github/pr/1530' --- diff --git a/.gitignore b/.gitignore index b85dc48a..8154d733 100644 --- a/.gitignore +++ b/.gitignore @@ -84,6 +84,9 @@ bindings/java/org/collectd/java/*.class #ide stuff .vscode +# cscope stuff +cscope.* + # Unit tests src/daemon/test-suite.log src/tests/ diff --git a/configure.ac b/configure.ac index 1bacddd1..44351937 100644 --- a/configure.ac +++ b/configure.ac @@ -2376,7 +2376,7 @@ if test "x$with_libgrpcpp" = "xyes" then AC_LANG_PUSH(C++) SAVE_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$with_libgrpcpp_cppflags $GRPCPP_CFLAGS $CPPFLAGS -std=c++11" + CPPFLAGS="-std=c++11 $with_libgrpcpp_cppflags $GRPCPP_CFLAGS $CPPFLAGS" AC_CHECK_HEADERS([grpc++/grpc++.h], [], [with_libgrpcpp="no ( not found)"] ) @@ -2386,8 +2386,10 @@ fi if test "x$with_libgrpcpp" = "xyes" then AC_LANG_PUSH(C++) + SAVE_CPPFLAGS="$CPPFLAGS" SAVE_LDFLAGS="$LDFLAGS" SAVE_LIBS="$LIBS" + CPPFLAGS="-std=c++11 $with_libgrpcpp_cppflags $GRPCPP_CFLAGS $CPPFLAGS" LDFLAGS="$with_libgrpcpp_ldflags" if test "x$GRPCPP_LIBS" = "x" then @@ -2409,6 +2411,7 @@ then ], [with_libgrpcpp="no (libgrpc++ not found)"] ) + CPPFLAGS="$SAVE_CPPFLAGS" LDFLAGS="$SAVE_LDFLAGS" LIBS="$SAVE_LIBS" AC_LANG_POP(C++) diff --git a/src/chrony.c b/src/chrony.c index 0485036a..f6294e49 100644 --- a/src/chrony.c +++ b/src/chrony.c @@ -452,8 +452,8 @@ chrony_connect(void) if (chrony_set_timeout()) { - ERROR(PLUGIN_NAME ": Error setting timeout to %lds. Errno = %d", - g_chrony_timeout, errno); + ERROR(PLUGIN_NAME ": Error setting timeout to %llds. Errno = %d", + (long long)g_chrony_timeout, errno); return CHRONY_RC_FAIL; } return CHRONY_RC_OK; diff --git a/src/daemon/common.c b/src/daemon/common.c index 14503525..45f9d533 100644 --- a/src/daemon/common.c +++ b/src/daemon/common.c @@ -1572,8 +1572,6 @@ void set_sock_opts (int sockfd) /* {{{ */ socklen_t socklen = sizeof (socklen_t); int so_keepalive = 1; - int tcp_keepidle = ((CDTIME_T_TO_MS(plugin_get_interval()) - 1) / 100 + 1); - int tcp_keepintvl = ((CDTIME_T_TO_MS(plugin_get_interval()) - 1) / 1000 + 1); status = getsockopt (sockfd, SOL_SOCKET, SO_TYPE, &socktype, &socklen); if (status != 0) @@ -1590,6 +1588,7 @@ void set_sock_opts (int sockfd) /* {{{ */ WARNING ("set_sock_opts: failed to set socket keepalive flag"); #ifdef TCP_KEEPIDLE + int tcp_keepidle = ((CDTIME_T_TO_MS(plugin_get_interval()) - 1) / 100 + 1); status = setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPIDLE, &tcp_keepidle, sizeof (tcp_keepidle)); if (status != 0) @@ -1597,6 +1596,7 @@ void set_sock_opts (int sockfd) /* {{{ */ #endif #ifdef TCP_KEEPINTVL + int tcp_keepintvl = ((CDTIME_T_TO_MS(plugin_get_interval()) - 1) / 1000 + 1); status = setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPINTVL, &tcp_keepintvl, sizeof (tcp_keepintvl)); if (status != 0) diff --git a/src/swap.c b/src/swap.c index 15eca9aa..9c63e9bb 100644 --- a/src/swap.c +++ b/src/swap.c @@ -674,6 +674,7 @@ static int swap_read (void) /* {{{ */ { ERROR ("swap plugin: Total swap space (%g) is less than used swap space (%g).", total, used); + sfree (swap_entries); return (-1); } diff --git a/src/utils_latency.c b/src/utils_latency.c index bfb9292c..c67752a3 100644 --- a/src/utils_latency.c +++ b/src/utils_latency.c @@ -125,8 +125,8 @@ latency_counter_t *latency_counter_create (void) /* {{{ */ if (lc == NULL) return (NULL); - latency_counter_reset (lc); lc->bin_width = HISTOGRAM_DEFAULT_BIN_WIDTH; + latency_counter_reset (lc); return (lc); } /* }}} latency_counter_t *latency_counter_create */ @@ -175,6 +175,28 @@ void latency_counter_reset (latency_counter_t *lc) /* {{{ */ return; cdtime_t bin_width = lc->bin_width; + cdtime_t max_bin = (lc->max - 1) / lc->bin_width; + +/* + If max latency is REDUCE_THRESHOLD times less than histogram's range, + then cut it in half. REDUCE_THRESHOLD must be >= 2. + Value of 4 is selected to reduce frequent changes of bin width. +*/ +#define REDUCE_THRESHOLD 4 + if ((lc->num > 0) && (lc->bin_width >= HISTOGRAM_DEFAULT_BIN_WIDTH * 2) + && (max_bin < HISTOGRAM_NUM_BINS / REDUCE_THRESHOLD)) + { + /* new bin width will be the previous power of 2 */ + bin_width = bin_width / 2; + + DEBUG("utils_latency: latency_counter_reset: max_latency = %.3f; " + "max_bin = %"PRIu64"; old_bin_width = %.3f; new_bin_width = %.3f;", + CDTIME_T_TO_DOUBLE (lc->max), + max_bin, + CDTIME_T_TO_DOUBLE (lc->bin_width), + CDTIME_T_TO_DOUBLE (bin_width)); + } + memset (lc, 0, sizeof (*lc)); /* preserve bin width */ diff --git a/src/write_sensu.c b/src/write_sensu.c index 77069c08..6cb49943 100644 --- a/src/write_sensu.c +++ b/src/write_sensu.c @@ -532,7 +532,7 @@ static char *sensu_value_to_json(struct sensu_host const *host, /* {{{ */ in_place_replace_sensu_name_reserved(service_buffer); // finalize the buffer by setting the output and closing curly bracket - res = my_asprintf(&temp_str, "%s, \"output\": \"%s %s %ld\"}\n", ret_str, service_buffer, value_str, CDTIME_T_TO_TIME_T(vl->time)); + res = my_asprintf(&temp_str, "%s, \"output\": \"%s %s %lld\"}\n",ret_str, service_buffer, value_str, (long long)CDTIME_T_TO_TIME_T(vl->time)); free(ret_str); free(value_str); if (res == -1) { @@ -668,7 +668,7 @@ static char *sensu_notification_to_json(struct sensu_host *host, /* {{{ */ ret_str = temp_str; // incorporate the timestamp - res = my_asprintf(&temp_str, "%s, \"timestamp\": %ld", ret_str, CDTIME_T_TO_TIME_T(n->time)); + res = my_asprintf(&temp_str, "%s, \"timestamp\": %lld", ret_str, (long long)CDTIME_T_TO_TIME_T(n->time)); free(ret_str); if (res == -1) { ERROR("write_sensu plugin: Unable to alloc memory");