ElkArte Community

Project Support => General ElkArte discussions => Topic started by: emanuele on June 01, 2019, 06:29:18 am

Title: Server uptime monitoring - proof of concept
Post by: emanuele on June 01, 2019, 06:29:18 am
Using existing tools is soooo boring... while reinventing the wheel is always so fun! :D

So, a few days ago I got the idea to give it a go to create a monitoring "service" with free tools that could be used to as a proof of concept monitor if the domain responds properly.
What i used are all tools provided by google for free:

The result is:
https://datastudio.google.com/reporting/1pISX1-ui5poBVZFVKQWp_d3dThmf0fNM/page/5gwq

a little boring look for the moment, but it's just a PoC.

The concept is somehow simple: a few lines of App script sends and capture a request to a webdomain, write down the result in a Google sheet and Data studio visualize that results.
The "ping" is done ever 15 minutes and the charts are updated every 15 minutes, so in the worst case you are looking at a data that is 30 minutes old.
For the time being I didn't spend much time tuning the Data studio report, so it shows only the number of pings in a certain status per hour (so the maximum would be 4, one every 15 minutes).

The App script code is the following:
Code: [Select]
function checkSite() {
  var response = UrlFetchApp.fetch("http://www.elkarte.it/", {'muteHttpExceptions': true});
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName('Sheet1');
  var d = new Date();
  sheet.appendRow([d.getFullYear().toString() +
                   Utilities.formatString("%02.0f", d.getMonth()) +
                   Utilities.formatString("%02.0f", d.getDate()) +
                   Utilities.formatString("%02.0f", d.getHours())
                   , response.getResponseCode(), response.getAllHeaders().toSource()]);
}
Most of the code at the moment is currently devoted to write a date that can be digested by Data studio.

The data source in Data studio is configured with 4 fields that filter the status code responses in order to show them in 4 different charts (one for 200 = all good, one for 404 = page not found, one for 500 = server error, and one for any other code).

My intention would be to add:
Title: Re: Server uptime monitoring - proof of concept
Post by: Spuds on June 01, 2019, 10:38:07 am
Very cool ... new toys to play with :D