Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Here's a challenge.
Write a script in c shell or perl that monitors disk space and displays a message when any filesystem goes over 85%. Exclude mnttab, fd, and proc. Make the script able to be changed from the command line in order to change the monitoring value of 85% on any monitored filesystem. I've gotten about a third of the way there but can't get the script to work right past getting the percentage of each filesystem into a file. I was trying a while do loop with nawk to monitor the system but I am new to unix and haven't had much luck. Anybody with an idea would be much appreciated.

Give df a try.
csh? Good luck with that. Personally I agree with this guy: www.faqs.org/faqs/unix-faq/shell/csh-whynot/

William is right. Unless you are working under the contraints of homework, no one uses csh for scripting because it works poorly.
#!/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

![]() |
RedHat Linux Boot Disk??
|
dual booting unix/xp
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |