Skip to main content
Inspiring
April 2, 2007
Answered

CFML to check my Server Status..

  • April 2, 2007
  • 4 replies
  • 606 views
Hello,
I have 3 Name servers and 2 Web Servers and 1 SQL server all at seperate IP #'s. I have a admin toolset for several websites and I wanted to add a Status checker to alert the users if any given server was offline before they tried to admin their sites (Or disable functions that rely on file parity, etc.) At first I tried to find CFML to "ping" the servers but no luck. Then i thought I would skip the Nameservers check and just check the webservers. So I put a file on each server that I could cfinclude. Then i remembered I can't use an IP address with cfinclude. So I used an IFRAME to include the file from the IP/dir I wanted. I wrapped this in a cftry/cfcatch block, but of course the failure is page not found when the server is offline and is not a direct cfinclude. So if I cfinclude a page with a IFRAME call to an IP addressed page and the server is down I get a broken IFRAME. Is there any CGI var or CFML readable info in a 404 return I can check for to report failure, rather than missing page error? OR, is there an easier more intelligent way to do this? See my current code below:
    This topic has been closed for replies.
    Correct answer bigbrain28
    Figured it out. See final code below.

    4 replies

    Inspiring
    April 3, 2007
    I take that back. Now when I delete the target file to test the test... I get a 404 error report on screen instead of the FAIL switch? I think i broke it!
    bigbrain28AuthorCorrect answer
    Inspiring
    April 3, 2007
    Figured it out. See final code below.
    Inspiring
    April 3, 2007
    I just saw this tutorial on EasyCFM.com:

    Website Monitor

    http://tutorial223.easycfm.com/
    Inspiring
    April 3, 2007
    That link was great, it solved most of the problem. I obviously run a query on the SQL Server to test it, and the CFHTTP routine worked great for the webservers. Now is their any way to ping a DNS server? From cf I mean? Below is the trimmed code I garnered from the EasyCFM link you gave;
    Inspiring
    April 3, 2007
    I'm with philh on this one - CFHTTP should give you what you need: the ability to check the availability of a web resource on the server-side.
    Inspiring
    April 3, 2007
    Maybe look into using CFHTTP to evaluate the results.