Disk Monitor

#!/usr/bin/perl

use strict;
use warnings;
use Filesys::DiskSpace;

# file system to monitor
my $dir = "/opt";

# warning level
my $warning_level=10;

# email setup
my $to='mail@mail.com';
my $subject='Low Disk Space';

# get df
my ($fs_type, $fs_desc, $used, $avail, $fused, $favail) = df $dir;

# calculate 
my $df_free = (($avail) / ($avail+$used)) * 100.0;

# compare 
if ($df_free < $warning_level) {
my $out = sprintf("WARNING Low Disk Space on $dir : %0.2f%%  ()\n",$df_free);

# send email using UNIX/Linux sendmail
open(MAIL, "|/usr/sbin/sendmail -t");

## Mail Header
print MAIL "To: $to\n";
print MAIL "Subject: $subject\n";

## Mail Body
print MAIL $out;

close(MAIL);
}

--------------------------------------
__________________________________________
I am getting following error by running this script. Any help will be appreciated

>./test2.sh 
Can't locate Filesys/DiskSpace.pm in @INC (@INC contains:  /usr/lib/perl5/5.8.8/s390x-linux-thread-multi /usr/lib/perl5/5.8.8  /usr/lib/perl5/site_perl/5.8.8/s390x-linux-thread-multi  /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl  /usr/lib/perl5/vendor_perl/5.8.8/s390x-linux-thread-multi  /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl .) at  ./test2.sh line 5.
BEGIN failed--compilation aborted  at ./test2.sh line 5.

I commented out "Filesys::DiskSpace"

 		 		 			 			 				 				"Filesys::DiskSpace" 			
		 			 		 		  		   		any  other alternative?

I do not have access to download " Filesys::DiskSpace ".

I commented out this but getting following error now;

Can't call method "df" without a package or object reference at  ./test2.sh line 18.

CPAN module Filesys::DiskSpace is not installed at your system. You have to install it to get this script working.

Else, execute df command and from the output obtained, check how much free disk space is available.