Révision 879686e5
dirsizes: use clean_fieldnames
| plugins/disk/dirsizes | ||
|---|---|---|
| 26 | 26 |
# |
| 27 | 27 |
|
| 28 | 28 |
use strict; |
| 29 |
use Munin::Plugin; |
|
| 29 | 30 |
my @watchdirs; |
| 30 | 31 |
|
| 31 | 32 |
if ( exists $ARGV[0] and $ARGV[0] eq "test" ) {
|
| ... | ... | |
| 59 | 60 |
foreach my $dir (@watchdirs) {
|
| 60 | 61 |
|
| 61 | 62 |
# Remove illegal characters |
| 62 |
my $label = $dir; |
|
| 63 |
$label =~ s@[\/-]@_@g; |
|
| 63 |
my $label = clean_fieldname($dir); |
|
| 64 | 64 |
|
| 65 | 65 |
# Print name |
| 66 | 66 |
print "dir", $label, ".label ", $dir, "\n"; |
| ... | ... | |
| 72 | 72 |
|
| 73 | 73 |
# All available directories |
| 74 | 74 |
foreach my $dir (@watchdirs) {
|
| 75 |
|
|
| 76 | 75 |
# Remove illegal characters |
| 77 |
my $label = $dir; |
|
| 78 |
$label =~ s@[\/-]@_@g; |
|
| 76 |
my $label = clean_fieldname($dir); |
|
| 79 | 77 |
|
| 80 | 78 |
# Get the dirsize |
| 81 | 79 |
my $dirsize = getSize($dir); |
| 82 | 80 |
|
| 83 |
# Get the label |
|
| 84 |
my $label = niceLabelname($dir); |
|
| 85 |
|
|
| 86 | 81 |
# Print name |
| 87 | 82 |
print "dir", $label, ".value ", $dirsize, ".0\n"; |
| 88 | 83 |
} |
| ... | ... | |
| 97 | 92 |
return @dirsize[0]; |
| 98 | 93 |
} |
| 99 | 94 |
|
| 100 |
# Remove illegal characters |
|
| 101 |
sub niceLabelname {
|
|
| 102 |
my ($label) = @_; |
|
| 103 |
|
|
| 104 |
$label =~ s@[\/-]@_@g; |
|
| 105 |
return $label; |
|
| 106 |
} |
|
| 107 |
|
|
| 108 | 95 |
exit 0; |
| 109 | 96 |
|
Formats disponibles : Unified diff