Saturday, 5 July 2014

file system checking script

#!/usr/bin/bash
#########################################
######### Chittibabu Generated SCRIPT########
######### FILE SYSTEM CHECK##############
##VERSION=1.0############################
##DESIGN&IMPLEMENTED:CHITTIBABU MIRIYALA#
##TESED BY :MAHESH KUMAR#################
#########################################
Node=`uname -n`
echo "From:chittibabu.miriyala@gmail.com" >"/tmp/output1"
echo "To:chittibabu.miriyala@gmail.com">>"/tmp/output1"
#Reply-To:chittibabu.miriyala@gmail.com
echo "Subject:Filesystem Space Check : $Node">>"/tmp/output1"
echo "Content-type: text/html">>"/tmp/output1"
echo "<html>">>"/tmp/output1"
echo "<body>">>"/tmp/output1"
echo "<table width=100%>">>"/tmp/output1"
echo "<tr BGCOLOR="#FFFF00"><td colspan="6"> <h1> $Node</h1> </td></tr>">>"/tmp/output1"
#echo "<tr> `cat /etc/hosts|grep `hostname`|grep -v "#"`">>"/tmp/output1"
#echo "</tr>
FS=`df -h |grep -v Filesystem |awk '{print $6}'`
for i in `echo $FS`
do
##[[`df -h $i|grep -v Filesystem|awk '{print $5}'` -le 50]]&& echo "les 50" || echo "gre 50"
if [ `df -h $i|grep -v Filesystem|awk '{print $5}'|tr -d %` -le 50 ]
then
        echo "<TR BGCOLOR="#00FF00">">>"/tmp/output1"
        f=`df -h $i|grep -v Filesystem`
        for y in `echo $f`
        do
        echo "<td> $y</td>">>"/tmp/output1"
        done
        echo "</tr>">>"/tmp/output1"
else
        echo "<TR BGCOLOR="#FF0000">">>"/tmp/output1"
        f=`df -h $i|grep -v Filesystem`
        for y in `echo $f`
        do
        echo "<td> $y</td>">>"/tmp/output1"
        done
        echo "</tr>">>"/tmp/output1"
fi
done
echo "</table>">>"/tmp/output1"
echo "</body>">>"/tmp/output1"
echo "</html>">>"/tmp/output1"
cat "/tmp/output1"|mail mailto:chittibabu.miriyala@gmail.com

No comments:

Post a Comment