2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00

Merge pull request #792 from shtrom/http_load_-fix-long-domains

Http load  fix long domains
This commit is contained in:
sumpfralle 2017-01-08 02:44:09 +01:00 committed by GitHub
commit 07428a0137

View File

@ -170,15 +170,24 @@ sub get_cache_file_name{
return $file;
}
# Get fieldname (making sure it is munin "compatible" as a fieldname)
# Get fieldname (making sure it is munin-1.0 "compatible" as a fieldname)
# 1. Remove all non-word characters from a string)
# 2. Make sure it has maximum 19 characters
# 2.1 If not, truncate the host part, while keeping anything after an underscore (e.g., HTTP response status)
sub get_fieldname{
my $url=$_[0];
$url =~ s/\W//g;
if(length($url) > 19){
$url =~ s/(\S+)_(\S+)/ /g;
my $host = $1;
my $info = $2;
my $suffixlength = length($info) + 1;
if ($suffixlength > 1) {
$url = substr($host, 0, 19 - $suffixlength) . '_' . $info;
} else {
$url = substr($url, 0, 19);
}
}
return $url;
}