vi /etc/cron.hourly/hdd_space.sh
#!/bin/sh
# Monitoring server free disk space by Vitalijus Ryzakovas
email=”[email protected]”
proc=85
df -H | grep -vE ‘^Filesystem|tmpfs|cdrom’ | awk ‘{ print $5 ” ” $1 }’ | while read output;
do
usep=$(echo $output | awk ‘{ print $1}’ | cut -d’%’ -f1 )
partition=$(echo $output | awk ‘{ print $2 }’ )
if [ $usep -ge $proc ]; then
echo “Your are running out of disk space \”$partition ($usep%)\” $(hostname) on date $(date)” |
mail -s “Importnat! Server disk space $usep” $mail
fi
done