1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-22 02:51:03 +00:00

[http_load_] Filter <link> based on rel, and <meta>

Signed-off-by: Olivier Mehani <shtrom@ssji.net>
This commit is contained in:
Olivier Mehani 2017-06-13 22:31:55 +10:00
parent cb2a0e6488
commit 1ee2a115f7

View file

@ -146,6 +146,13 @@ sub filter{
# status=1 => do download (default) # status=1 => do download (default)
# status=0 => do not download # status=0 => do not download
# For links, the 'rel' is more relevant that the 'src' attribute
if("$tag" =~ /^link/){
$status=0;
if("$tag" =~ /stylesheet$/){
$status=1;
}
}
if("$tag" eq "form action"){ if("$tag" eq "form action"){
$status=0; $status=0;
} }
@ -155,6 +162,9 @@ sub filter{
if("$tag" eq "area href"){ if("$tag" eq "area href"){
$status=0; $status=0;
} }
if("$tag" eq "meta content"){
$status=0;
}
return $status; return $status;
} }
@ -294,6 +304,8 @@ if($ARGV[0] and $ARGV[0] eq "autoconf") {
$output{"response_" . $host . "_" . $response->code}+=1; $output{"response_" . $host . "_" . $response->code}+=1;
$output{"type_" . $response->content_type}+=1; $output{"type_" . $response->content_type}+=1;
# For <link />s, also capture the rel attribute
$HTML::Tagset::linkElements{'link'} = [ qw( href rel ) ];
$page_parser = HTML::LinkExtor->new(undef, $url); $page_parser = HTML::LinkExtor->new(undef, $url);
$page_parser->parse($contents)->eof; $page_parser->parse($contents)->eof;
my @links = $page_parser->links; my @links = $page_parser->links;
@ -301,8 +313,13 @@ if($ARGV[0] and $ARGV[0] eq "autoconf") {
%res=(); %res=();
foreach $link (@links){ foreach $link (@links){
my $tag=$$link[0] . " " . $$link[1]; my $tag;
my($t, %attrs) = @{$link};
if ($attrs{rel} =~ /.*\/([^\/]+)/) {
$tag=$$link[0] . " " . $1;
} else {
$tag=$$link[0] . " " . $$link[1];
}
$output{"tags_" . $$link[0] . "-" . $$link[1]}+=1; $output{"tags_" . $$link[0] . "-" . $$link[1]}+=1;
if(filter($tag)){ if(filter($tag)){