mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-09-19 00:53:19 +00:00
Merge pull request #345 from anarcat/http_request_time_timeout
Http request time timeout
This commit is contained in:
commit
0c47fcafc0
1 changed files with 6 additions and 2 deletions
|
@ -56,6 +56,10 @@ if (! eval "require LWP::UserAgent;")
|
||||||
|
|
||||||
my %URLS;
|
my %URLS;
|
||||||
|
|
||||||
|
# timeout in seconds for requests
|
||||||
|
# slightly lower than the default global timeout (5 seconds)
|
||||||
|
my $timeout = $ENV{'timeout'} || 3;
|
||||||
|
|
||||||
for (my $i = 1; $ENV{"url$i"}; $i++)
|
for (my $i = 1; $ENV{"url$i"}; $i++)
|
||||||
{
|
{
|
||||||
my $url = $ENV{"url$i"};
|
my $url = $ENV{"url$i"};
|
||||||
|
@ -79,7 +83,7 @@ if ( defined $ARGV[0] and $ARGV[0] eq "autoconf" )
|
||||||
exit 0;
|
exit 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $ua = LWP::UserAgent->new(timeout => 30);
|
my $ua = LWP::UserAgent->new(timeout => $timeout);
|
||||||
|
|
||||||
foreach my $url (keys %URLS) {
|
foreach my $url (keys %URLS) {
|
||||||
my $response = $ua->request(HTTP::Request->new('GET',$url));
|
my $response = $ua->request(HTTP::Request->new('GET',$url));
|
||||||
|
@ -132,7 +136,7 @@ if ( defined $ARGV[0] and $ARGV[0] eq "config" )
|
||||||
exit 0;
|
exit 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $ua = LWP::UserAgent->new(timeout => 15);
|
my $ua = LWP::UserAgent->new(timeout => $timeout);
|
||||||
foreach my $name (keys %URLS) {
|
foreach my $name (keys %URLS) {
|
||||||
my $url = $URLS{$name};
|
my $url = $URLS{$name};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue