in reply to Partition monitor, aka, I told you it was ugly
use strict; use Mail::Send; use Sys::Hostname; my $MAX = 50; my $dir = shift || '/usr'; my $to = 'foo@bar.com'; my $body; open(DF, "df -k $dir | ") or die; $body .= $_ while <DF>; my ($perc) = $body =~ /(\d+)%/; close DF; exit if $perc < $MAX; my $msg = new Mail::Send Subject => 'df alarm', To => $to; my $fh = $msg->open; print $fh "Disk uskagage for $dir on ", hostname(), "\n"; print $fh $body; $fh->close;
I played around with Filesys::DiskSpace, but it does not return the percentage left. I decided to open a pipe to the 'df' command instead of doing the math. Besides, this is Perl, not C. :)
Jeff
R-R-R--R-R-R--R-R-R--R-R-R--R-R-R--
L-L--L-L--L-L--L-L--L-L--L-L--L-L--
|
|---|