always use Google Docs for saving sharing my data. But now with Google Docs you can monitor your website’s up-time and down-time. The latest version of this Google Docs based website monitoring tool is even better:
- Support multiple websites and blogs
- It not only support E-mail but also SMS Alert
How To Do:
- Click here and get a sheet.
- Now go to file and make copy of it.
- You’ll see a new Website Monitor menu in the toolbar. Click Initialize and you’ll get a pop-up asking for authorization. Just say Yes.
- Put your Website URL and email address
- You can put multiple URLs by adding comma.
- Go to the Website Monitor menu again and choose “Start Monitoring”.
Note: If you do not wish to receive SMS alerts, simply change the value of cell B4 from Yes to No.
Full Source Code:
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; ii++) {
var url = urls[i];
if (!ScriptProperties.getProperty(url)) {
ScriptProperties.setProperty(url, 200);
}
// Trying to connect to the website URL
try {
response = UrlFetchApp.fetch(url);
} catch(error) {
// If URLFetchApp fails, the site is probably down
updateLog(url, -1);
continue;
}
code = response.getResponseCode();
updateLog(url, code);
}
}
function updateLog(url, code) {
if (ScriptProperties.getProperty(url) == code)
return;
ScriptProperties.setProperty(url, code);
var sheet = SpreadsheetApp.getActiveSheet();
var row = sheet.getLastRow() + 1;
var time = new Date();
var msg = "Down";
if (code == 200)
msg = "Up";
msg = "Website is " + msg + " " + url;
sheet.getRange(row,1).setValue(time);
sheet.getRange(row,2).setValue(msg);
// Send an email notification when the site status changes
var email = sheet.getRange("B3").getValue();
MailApp.sendEmail(email, msg, url);
var now = new Date(time.getTime() + 10000);
// Create an event in Google Calendar with an SMS reminder
if (sheet.getRange("B4").getValue().toLowerCase() == "yes")
CalendarApp.createEvent(msg, now, now).addSmsReminder(0);
}