Twitter: raymondcamden


Address: Lafayette, LA, USA

Using ColdFusion to check available disk space

01-22-2013 4,332 views ColdFusion 7 Comments

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.

7 Comments

These comments will soon be imported into Disqus. To add a comment, use Disqus above.
  • Commented on 01-22-2013 at 9:50 AM
    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.
  • Commented on 01-22-2013 at 9:58 AM
    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.
  • Commented on 01-22-2013 at 10:16 AM
    nice post, But how to apply the same in CF9? any way?
  • Commented on 01-22-2013 at 10:21 AM
    Try this: http://www.jozza.net/blog/measuring-disk-space-in-...
  • GrumpyCFer #
    Commented on 01-22-2013 at 6:13 PM
    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.
  • Commented on 01-22-2013 at 7:35 PM
    Hence the minimum of 1 gig above. ;)
  • GrumpyCFer #
    Commented on 01-23-2013 at 1:36 AM
    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...