From b20df0bde244c3638cbc92ec0a75c88c6aa254be Mon Sep 17 00:00:00 2001 From: Marc Fournier Date: Sat, 4 Apr 2015 22:27:53 +0200 Subject: [PATCH] bind: Add support for specifying a connection timeout --- src/bind.c | 6 ++++++ src/collectd.conf.pod | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/bind.c b/src/bind.c index 59eb2491..c36cf482 100644 --- a/src/bind.c +++ b/src/bind.c @@ -109,6 +109,7 @@ static int global_server_stats = 1; static int global_zone_maint_stats = 1; static int global_resolver_stats = 0; static int global_memory_stats = 1; +static int timeout = -1; static cb_view_t *views = NULL; static size_t views_num = 0; @@ -1695,6 +1696,8 @@ static int bind_config (oconfig_item_t *ci) /* {{{ */ bind_config_add_view (child); else if (strcasecmp ("ParseTime", child->key) == 0) cf_util_get_boolean (child, &config_parse_time); + else if (strcasecmp ("Timeout", child->key) == 0) + cf_util_get_int (child, &timeout); else { WARNING ("bind plugin: Unknown configuration option " @@ -1724,6 +1727,9 @@ static int bind_init (void) /* {{{ */ curl_easy_setopt (curl, CURLOPT_URL, (url != NULL) ? url : BIND_DEFAULT_URL); curl_easy_setopt (curl, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt (curl, CURLOPT_MAXREDIRS, 50L); + curl_easy_setopt (curl, CURLOPT_TIMEOUT_MS, (timeout >= 0) ? + timeout : CDTIME_T_TO_MS(plugin_get_interval())); + return (0); } /* }}} int bind_init */ diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index 07ef54f1..652e3f4b 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -1133,6 +1133,12 @@ Collect global memory statistics. Default: Enabled. +=item B I + +The B option sets the overall timeout for HTTP requests, in +milliseconds. By default, the configured B is used to set the +timeout. + =item B I Collect statistics about a specific I<"view">. BIND can behave different, -- 2.11.0