It seems like the simplest way to modify the script is to take the body of the for loop and create a function that takes a filesystem name and a threshold value as parameters. Then create a second list of file systems and add a second loop for that list using the higher threshold.
Something like the following:
Code:
...
my $mnt_threshold = 95;
@mnt_fs ( '/mnt/backup_1', '/mnt/backup_2');
process_fs {
my($fs, $threshold) = @_; #subroutine parameters
undef @new_files;
undef @big_files;
@lines = `df -k $fs`;
$lines[ -1 ] =~ /(\d+)\%/;
... # The rest of the for loop
}
foreach my $fs ( @fs ) {
process_fs ($fs, $threshold);
}
foreach my $mnt_fs ( @fs ) {
process_fs ($fs, $mnt_threshold);
}
To not remove the log file then remove the unlink command the script, but you need to put in place some way to clean up the log files, even if it is to say someone needs to delete the log file after it is read.
As far as sending the email. A quick google of "perl email" will provide lots of ways to do it.