I wanted to make a more flexible mount point script to use since our environment consists of several different architects with different mount points. This works good by reading the fstab file and mounting accordingly. I just need a flexible way to omit the common mount points like / and /opt…
#!/usr/bin/perl -w
#
# Name: mountCheck.pl
# Written by: brandon.thompson EMC Mortgage
# Usage: ./mountcheck.pl 'mount point 1' 'mount point 2'... or no argsv for defaults
# This script is put in cron on these boxes for monitoring purposes
#
use strict;
my $alert_email='brandon.w.thompson\@jpmorgan.com';
chomp(my $host=`/bin/hostname`);
open(FSTAB,"awk '{print\$2}' /etc/fstab |") or die "Failed: $!\n";
our @mounts=;
close(FSTAB);
foreach my $mount(@mounts){
my $status=`df -hT | egrep -i $mount`;
if(!$status){
`mount $mount`;
system("/bin/logger", "-p", "warn", "Mount Point: $host: $mount is NOT mounted on ". scalar(localtime())."!\n")==0
or die "Can't complete cmd: $!\n";
my $alert=system("/usr/bin/mailx -s 'ALERT! $host: $mount is NOT mounted!' $alert_email /dev/null")==0
or die "Can't complete cmd: $!\n";
# Attempt to mount
}
}