use Win32::AdminMisc;
use Mail::Sendmail;
use strict;
my ($total, $free, %mail,
$machine, $drive, $low,
$to, $from, # Email addresses
);
$machine = 'DBSQL01';
$drive = "c:/";
$low = 50000000; # 50MB
$to = 'notify@address.com';
$from = "$machine\@address.com";
my $VERSION = 0.1;
while (sleep 43200) { # Check every 12 hours
($total, $free) = Win32::AdminMisc::GetDriveSpace($drive);
print "$free bytes remaining\n";
if ($free < $low) {
%mail = (To => $to,
From => $from,
Subject => "$machine low on disk space",
Message => "$machine is low on disk space again.
($free bytes remaining.)"
);
sendmail(%mail) or die $Mail::Sendmail::error;
} # End if;
} # Wend
source: http://www.rcbowen.com/imho/perl/disklow
No comments:
Post a Comment