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 strict;
use Munin::Plugin;
my @watchdirs; my @watchdirs;
if ( exists $ARGV[0] and $ARGV[0] eq "test" ) { 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) { foreach my $dir (@watchdirs) {
# Remove illegal characters # Remove illegal characters
my $label = $dir; my $label = clean_fieldname($dir);
$label =~ s@[\/-]@_@g;
# Print name # Print name
print "dir", $label, ".label ", $dir, "\n"; print "dir", $label, ".label ", $dir, "\n";
@ -72,17 +72,12 @@ else {
# All available directories # All available directories
foreach my $dir (@watchdirs) { foreach my $dir (@watchdirs) {
# Remove illegal characters # Remove illegal characters
my $label = $dir; my $label = clean_fieldname($dir);
$label =~ s@[\/-]@_@g;
# Get the dirsize # Get the dirsize
my $dirsize = getSize($dir); my $dirsize = getSize($dir);
# Get the label
my $label = niceLabelname($dir);
# Print name # Print name
print "dir", $label, ".value ", $dirsize, ".0\n"; print "dir", $label, ".value ", $dirsize, ".0\n";
} }
@ -97,13 +92,5 @@ sub getSize {
return @dirsize[0]; return @dirsize[0];
} }
# Remove illegal characters
sub niceLabelname {
my ($label) = @_;
$label =~ s@[\/-]@_@g;
return $label;
}
exit 0; exit 0;