The other day I ran into an issue where a server of mine ran out of disk space. The server is part of a surveillance system I have and collects ~2 gigs of jpeg’s a day, and so can fill up every couple of months if I’m not careful. Not having an alert system finally caught up with me and I was greeted when I returned from work with a couple dozen failure e-mails from cron, indicating the system had run out of space.
Not to be caught in this situation again, I’ve added the below to my crontab. It’s a simple bash command that will e-mail me if my server gets over 80% utilized. I use the second line to send an SMS message to myself if the server becomes 90% or over utilized.
Email when storage gets low
00 * * * * full=/bin/df | /bin/egrep “(100\%|[0-9]\%)”
&& echo $full | /usr/bin/mail -s "[$HOSTNAME] Warning: harddrive space issue" EMAIL_ADDRESS@PROVIDER.COM
00 * * * * full=/bin/df | /bin/egrep “(100\%|9[0-9]\%)”
&& echo $full | /usr/bin/mail -s "[$HOSTNAME] URGENT: harddrive space issue" EMAIL_ADDRESS@PROVIDER.COM