From 879686e59c12fc893aef4f6e82c44282825f029d Mon Sep 17 00:00:00 2001 From: Nicolas Joyard Date: Fri, 17 Feb 2017 09:54:23 +0100 Subject: [PATCH] dirsizes: use clean_fieldnames --- plugins/disk/dirsizes | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) 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;