Create disk space alerts
#!/usr/bin/perl
use Term::ANSIColor;
####TIME DETAILS ######
print colored ( "PLEASE SPECIFY HOURS FOR THE FILESIZEREPORT TO RUN \n", ' bold green on_blue' );
$hrstorun = ;
chomp ($hrstorun);
print colored ( "PLEASE SPECIFY INTERVAL (min) FOR THE FILESIZEREPORT TO RUN \n", ' bold green on_blue' );
$intmin = ;
chomp ($intmin);
####END TIME #####
$count = $hrstorun*60/$intmin;
$interval = $intmin*60;
#print "Free Space ";
for ($c=0; $c < $count; $c++ )
{
sleep $interval;
&frespacetest;
$Free = FreeSpace;
select undef, undef, undef, 0.25;
print "\r";
printf ("%10s%20s",$Free ,$frsp );
}
}
###SUBROUTINES ###
{
sub frespacetest
{
$x = `dfoutputscript `;
@freesp = split(' ',$x);
$frsp = ("%s\n",$freesp[3]);
if ( $frsp <>
{
print " FREE SPACE IS BELOW THRESHOLD\n"; ##SEND MAIL OR ALERT##
}
if (!$frspini)
{
$frspini = $frsp;
}
else
{
$frspfinal = $frsp;
if ($frspini > $frspfinal)
{
$deltafrsp = $frspini - $frspfinal;
$frspini = $frspfinal;
if ( $deltafrsp > 1 )
{
print "FREE SPACE DECREASING AT HIGH RATE \n";##SEND MAIL OR ALERT##
}
}
}
}
}
|