Categories
Code

Website Monitor with Google Docs

The following Google Apps Script monitors website domains and will send SMS text alerts when any of these sites are down or inaccessible.


/*

   Website Monitor HD by Digital Inspiration   
   =========================================  

*/

function init() {  
  if (ScriptApp.getScriptTriggers().length == 0) {
    // Set up a monitor that triggers every 5 minutes
    ScriptApp.newTrigger("websiteMonitor")
      .timeBased().everyMinutes(5).create();
  }  
}

function websiteMonitor()
{ 
  var response, error, code, urls;
 
  // The script can monitor multiple website URLs (comma separated) 
  urls = SpreadsheetApp.getActiveSheet().getRange("B2").getValue();
  urls = urls.replace(/\s/g, "").split(",");
  
  for (var i=0; i