I mentioned this in a presentation last week but I thought I'd bring it up with a concrete example. For those of you who allow file uploads to your server, how many of you actively check your free space on your server? Even if you don't use that feature, do you monitor free space anyway? Log files, in particular, can suck up quite a bit of space. Here is an incredibly simple ColdFusion template that checks for a minimum number of gigs of free hard drive space. If it is less than that threshold, or at 0, which didn't happen to me yesterday, honest, then it fires off an email.
Set this up to run hourly and you should be good to go. You could also make this check multiple drives if your server makes use of them.
So yeah -this so didn't bite me in the ass. Honest.
Archived Comments
Thanks a bunch for this post Ray, will come in really handy for monitoring AWS space usage. I tried it and it worked on Railo right out of the box too.
AWS brings up a good point. I was going to mention that even if used AWS for file uploads, you may still get screwed by log files (that's what screwed me), but your example is great too. This could be used to ensure your AWS store doesn't go super high and cost you a bundle.
nice post, But how to apply the same in CF9? any way?
Try this: http://www.jozza.net/blog/m...
Note that with standard configurations at extremely low disk space, the email will not be sent because it can not be spooled to disk.
There are ways around that, like spooling to memory, but it's something to be aware of.
Hence the minimum of 1 gig above. ;)
We once had a rogue process on a crash/restart loop. The logs chewed up more than a few gig in the space of an hour. Just something to be aware of...
I don't see where is the function for getFreeSpace('./')
It is a ColdFusion function. I'm not sure when it was added, but certainly over 3 years ago.