Script abt Filesystem alert

Taking care of your Linux box.
telenor
Havaldaar
Posts: 104
Joined: Tue Mar 29, 2005 11:08 am

Script abt Filesystem alert

Postby telenor » Fri Mar 12, 2010 3:35 pm

AOA,

I made a following script that check filesystem, if any filesystem exceed to 90% then riase an alert only 1 time, but following script generate an alert every 5 minutes according to cronjob. so i need a correction on the script.

************************************************
ALERT="90"
ALERT1="85"
DFH="/tmp/dfout"
DFM="/tmp/dfmail"
CHK="/tmp/hdsize-chk"

rm -f $DFM

clear
echo

echo `date` | tee $DFM
echo | tee -a $DFM

df -h > $DFH
cat $DFH | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $6 }' | while read output;

do
#echo $output
USEP=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
FS=$(echo $output | awk '{ print $2 }' )
if [ $USEP -gt $ALERT ]
then
echo "Running out of space \"$FS - ($USEP%)\"" | tee -a $DFM
fi
done

if test -f $CHK
then
echo "Not Sending an Email"
exit

else

echo Sending an Email
$MAILPROG -s "$SUBJECT" "$EMAIL" < $DFM

echo Creating Tmp File
touch $CHK

fi

if [ $USEP -lt $ALERT1 ]
then
echo Removing Tmp File
rm -f $CHK

fi

************************************************

azfar
Captain
Posts: 598
Joined: Tue Mar 23, 2004 1:16 am
Location: Karachi
Contact:

Postby azfar » Tue Mar 23, 2010 12:16 am

Azfar Hashmi
Email : azfarhashmi@hotmail.com

telenor
Havaldaar
Posts: 104
Joined: Tue Mar 29, 2005 11:08 am

Postby telenor » Wed Mar 24, 2010 1:31 pm

AOA Azfar,


Here is my File System:

Filesystem Size Used Avail Use% Mounted on
/dev/sda1 20G 8.3G 11G 45% /
/dev/sda3 40G 33G 5.2G 87% /d01
none 3.9G 0 3.9G 0% /dev/shm
/dev/sdb 148G 113G 28G 81% /san
/dev/sdc 50G 9.0G 38G 20% /san01
/dev/sdd 403G 303G 79G 80% /san00

If any of the above filesystem exceed to 90% then riase an email alert only 1 time coz script will run with cronjob (after every 5 min).

azfar
Captain
Posts: 598
Joined: Tue Mar 23, 2004 1:16 am
Location: Karachi
Contact:

Postby azfar » Thu Mar 25, 2010 2:49 pm

Azfar Hashmi

Email : azfarhashmi@hotmail.com

telenor
Havaldaar
Posts: 104
Joined: Tue Mar 29, 2005 11:08 am

Postby telenor » Fri Mar 26, 2010 12:36 pm


azfar
Captain
Posts: 598
Joined: Tue Mar 23, 2004 1:16 am
Location: Karachi
Contact:

Postby azfar » Fri Mar 26, 2010 1:23 pm

Azfar Hashmi

Email : azfarhashmi@hotmail.com


Return to “Administration”

Who is online

Users browsing this forum: No registered users and 1 guest