mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 02:51:03 +00:00
Modified http_request_time to allow specifying a user agent
Similar to other settings for this plugin, there is a new env.urlN_agent setting which allows specifying a user agent
This commit is contained in:
parent
31f64337b6
commit
54c9563274
1 changed files with 9 additions and 0 deletions
|
@ -16,6 +16,7 @@
|
||||||
env.url3_name some_munin_internal_name
|
env.url3_name some_munin_internal_name
|
||||||
env.url3_label Some random page on our website
|
env.url3_label Some random page on our website
|
||||||
env.url3_proxy http://firewall:3128
|
env.url3_proxy http://firewall:3128
|
||||||
|
env.url3_agent Mozilla/5.0
|
||||||
env.timeout 3
|
env.timeout 3
|
||||||
|
|
||||||
Timeout is the timeout of any HTTP request. Tune to avoid a complete
|
Timeout is the timeout of any HTTP request. Tune to avoid a complete
|
||||||
|
@ -70,11 +71,13 @@ for (my $i = 1; $ENV{"url$i"}; $i++)
|
||||||
my $proxy = $ENV{"url${i}_proxy"};
|
my $proxy = $ENV{"url${i}_proxy"};
|
||||||
my $name = $ENV{"url${i}_name"} || clean($url);
|
my $name = $ENV{"url${i}_name"} || clean($url);
|
||||||
my $label = $ENV{"url${i}_label"} || $url;
|
my $label = $ENV{"url${i}_label"} || $url;
|
||||||
|
my $agent = $ENV{"url${i}_agent"};
|
||||||
|
|
||||||
$URLS{$name}={
|
$URLS{$name}={
|
||||||
url=>$url,
|
url=>$url,
|
||||||
proxy=>$proxy,
|
proxy=>$proxy,
|
||||||
label=>$label,
|
label=>$label,
|
||||||
|
agent=>$agent,
|
||||||
time=>'U'
|
time=>'U'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -141,9 +144,15 @@ if ( defined $ARGV[0] and $ARGV[0] eq "config" )
|
||||||
}
|
}
|
||||||
|
|
||||||
my $ua = LWP::UserAgent->new(timeout => $timeout);
|
my $ua = LWP::UserAgent->new(timeout => $timeout);
|
||||||
|
my $defaultAgent = $ua->agent;
|
||||||
foreach my $name (keys %URLS) {
|
foreach my $name (keys %URLS) {
|
||||||
my $url = $URLS{$name};
|
my $url = $URLS{$name};
|
||||||
|
|
||||||
|
if ($url->{agent}) {
|
||||||
|
$ua->agent($url->{agent});
|
||||||
|
} else {
|
||||||
|
$ua->agent($defaultAgent);
|
||||||
|
}
|
||||||
if ($url->{proxy}) {
|
if ($url->{proxy}) {
|
||||||
$ua->proxy(['http', 'ftp'], $url->{proxy});
|
$ua->proxy(['http', 'ftp'], $url->{proxy});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue