1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 18:41:03 +00:00

dirsizes: use clean_fieldnames

This commit is contained in:
Nicolas Joyard 2017-02-17 09:54:23 +01:00
parent 9c5d4d673c
commit 879686e59c
No known key found for this signature in database
GPG key ID: 3C695D76B2DF66AA

View file

@ -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;