summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f03005b)
raw | patch | inline | side by side (parent: f03005b)
author | Jan Kundrát <jan.kundrat@cesnet.cz> | |
Sat, 21 Feb 2015 15:12:27 +0000 (16:12 +0100) | ||
committer | Jan Kundrát <jan.kundrat@cesnet.cz> | |
Wed, 1 Apr 2015 16:17:09 +0000 (18:17 +0200) |
src/collectd.conf.pod | patch | blob | history | |
src/curl.c | patch | blob | history |
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index bd7810748e1111b6a13456c0eb5e3ee0fb19b347..788ffd454f2c74b489378f81c01db4b8f8a8d663 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
B<MeasureResponseCode> options are set to B<true>, B<Match> blocks are
optional.
+=item B<Timeout> I<Timeout in miliseconds>
+
+The B<Timeout> option sets the overall timeout for each request. Make sure that
+collectd is configured with enough C<ReadThreads>, otherwise an overly long
+timeout could block other plugins. By default or when set to B<0>, a timeout
+equal to the B<Interval> is used. Prior to version 5.5.0, there was no timeout
+and requests might hang indefinitely.
+
=back
=head2 Plugin C<curl_json>
diff --git a/src/curl.c b/src/curl.c
index 0e5d2cfa7ea0a1dca1fab6f00780773bc1f07b8e..503153913052b2943ad1451d2d95439be1f48160 100644 (file)
--- a/src/curl.c
+++ b/src/curl.c
char *post_body;
_Bool response_time;
_Bool response_code;
+ int timeout;
CURL *curl;
char curl_errbuf[CURL_ERROR_SIZE];
curl_easy_setopt (wp->curl, CURLOPT_HTTPHEADER, wp->headers);
if (wp->post_body != NULL)
curl_easy_setopt (wp->curl, CURLOPT_POSTFIELDS, wp->post_body);
+ curl_easy_setopt (wp->curl, CURLOPT_TIMEOUT_MS, wp->timeout > 0 ? wp->timeout : cf_get_default_interval ());
return (0);
} /* }}} int cc_page_init_curl */
page->verify_host = 1;
page->response_time = 0;
page->response_code = 0;
+ page->timeout = 0;
page->instance = strdup (ci->values[0].value.string);
if (page->instance == NULL)
status = cc_config_append_string ("Header", &page->headers, child);
else if (strcasecmp ("Post", child->key) == 0)
status = cf_util_get_string (child, &page->post_body);
+ else if (strcasecmp ("Timeout", child->key) == 0)
+ status = cf_util_get_int (child, &page->timeout);
else
{
WARNING ("curl plugin: Option `%s' not allowed here.", child->key);