FS Monitoring

::::::::::::: Script to Monitor File system :::::::::::::::

No need to configure any mail server just send a mail/messages using sendEmail..

Download sendEmail Program from below link

http://caspian.dotconf.net/menu/Software/SendEmail/

------------------
Installation
------------------

SendEmail is a perl script/program, and only needs to be copied to a directory
in your path to make it accessible.  Most likely the following steps will
be sufficient:

1) Extract the package
    tar -zxvf sendEmail-v1.XX.tar.gz

2) Copy the sendEmail script to /usr/local/bin
    cp -a sendEmail-v1.XX/sendEmail /usr/local/bin

3) Make sure its executable
    chmod +x /usr/local/bin/sendEmail

4) Run it
    sendEmail
      or
    /usr/local/bin/sendEmail

NOTES:
  * Running sendEmail without any arguments will produce a usage summary.
  * SendEmail is written in Perl, so no compilation is needed.
  * On a Unix/Linux OS if your perl binary is not installed at /usr/bin/perl
    you may need to edit the first line of the script accordingly.

#------------------------------------------------------------------
# Script Starts................
#------------------------------------------------------------------
#!/bin/bash
# Purpose: Disk Space Monitoring
# Author: Ravi Kumar
# Script Start
# Variables #
MAILLIST="aravikumar48@gmail.com"
CRITICAL=95
HOSTNAME=`hostname`
MAIL=sendEmail
PERCENTAGE=`df -hP | egrep '^/dev/' | awk '{ print $6 "_:_" $5 }' | awk -F"_:_" '{ print $2 }' | cut -d'%' -f1 | head -n 1`
PERCENTAGE1=`df -hP | egrep '^/dev/' | awk '{ print $6 "_:_" $5 }' | awk -F"_:_" '{ print $2 }' | cut -d'%' -f1 | tail -1`
BODY=`df -hP | egrep '^/dev/'`

if [ $PERCENTAGE -ge $CRITICAL ];
then
        sendEmail -f alert@gmail.com -t $MAILLIST -u "$HOSTNAME - File System is CRITICAL $PERCENTAGE%" -m $BODY -s MAIL-EXCHANGE.com
elif [ $PERCENTAGE1 -ge $CRITICAL ];
then
        sendEmail -f alert@gmail.com -t $MAILLIST -u "$HOSTNAME - File System is CRITICAL $PERCENTAGE1%" -m $BODY -s MAIL-EXCHANGE.com
else
        echo ""
fi
#END

No comments:

Post a Comment