use strict; use Mail::Send; use Filesys::DiskFree; # This will check all mounted volumes, both local and NFS, # and send separate email reports listing the ones over # 90% full and the ones over 70% full. my $fs = new Filesys::DiskFree; $fs->df(); my @vols = sort $fs->disks(); my ( $yellowFlag, $redFlag ); for my $vol ( @vols ) { my $dev = $fs->device( $vol ); next unless ( $fs->total( $dev ); # some solaris vols may be 0 my $pct_used = $fs->used( $dev ) / $fs->total( $dev ); $yellowFlag .= "$vol ($dev) is over 70% full\n" if ( $pct_used > 0.7 ); $redFlag .= "$vol ($dev) is over 90% full\n" if ( $pct_used > 0.9 ); } if ( $yellowFlag or $redFlag ) { my $msg = new Mail::Send; if ( $yellowFlag ) { $msg->to( 'bureaucrat@my.org' ); $msg->subject( 'Time to buy more disk!' ); my $fh = $msg->open; print $fh $yellowFlag; $fh->close; } if ( $redFlag ) { $msg->to( 'sysadmin@my.org' ); $msg->subject( 'Time to rattle some cages!' ); my $fh = $msg->open; print $fh $redFlag; $fh->close; } }