Dear All,
I am looking for a script by which i get email alert if disk space goes above 80%, while this script should not email unless filesystem reaches 81% and then next email after 82% and on and on.
Regards,
Ghulam Yaseen
script to alert about filesystem
-
- Naik
- Posts: 68
- Joined: Thu Aug 07, 2008 6:09 pm
- Location: karachi
-
- Lance Naik
- Posts: 23
- Joined: Fri Sep 01, 2006 12:16 am
use Nagios
a complete solution for these type of needs.
a complete solution for these type of needs.
Code: Select all
#!/bin/sh
subject="Disk Usage Warning"
file=`pwd`/usage
use=`cat $file`
email="root"
mbody=/tmp/body
usage=`df -h /dev/sda1 | awk 'NR==1{next}{ if ($5 > '$use') print $6 " is at " $5;}'`
if [ -n "$usage" ]; then
echo "$usage" > $mbody
#mail -s "$subject" "$email" < $mbody
echo $usage
echo $use + 1 |bc > $file
fi
Azfar Hashmi
Email : azfarhashmi@hotmail.com
Email : azfarhashmi@hotmail.com
updated.
Code: Select all
#!/bin/sh
subject="Disk Usage Warning"
file=`pwd`/usage
use=`cat $file`
email="root"
mbody=/tmp/body
usage=`df -h /dev/sda1 | awk 'NR==1{next}{ if ($5 > '$use') print $6 " is at " $5;}'`
usage1=`df -h /dev/sda1 | awk 'NR==1{next}{ if ($5 < 81) print $5;}' | cut -b 1-2`
if [ -n "$usage" ]; then
echo "$usage" > $mbody
mail -s "$subject" "$email" < $mbody
echo $usage
echo $use + 1 |bc > $file
fi
if [ -n "usage1" ]; then
echo 80 > $file
fi
Last edited by azfar on Sat May 15, 2010 8:05 pm, edited 1 time in total.
Azfar Hashmi
Email : azfarhashmi@hotmail.com
Email : azfarhashmi@hotmail.com
you have to put your threshold (80) in a file "usage".
When your usage reached 81% it will email you and only alert you next time when the usage reached to 82% and so on. It will reset the threshold to 80 when disk reduced below 81%.
When your usage reached 81% it will email you and only alert you next time when the usage reached to 82% and so on. It will reset the threshold to 80 when disk reduced below 81%.
Azfar Hashmi
Email : azfarhashmi@hotmail.com
Email : azfarhashmi@hotmail.com