ColdFusion: Monitor Hard Drive Space And Email Alert

Coldfusion: Monitor and Alert on Low Disk Space

I've been using Adobe Coldfusion since 1999. Everyday, I still learn something new about it's capabilities. There is so much that I have not seen and there is so much that I have seen. Also, there are many ways to have Coldfusion perform and function as needed. Just like everyday task we encounter, you decide on the best solution for you.

Sample Code:

This sample, displays the space and checks to make sure it doesn't fall below 5gigs. If so, it will send out an email notificaion.

Once you have tested your coldfusion snippet. Schedule it with the ColdFusion administrator to run as often as needed.

<cfset fileOb = createObject("java", "java.io.File").init("d:/")>

<cfoutput>
freespace=#fileOb.getFreeSpace()#
<br>
usablespace=#numberformat(fileOb.getUsableSpace(),'9,999,999,999,999')#
<br>
totalspace=#numberformat(fileOb.getTotalSpace(),'9,999,999,999,999,999')#
<br>
<cfset freespace= #numberformat(fileOb.getUsableSpace(),'9999999999999')#>
<br>
#freespace#
</cfoutput>


<cfif #freespace# LT '5000000000'>

<CFMAIL
FROM="any mail"
TO="any email"
SUBJECT="FREE SPACE LOW"
type="html">

<cfoutput>
freespace=#fileOb.getFreeSpace()#<br>
usablespace=#numberformat(fileOb.getUsableSpace(),'9,999,999,999,999')#<br>
totalspace=#numberformat(fileOb.getTotalSpace(),'9,999,999,999,999,999')#<br>
</cfoutput>
</CFMAIL>

</cfif>

More by this Author

  • Gun Laws in Georgia
    38

    Firearms can be a very dangerous tool in the hands of the wrong person. Every state has their own gun laws and regulations. For the state of Georgia, the laws are pretty straight forward and easy to abide by. Before you...

  • How to Build Wooden Roof Trusses
    23

    You may refer to a truss as the rafter, but it's basically the skeleton of the roof, carrying the weight of the frame and supporting the walls of the building. Trusses are very important to preventing the walls from...

  • How to Get Rid of Mice In and Around The House?
    5

    Until this year, the only time that I've had mice or rats in the house were when my daughter had pet mice and rats, and one of those times we did have one loose in the house. (Science fair project got loose.) Anyway,...


Click to Rate This Article
working