Monitor your website and get SMS reports when your website is down through Google Docs. Here i made one small JavaScript which help you to monitor your website and give you SMS reports when website is down. Using Google Docs you can monitor your website’s up-time and down-time. The latest version of this Google Docs JavaScript based on website monitoring tool, and it is much much better than any other website monitoring site. It uses Google SMS channel to serve SMS so you don't need to pay for it. It also supports multiple websites and blogs. This website monitoring Script also supports Email Reports.
How To Do:
Full Source Code:
- 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”.
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);
}
{ 0 comments... read them below or add one }
Post a Comment