I need some help with creating a simple site status (uptime/downtime) monitor script in ColdFusion.
My guess it can be done using cfschedule, but I am not knowledgeable with that so I would really appreciate any help.
Basically I would like the script to check if an application on my site (http://www.mysite.com/application) is accessible or not 60 minutes. If the application is down in that 60 minutes, then I am sent an e-mail to firstname.lastname@example.org.
Can anybody please help me with this? I am using ColdFusion 7.
We do something similar, but we are monitoring the server, not just one app.
From another server we have a scheduled job that runs every two minutes. It uses cftry/cfcatch. The try block has a cfhttp tag with a very short timeout. The catch block has the notification code.
You could indeed use cfschedule. However, checking whether an application is up or down isn't a trivial matter. Parts of the application may be down, whereas others are up.
This means that your notification script should emulate a selection of the essential activities of the application. Also, it should be light in its consumption of resources. Otherwise, it may itself become the reason the application goes down.
For example, suppose your application validates certain important variables, reads from and writes to the database. Then the notification script could run a test query(returning just 1 row) on each vital database table, and cflog the current values of the important variables.
<cfschedule action = "update"
task = "TaskName"
operation = "HTTPRequest"
startDate = "#createdate(2012,3,27)#"
startTime = "08:00 AM"
interval = "3600"
requestTimeOut = "600">
Thanks BKBK, that is very helpful! My end goal was actually to have two checks, but I didn't want to ask for too much of your kindness. Your code works nicely, but what my end goal was to check to see if, for example http://www.mysite.com/application/alertMe.cfm, was working or not twice.
In otherwords, every 60 minutes the script would check to see if the page was working or not. If it wasn't, then it would check again in five minutes, and if its still down send an e-mail. The problem, I am having however, is when I try to run two CFschedules it doesn't work for me.
So say page1.cfm has your code, alertMe.cfm has the cfmail to send me a message the server is down, and then page2.cfm has your code again, but with an interval of "once" and a start time of 5 minutes from now. Page1.cfm to alertMe.cfm works like a charm. Page 2.cfm to alertMe.cfm also works beautifully. But, when I try to go from page1.cfm to page 2.cfm to alertMe.cfm, it does not seem like the cfschedule on page2.cfm is running so I end up not getting any mail.
Can you plz tell me what I am doing wrong?