Know When Your Site Goes Down Before Your Clients Do

Posted by Shaun Geisert Friday, January 20, 2012 5:47:00 PM Categories: Development Philosophy General

I'm not too happy when a site I am responsible for goes down.  I especially don't like it when a client alerts me to this fact, when I should have known/fixed the issue myself well before their knowledge of the issue.  So, here's how to prevent such an occurrence from ever happening to you again.

  1. Create yourself a little friendly error.htm page and place it in your root.  If you are using mojoPortal as your CMS, I advise against using the default error.htm page as it is not particularly pretty or helpful (for one, it's important to have some type of web master contact info on an error page in my opinion, so that an end user can contact you).  Here's an example of such a page: http://www.studentaffairs.colostate.edu/error.htm.
  2. Within the html of the aforementioned page, place a little snippet of code that will be used to detect when your site goes down.  Eg, after the opening body tag I have a span tag like so: <span id="mrgeisertyoursiteisdown"></span>
  3. Now make sure that, when your site bombs out it will redirect to your error page.  If you are using mojoPortal, this should already be configured for you.  Otherwise, do something like the following in your web.config file:

    <customErrors mode="RemoteOnly" defaultRedirect="error.htm"> </customErrors>
     
  4. Next head on over to http://www.uptimerobot.com (or some similar "uptime checking" website) and set an alert to hit your site's main page.  Eg, http://www.studentaffairs.colostate.edu . I personally prefer uptimerobot because it allows up to 50 sites (versus 10 for wasitup).  Additionally, uptimerobot has a handy 99 cent iPhone app to monitor your site's uptime. 
  5. Assuming you have an account with uptimerobot,  click "Add New" and under "Monitor Type" select "Keyword Checking".   Be sure to select the option for "Alert When" to "exists" and enter your keyword.  In my case, the keyword is tucked away within the span tag on my error page: mrgeisertyoursiteisdown.
  6. Add Your Monitor, sit back, and relax.

 PS - Doing the above has the added benefit of keeping your ASP.NET web app "alive" and therefore much speedier (often applicable for low-traffic sites).  See http://www.mojoportal.com/using-the-appkeepalive-task-to-speed-up-a-low-traffic-site.aspx for more details.