1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-25 02:18:08 +00:00

Whitespace cleanup

* remove trailing whitespace
* remove empty lines at the end of files
This commit is contained in:
Lars Kruse 2018-08-02 02:03:42 +02:00
parent ef851f0c34
commit 17f784270a
604 changed files with 2927 additions and 2945 deletions

View file

@ -39,7 +39,7 @@
#
# Change log
# v1.0.0 2008-07-21 Chris Hastie
# initial release
# initial release
#
# v1.1.0 2010-12-07 Uffe Norberg
# - Changed default statedir to /var/lib/munin/plugin-state (Debian default)
@ -107,7 +107,7 @@ open(SERVICE, "$COMMAND |")
while (<SERVICE>) {
if (/^[-+*#](\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(\s+\S+){7}\s+(\S+)/) {
my $name = &lookupname($1);
$peers{$1}{'value'} = $3;
$peers{$1}{'value'} = $3;
}
}
close(SERVICE);
@ -140,7 +140,7 @@ foreach my $peer (keys %peers) {
# save list of peer IPs and hostnames
if(-l $statefile) {
die("$statefile is a symbolic link, refusing to touch it.");
}
}
open (OUT, ">$statefile") or exit 4;
foreach my $i (keys %peers) {
print OUT "$i:" . $peers{$i}{'name'} . "\n";
@ -155,12 +155,12 @@ sub by_name {
# create a valid munin field name from the hostname
sub sanitize_field () {
my $field = shift;
# replace illegal characters with an underscore
$field =~ s/[^A-Za-z0-9_]/_/g;
# prepend an underscore if name starts with a number
$field =~ s/^([^A-Za-z_])/_$1/;
# truncate to 19 characters
if (length($field) > 19) {
$field = substr($field, 0, 19);
@ -181,11 +181,11 @@ sub lookupname () {
my $ip = shift;
# have we already got it?
if ($peers{$ip}{'name'}) {
return $peers{$ip}{'name'};
return $peers{$ip}{'name'};
}
# else look it up
my $iaddr = inet_aton($ip);
my $name = gethostbyaddr($iaddr, AF_INET) || $ip;
my $iaddr = inet_aton($ip);
my $name = gethostbyaddr($iaddr, AF_INET) || $ip;
# add to cache
$peers{$ip}{'name'} = $name;
return $name;