UNIX Programming, Certification, System Administration, Performance Tuning Reference Books
Write a Script That Monitors The Used Diskspace

I not very familiar with unix.  Trying to write a script that monitors the used diskspace in % (df -k) for all mounting points. The script should be implemented in a cronjob. If for example the limit exeeds a definded percentage (eq. 90%) then an E-Mail message via smtp should be sent to the admin or someone else.
 

Have a look into this.

#!/bin/ksh
rm /tmp/dfk.txt
echo "df -k output for `date` `uname -a`" > /tmp/dfk.txt
i=1
while [ $i -le `df -k | grep -v proc | grep -v Capacity | wc -l` ] ;do
if [ `df -k | grep -v proc | grep -v Capacity | head -n $i | tail -1 | awk '{print $5}' | sed -e 's/%//'` -gt 85 ] ; then
df -k | grep -v proc | grep -v Capacity | head -n $i | tail -1 >> /tmp/dfk.txt
fi
((i=i+1))
done
if [ `cat /tmp/dfk.txt | wc -l` -gt 1 ] ; then
cat /tmp/dfk.txt | mail user@host.com
fi

Quick Links:
Do you have a UNIX Question?

Unix Home: Unix System Administration Hints and Tips