Projet

Général

Profil

Révision ec0df071

IDec0df0719dbd744d2687f86a49c90f19aead95a4
Parent 2bb6892e
Enfant 07428a01

Ajouté par Olivier Mehani il y a presque 9 ans

[http_load_] Fix issue with long domain name

Munin 1.0 supports fieldnames of at most 19 characters. For domain names
longer than that, this plugin simply truncate the names in its own cache
down to 19.

This creates an issue with the `response` graph, which appends the HTTP
status code to the hostname to make multiple variables. Truncating to
this string loses this information, leading to an empty graph.

Signed-off-by: Olivier Mehani <>

Voir les différences:

plugins/http/http_load_
170 170
	return $file;
171 171
}
172 172

  
173
# Get fieldname (making sure it is munin "compatible" as a fieldname)
173
# Get fieldname (making sure it is munin-1.0 "compatible" as a fieldname)
174 174
# 1. Remove all non-word characters from a string)
175 175
# 2. Make sure it has maximum 19 characters
176
#    2.1 If not, truncate the host part, while keeping anything after an underscore (e.g., HTTP response status)
176 177
sub get_fieldname{
177 178
	my $url=$_[0];
178 179
	$url =~ s/\W//g;
179 180
	if(length($url) > 19){
180
		$url =  substr($url, 0, 19);
181
		$url =~ s/(\S+)_(\S+)/ /g;
182
		my $host = $1;
183
		my $info = $2;
184
		my $suffixlength = length($info) + 1;
185
		if ($suffixlength > 1) {
186
			$url = substr($host, 0, 19 - $suffixlength) . '_' . $info;
187
		} else {
188
			$url = substr($url, 0, 19);
189
		}
181 190
	}
182 191
	return $url;
183 192
}

Formats disponibles : Unified diff