#vi diskspacealert.sh
#!/bin/bash
threshould=10
hostname=$(hostname)
for path in `/bin/df -h | grep -vE 'Filesystem|tmpfs' | awk '{print $5}'| sed 's/%//g'`
do
if [ $path -ge $threshould ]; then
df -h | grep $path% >> /tmp/temp
fi
done
value=`cat /tmp/temp | wc -l`
if [ $value -ge 1 ]; then
echo "your storage is critical cat /tmp/temp" | mail -v -s "$hostname disk is critical" boobxxxxxxxxxx@gmail.com
fi
#rm -rf /tmp/temp
#sh diskspacealert.sh
.
.
.
//you will get a mail alert if your server have greater then 10%
//and before that make sure you were been configured any relay mail service like sendmail,ssmtp,mailx,postfix..
#!/bin/bash
threshould=10
hostname=$(hostname)
for path in `/bin/df -h | grep -vE 'Filesystem|tmpfs' | awk '{print $5}'| sed 's/%//g'`
do
if [ $path -ge $threshould ]; then
df -h | grep $path% >> /tmp/temp
fi
done
value=`cat /tmp/temp | wc -l`
if [ $value -ge 1 ]; then
echo "your storage is critical cat /tmp/temp" | mail -v -s "$hostname disk is critical" boobxxxxxxxxxx@gmail.com
fi
#rm -rf /tmp/temp
#sh diskspacealert.sh
.
.
.
//you will get a mail alert if your server have greater then 10%
//and before that make sure you were been configured any relay mail service like sendmail,ssmtp,mailx,postfix..
0 Comments