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
Have a Unix Problem
Unix
Forum - Do you have a UNIX Question?
Unix Books :-
UNIX Programming,
Certification, System Administration, Performance Tuning Reference Books
Return to : - Unix
System Administration Hints and Tips
(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.
Information used on this site is at your own risk.
All product names are trademarks of their respective
companies.
The site www.gotothings.com is in no way affiliated with
or endorsed by any company listed at this site.
Any unauthorised copying or mirroring is prohibited.
|