Software: Low Disk Space Script

What does it do?
This is a simple AppleScript that tests two things:
- That there are no hard drives missing
- That there is a certain (pre-defined) amount of available space
If one of these tests fail, it then automatically sends an email (to one or more pre-defined addresses) to inform you of the relevant problem.
What does it work on?
It should work on any version of Mac OS X, however, I have only tested it on 10.3, 10.4 and 10.5 clients and servers.
Why was it created?
Mac OS X requires a certain amount of available space on its boot drive to function normally (at least 500MB, preferably over 2GB for safety). If it gets too low, the system begins to slow down, to an eventual crawl, and can actually crash the computer / server altogether, requiring potentially hours / days of rebuilding.
I know because this happened to one of my Mac servers once. When the hard drive became full, and no-one realised until it was too late, it crashed completely. Even after clearing plenty of space, it still wouldn't start any longer - it took 2 days to rebuild.
Who is it useful for?
Anyone who needs something automated to check their available disk space for them. Especially useful for those with remote computers / servers that can't easily check this regularly. Also handy for those that want to check when their backup drive is close to filling up, or that the backup drive is even present so the backup can occur.
How do I customise it?
By default, this script will check for one hard drive, and that this hard drive has at least 10% of available space remaining. To customise this for any number of hard drives, and a minimum percent of your choosing, open the script and modify the first 3 values under "change these settings" to whatever you like.
- To set how many drives (internal and external) you have connected , change the property next to "set expectedNumberOfHardDisks to" from the default of 1 to how many you have
- To set the minimum amount of free space you'd like to check for, change the property next to "set minimumFreeSpacePercentage to" from the default of 10 to what you'd like
- And most importantly, to tell it what email address(es) to send the error report to, change the property next to "set sendToAddresses to" to your email address. Be sure to keep all the relevant code such as { " , " } otherwise the script may not work
Once finished, you do not need to save the script as an application, compile it, or anything like that. Just save it once you're finished customising, and this is the file that we will use in the instructions below. You may want to move it to a safe location (such as Documents or your Library folder) so it won't accidentally be moved or deleted.
How can I set it so that it checks automatically?
I'm sure there are programs that can run AppleScripts periodically, but I find it just as easy to set a simple appointment (every hour / day / week / whatever) in iCal, and tell it to run this script.
To do this in iCal, use the following instructions:
- Create an appointment
- Name it
- Select how often you'd like this to repeat (every day for example)
- Select "Run script" from the alarm menu
- Select "Other" from the menu below this
- Navigate to the location of your AppleScript
- Click Select
- That's it!
Note - iCal does not have to be open for this to occur.
How much is it?
Free.
Who made it?
Matthew Lindfield Seager.
The usual disclaimer
This software is 'use at your own risk.' While every effort has been made to ensure the safety of this software and its contents, Mac Manager cannot be held liable for any problem, damage or deletion that is caused by the use of this script.
Questions
If you have any questions, please email us.
|