On Thu, Jan 26, 2006 at 02:36:17PM +0000, Mark Rogers wrote:
If I want to run a script on my externally hosted server to mark me if my disk space is getting low, what's the simplest way to do it?
Hmm, something like...
--- Begin Script #!/bin/bash
filesystem="/" warningpercentage=90 persontomail=me@someplace.com subjectofmail='Warning: You are running low on diskspace!'
percentageused=$(df -h $filesystem | tail -n 1 | awk '{print $5}')
if [[ $percentageused -gt $warningpercentage ]]; then ( echo $nicemessage echo df -h $filesystem ) | mail -s $subjectofmail $persontomail fi
--- End Script
Say I want a report if "df" reports more than 90% used, I want the script to run regularly but not send an email every time it runs if the problem hasn't worsend, and want to include the output from 'du -h' in the email?
Then, once I have that sorted, what's the "best" way to do this kind of thing?
cron it half hourly?
Oh, and what's the best way to work out *why* I only have 1% left on my server?
I tend to sit and use du -sh by hand to narrow it down :)
Cheers,