Low Disk Space Warning Script

Have you ever experienced a full disk on a server or a desktop? Not fun. This script would normally be run as a cron job and would notify you by email if any drive's free disk space has passed below a certain threshold. The code could be better; I wrote this one a long time ago when I was a bit of a n00b and I was in a rush as well. I might make take a look at it again and see if I can make some improvements.

Topic: 

Comments

This script fails for work for situations where the filesystem name is too long, causing the other columns to be pushed to a new line. Therefore, not everyline will have a valid line.split()[4]

Huh... looks like we'll have to join all the lines together (essentially removing line endings and replacing them with a space) and then split on something other than '\n'. The only thing I can see that is common in each "real line" of output is the percent sign. So I could split on the second bit of white space after the percent sign. That is assuming that there are no spaces in the mount point. Or I could do something really stupid like, try to get line.split()[4] and if that fails, get the nextLine.split()[-1] and assume that is the mount point.

Send me a patch if you want and I'll commit it for all to share.