You are hereLow Disk Space Warning Script

Low Disk Space Warning Script


By David Grant - Posted on 09 September 2008

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.

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.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <s> <img> <h2> <h3>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. The supported tag styles are: <foo>, [foo].
  • Insert Google Map macro.
  • Images can be added to this post.
  • You may use [inline:xx] tags to display uploaded files or images inline.
  • You may use [view:name=display=args] tags to display views.

More information about formatting options

CAPTCHA
Sorry I had to add this test to combat the spam problem.
e
E
9
L
H
K
Enter the code without spaces and pay attention to upper/lower case.