From 2ae2cd69241f46cdb99bc0f7dd6fb365bd99325e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= Date: Tue, 9 Jul 2013 17:13:46 -0400 Subject: [PATCH 1/2] make timeouts customizable --- plugins/http/http_request_time | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/http/http_request_time b/plugins/http/http_request_time index 8ecd774d..2f9d3a5c 100755 --- a/plugins/http/http_request_time +++ b/plugins/http/http_request_time @@ -56,6 +56,9 @@ if (! eval "require LWP::UserAgent;") my %URLS; +# timeout in seconds for requests +my $timeout = $ENV{'timeout'} || 15; + for (my $i = 1; $ENV{"url$i"}; $i++) { my $url = $ENV{"url$i"}; @@ -79,7 +82,7 @@ if ( defined $ARGV[0] and $ARGV[0] eq "autoconf" ) exit 0; } - my $ua = LWP::UserAgent->new(timeout => 30); + my $ua = LWP::UserAgent->new(timeout => $timeout); foreach my $url (keys %URLS) { my $response = $ua->request(HTTP::Request->new('GET',$url)); @@ -132,7 +135,7 @@ if ( defined $ARGV[0] and $ARGV[0] eq "config" ) exit 0; } -my $ua = LWP::UserAgent->new(timeout => 15); +my $ua = LWP::UserAgent->new(timeout => $timeout); foreach my $name (keys %URLS) { my $url = $URLS{$name}; From 6994c89d817771bc1abda178ba8585a37ee0dac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= Date: Tue, 9 Jul 2013 17:14:20 -0400 Subject: [PATCH 2/2] lower the timeout to respect the default munin timeout --- plugins/http/http_request_time | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/http/http_request_time b/plugins/http/http_request_time index 2f9d3a5c..2b9b1b9d 100755 --- a/plugins/http/http_request_time +++ b/plugins/http/http_request_time @@ -57,7 +57,8 @@ if (! eval "require LWP::UserAgent;") my %URLS; # timeout in seconds for requests -my $timeout = $ENV{'timeout'} || 15; +# slightly lower than the default global timeout (5 seconds) +my $timeout = $ENV{'timeout'} || 3; for (my $i = 1; $ENV{"url$i"}; $i++) {