Checks every site listed in a spreadsheet on a schedule and alerts you in Slack or by email when one goes down or recovers.

UsesGmailGoogle SheetsSlack

Watch your websites for downtime

Every 15 minutes, the workflow reads the sites listed on the 'Sites' tab of your spreadsheet, requests each one and decides whether it is up. A successful answer counts as up; a server error, a timeout or a name that no longer resolves counts as down. When a site changes state you are told in Slack, by email, or both.

Alerts go out on the change, not the state. When a site first stops answering you get one message saying what went wrong; while it stays down you hear nothing more; when it answers again you get a single all-clear saying how long it had been down. Every change is written to a 'Status log' tab in the same spreadsheet, created on the first run, which is both its memory and your record of what happened and when. One unreachable site never stops the others being checked.

Before the first run you need a spreadsheet with a 'Sites' tab that has a column headed 'URL', one site per row, and a Slack channel or email address to alert.

Run every 15 minutes.Run every 15 minutes.
Set sitesSheetUrl to blank.Set sitesSheetUrl to blank.
Set sitesTabName to “Sites”.Set sitesTabName to “Sites”.
Set statusTabName to “Status log”.Set statusTabName to “Status log”.
Set alertSlackChannelId to blank.Set alertSlackChannelId to blank.
Set alertEmailAddress to blank.Set alertEmailAddress to blank.
Set maxSites to 25.Set maxSites to 25.
Get the current date and time and save it as checkedAt.Get the current date and time and save it as checkedAt.
Set siteRows to an empty list.Set siteRows to an empty list.
If a step below fails, save the error as siteListErrorIf a step below fails, save the error as siteListError
Try
Google SheetsGoogle SheetsRead the rows of sitesSheetUrl. Save it as siteList.Read the rows of sitesSheetUrl. Save it as siteList.
Change siteRows to siteList.rows.Change siteRows to siteList.rows.
On error
Stop and report a problem: Could not read the site list, so nothing was checked. Check that the spreadsheet in 'sitesSheetUrl' has a tab named as in 'sitesTabName'. (siteListError.message).Stop and report a problem: Could not read the site list, so nothing was checked. Check that the spreadsheet in 'sitesSheetUrl' has a tab named as in 'sitesTabName'. (siteListError.message).
Set logRows to an empty list.Set logRows to an empty list.
Set logHasHeader to false.Set logHasHeader to false.
If a step below fails, save the error as logReadErrorIf a step below fails, save the error as logReadError
Try
Google SheetsGoogle SheetsRead the rows of sitesSheetUrl. Save it as storedLog.Read the rows of sitesSheetUrl. Save it as storedLog.
Change logRows to storedLog.rows.Change logRows to storedLog.rows.
Change logHasHeader to the length of storedLog.headers is greater than 0.Change logHasHeader to the length of storedLog.headers is greater than 0.
On error
Show in the output: There is no status log yet, so this run creates it and records what it finds as the starting point. (logReadError.message).Show in the output: There is no status log yet, so this run creates it and records what it finds as the starting point. (logReadError.message).
If a step below fails, save the error as createTabErrorIf a step below fails, save the error as createTabError
Try
Google SheetsGoogle SheetsCreate the tab statusTabName in sitesSheetUrl.Create the tab statusTabName in sitesSheetUrl.
On error
Show in the output: Could not create the status log tab; carrying on in case it already exists. (createTabError.message).Show in the output: Could not create the status log tab; carrying on in case it already exists. (createTabError.message).
If logHasHeader is noIf logHasHeader is no
Yes
If a step below fails, save the error as headerErrorIf a step below fails, save the error as headerError
Try
Google SheetsGoogle SheetsAdd a row to statusTabName in sitesSheetUrl.Add a row to statusTabName in sitesSheetUrl.
On error
Show in the output: Could not write the status log header row. (headerError.message).Show in the output: Could not write the status log header row. (headerError.message).
No
No steps
Set sitesChecked to 0.Set sitesChecked to 0.
Set sitesDown to 0.Set sitesDown to 0.
For each site in siteRows:For each site in siteRows:
Set siteUrl to blank.Set siteUrl to blank.
If a step below fails, save the error as urlErrorIf a step below fails, save the error as urlError
Try
Trim site.URL and save it as siteUrl.Trim site.URL and save it as siteUrl.
On error
Show in the output: “A row in the site list has no 'URL' column, so it was skipped. Check that the first row of the sites tab has a column headed URL.”.Show in the output: “A row in the site list has no 'URL' column, so it was skipped. Check that the first row of the sites tab has a column headed URL.”.
If siteUrl is emptyIf siteUrl is empty
Yes
Skip to the next item.Skip to the next item.
No
No steps
Add 1 to sitesChecked.Add 1 to sitesChecked.
Set isUp to false.Set isUp to false.
Set detail to blank.Set detail to blank.
If a step below fails, save the error as checkErrorIf a step below fails, save the error as checkError
Try
Fetch siteUrl and save it as response.Fetch siteUrl and save it as response.
Change isUp to response.ok.Change isUp to response.ok.
Change detail to “Answered with HTTP response.status as text”.Change detail to “Answered with HTTP response.status as text”.
On error
Change isUp to false.Change isUp to false.
Change detail to “Could not be reached. checkError.message”.Change detail to “Could not be reached. checkError.message”.
Set currentStatus to “Down”.Set currentStatus to “Down”.
If isUp is yesIf isUp is yes
Yes
Change currentStatus to “Up”.Change currentStatus to “Up”.
No
Add 1 to sitesDown.Add 1 to sitesDown.
Set lastStatus to blank.Set lastStatus to blank.
Set lastChangedAt to blank.Set lastChangedAt to blank.
For each entry in logRows:For each entry in logRows:
If a step below fails, save the error as logRowErrorIf a step below fails, save the error as logRowError
Try
Trim entry.URL and save it as entryUrl.Trim entry.URL and save it as entryUrl.
Trim entry.Status and save it as entryStatus.Trim entry.Status and save it as entryStatus.
Trim entry.Time and save it as entryTime.Trim entry.Time and save it as entryTime.
If entryUrl is siteUrlIf entryUrl is siteUrl
Yes
Change lastStatus to entryStatus.Change lastStatus to entryStatus.
Change lastChangedAt to entryTime.Change lastChangedAt to entryTime.
No
No steps
On error
Show in the output: Ignored a status log row that is missing a column. (logRowError.message).Show in the output: Ignored a status log row that is missing a column. (logRowError.message).
If currentStatus is not lastStatusIf currentStatus is not lastStatus
Yes
If a step below fails, save the error as logWriteErrorIf a step below fails, save the error as logWriteError
Try
Google SheetsGoogle SheetsAdd a row to statusTabName in sitesSheetUrl.Add a row to statusTabName in sitesSheetUrl.
On error
Show in the output: Could not record the change for siteUrl in the status log. (logWriteError.message).Show in the output: Could not record the change for siteUrl in the status log. (logWriteError.message).
Set alertSubject to blank.Set alertSubject to blank.
Set alertBody to blank.Set alertBody to blank.
If currentStatus is “Down”If currentStatus is “Down”
Yes
Change alertSubject to “Site down: siteUrl”.Change alertSubject to “Site down: siteUrl”.
Change alertBody to siteUrl did not answer as expected.Change alertBody to siteUrl did not answer as expected. detail First seen at checkedAt.
Else if @lastStatus isn't empty
Change alertSubject to “Site back up: siteUrl”.Change alertSubject to “Site back up: siteUrl”.
Change alertBody to siteUrl is answering again.Change alertBody to siteUrl is answering again. detail It had been down since lastChangedAt.
Otherwise
No steps
If alertSubject isn't emptyIf alertSubject isn't empty
Yes
If alertSlackChannelId isn't emptyIf alertSlackChannelId isn't empty
Yes
If a step below fails, save the error as slackErrorIf a step below fails, save the error as slackError
Try
SlackSlackSend a message to alertSlackChannelId.Send a message to alertSlackChannelId.alertSubject alertBody
On error
Show in the output: Could not post the alert for siteUrl to Slack. (slackError.message).Show in the output: Could not post the alert for siteUrl to Slack. (slackError.message).
No
No steps
If alertEmailAddress isn't emptyIf alertEmailAddress isn't empty
Yes
If a step below fails, save the error as emailErrorIf a step below fails, save the error as emailError
Try
GmailGmailSend an email to alertEmailAddress.Send an email to alertEmailAddress. Subject: alertSubjectalertBody
On error
Show in the output: Could not email the alert for siteUrl. (emailError.message).Show in the output: Could not email the alert for siteUrl. (emailError.message).
No
No steps
No
No steps
No
No steps
Show in the output: Checked sitesChecked as text site(s); sitesDown as text not answering.Show in the output: Checked sitesChecked as text site(s); sitesDown as text not answering.