Send Email When Mount Point Down Linux

Send Email When Mount Point Down Linux

Send Email When Mount Point Down Linux

This is a beautiful script that checks if a mount point in /mnt is available or not, and then can be highly customized to your environment.

Assumptions:

  • mount points are in /mnt
  • you have a separate script that sends an email from your Linux Server
  • you know how to schedule a cron job

Here’s what we have:

#!/bin/sh
# Created By Zwiegnet Linux Admins 6/8/2013

# Variables
time=`date +%T`
date=`date +%F`
logdir=/var/log

###########################
# Check NFS Mount if/then #
###########################

if grep -qs ‘/mnt/NFS’ /proc/mounts; then
    echo “It’s mounted.”
else
    echo “/mnt/NFS not mounted!”
    echo “/mnt/NFS offline $date at $time!” >> $logdir/messages
    
fi

Basically this script is a if/else script that checks to see if  the mount point is available. If not, it writes the mount point name/date/time into the messages log (this is also where you append your email script after the 3rd echo in the script

That’s it! Happy Scripting!

To get a hosted Linux server visit www.zwiegnet.com/go to get started today!

Related guides: Send Email Script CentOS | input/output error from NFS client on CentOS

Leave a Reply

Your email address will not be published. Required fields are marked *