mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
Fix spaces in directory names. Glob directories.
This commit is contained in:
parent
d5fc30a9bf
commit
5fcad70008
1 changed files with 14 additions and 2 deletions
|
@ -21,6 +21,8 @@
|
|||
# You can test this plugin by calling it with params "test" and your watchdirs:
|
||||
# ./dirsizes test /dir1,/tmp/dir2
|
||||
#
|
||||
# The directories can contain wildcards that are automatically expanded.
|
||||
#
|
||||
#
|
||||
##############################################################################
|
||||
#
|
||||
|
@ -45,6 +47,17 @@ else {
|
|||
@watchdirs = split( ",", $ENV{"watchdirs"} );
|
||||
}
|
||||
|
||||
# Glob all of the watchdirs.
|
||||
my @globbed_watchdirs;
|
||||
foreach my $watchdir ( @watchdirs )
|
||||
{
|
||||
foreach my $expanded_dir ( glob( $watchdir ) )
|
||||
{
|
||||
push @globbed_watchdirs, $expanded_dir;
|
||||
}
|
||||
}
|
||||
@watchdirs = @globbed_watchdirs;
|
||||
|
||||
# Config or read request?
|
||||
if ( exists $ARGV[0] and $ARGV[0] eq "config" ) {
|
||||
|
||||
|
@ -88,9 +101,8 @@ sub getSize {
|
|||
my ($dir) = @_;
|
||||
|
||||
# Get the size via `du`
|
||||
my @dirsize = split( ' ', `du -cb $dir | grep "total" | tail -1 ` );
|
||||
my @dirsize = split( ' ', `du -cb "$dir" | grep "total" | tail -1 ` );
|
||||
return @dirsize[0];
|
||||
}
|
||||
|
||||
exit 0;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue