diff --git a/plugins/disk/dirsizes b/plugins/disk/dirsizes index a0c57dda..8630191c 100755 --- a/plugins/disk/dirsizes +++ b/plugins/disk/dirsizes @@ -26,6 +26,7 @@ # use strict; +use Munin::Plugin; my @watchdirs; if ( exists $ARGV[0] and $ARGV[0] eq "test" ) { @@ -59,8 +60,7 @@ if ( exists $ARGV[0] and $ARGV[0] eq "config" ) { foreach my $dir (@watchdirs) { # Remove illegal characters - my $label = $dir; - $label =~ s@[\/-]@_@g; + my $label = clean_fieldname($dir); # Print name print "dir", $label, ".label ", $dir, "\n"; @@ -72,17 +72,12 @@ else { # All available directories foreach my $dir (@watchdirs) { - # Remove illegal characters - my $label = $dir; - $label =~ s@[\/-]@_@g; + my $label = clean_fieldname($dir); # Get the dirsize my $dirsize = getSize($dir); - # Get the label - my $label = niceLabelname($dir); - # Print name print "dir", $label, ".value ", $dirsize, ".0\n"; } @@ -97,13 +92,5 @@ sub getSize { return @dirsize[0]; } -# Remove illegal characters -sub niceLabelname { - my ($label) = @_; - - $label =~ s@[\/-]@_@g; - return $label; -} - exit 0;