About

Unfortunately, the ultimate uptime check for a website has to be performed external to the network and through a public network in order to ensure that a website is indeed up and running. There are multiple services available online, most of them being free, with "UptimeRobot" gaining some popularity and traction over the past decade or so. One of the advantages of "UptimeRobot" is the ability to actually perform a HTTP request and pull content in order to be able to tell whether the website is rendering properly - this is something that we've attempted before, using Selenium and an external service that takes screenshots of websites and then comparing the screenshots in order to check whether the website renders properly. With "UptimeRobot", there is a built-in approach where the content is first requested using the website interface and then some keyword is looked up on the data that is downloaded from the website in order to ensure that some marker is present before considering that the website is up and running.

UptimeRobot

The "UptimeRobot" website can be used in order to set up a monitor for a website using various checking methods. After that, the API is straight-forward in regards to checking whether a website is up and running, by simply using the REST interface available. There are features such as WebHooks but those are behind a paywall and hence cannot be used.

The only service that needs to be queried is the getMonitors method as described on the "UptimeRobot" API page that is meant to retrieve all the configured monitors. Ideally, the getMonitors method is called with a monitor ID, yet it seems that the "UptimeRobot" website does not display the monitor ID such that using a search key will allow the query to be narrowed down just to the monitor sought after.

Node-Red

Automating with Node-Red is rather simple given that there are built-in nodes to perform HTTP requests. The following screenshot is an example flow that queries "UptimeRobot" for the status of a monitor and then branches on the result of the status key that indicates the website status on the "UptimeRobot" API page.

As it turns out, a status code of 9 will mean that the website is down and the flow extracts that status in order to feed it into the lower sub-flow that sends a notification via Gotify that the website is down.

In the current format, the monitoring method is via polling by proactively requesting the website status from "UptimeRobot" such that the very first upper timestamp node will first make a request for the monitor status and then repeat the request every minute. Fortunately, "UptimeRobot" understands JSON such that multi-line structured commands can be sent instead of having to squash everything in a POST form body submission.

With all that in place, the website check should be now automated, with a check being performed every minute. For further ideas, the project can be coupled with a physical beacon that will light up when the website status changes.

Flow Export

The flow does not use any special nodes, except the built-in nodes for Node-Red.

[{"id":"8e68ed8020dd6f50","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"d5fca728f442d246","type":"http request","z":"8e68ed8020dd6f50","name":"UptimeRobot","method":"POST","ret":"txt","paytoqs":"ignore","url":"https://api.uptimerobot.com/v2/getMonitors","tls":"14b5e98591d4e0fb","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"other","keyValue":"Content-Type","valueType":"other","valueValue":"application/json"}],"x":510,"y":160,"wires":[["81ae61f49e11d3c8"]]},{"id":"5b37de9a9a8299cb","type":"debug","z":"8e68ed8020dd6f50","name":"debug 95","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":820,"y":260,"wires":[]},{"id":"4d21d51bd64a732f","type":"inject","z":"8e68ed8020dd6f50","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"60","crontab":"","once":true,"onceDelay":"0.1","topic":"","payload":"","payloadType":"date","x":170,"y":160,"wires":[["bebba6174954b72a"]]},{"id":"bebba6174954b72a","type":"template","z":"8e68ed8020dd6f50","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n    \"api_key\": \"{{flow.uptimeRobotKey}}\",\n    \"format\": \"json\",\n    \"search\": \"grimore.org\"\n}","output":"json","x":340,"y":160,"wires":[["d5fca728f442d246"]]},{"id":"81ae61f49e11d3c8","type":"json","z":"8e68ed8020dd6f50","name":"","property":"payload","action":"","pretty":false,"x":670,"y":160,"wires":[["5b37de9a9a8299cb","3f9de2349e91b309"]]},{"id":"3f9de2349e91b309","type":"switch","z":"8e68ed8020dd6f50","name":"","property":"payload.monitors[0].status","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"2","vt":"num"},{"t":"eq","v":"8","vt":"num"},{"t":"eq","v":"9","vt":"num"}],"checkall":"true","repair":false,"outputs":5,"x":810,"y":160,"wires":[[],[],[],[],["18d3066ad1120ce9"]]},{"id":"2b7cd67b1f0f342d","type":"comment","z":"8e68ed8020dd6f50","name":"","info":"0 - paused\n1 - not checked yet\n2 - up\n8 - seems down\n9 - down\n\n","x":820,"y":80,"wires":[]},{"id":"5291c80e6365492b","type":"http request","z":"8e68ed8020dd6f50","name":"gotify","method":"POST","ret":"txt","paytoqs":"ignore","url":"https://gotify.lan/message","tls":"14b5e98591d4e0fb","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"bearer","senderr":false,"headers":[{"keyType":"other","keyValue":"Content-Type","valueType":"other","valueValue":"application/json"}],"x":650,"y":340,"wires":[["f30fa3274f9fca28"]]},{"id":"de9dcd3bde1a6d1f","type":"template","z":"8e68ed8020dd6f50","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n    \"title\": \"grimore.org\",\n    \"message\": \"{{payload}}\"\n}","output":"json","x":500,"y":340,"wires":[["5291c80e6365492b","375db6cb16b1c360"]]},{"id":"4bc751665e1836cd","type":"template","z":"8e68ed8020dd6f50","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"grimore.org is down!","output":"str","x":340,"y":340,"wires":[["de9dcd3bde1a6d1f"]]},{"id":"53fdc9751e05c5d9","type":"inject","z":"8e68ed8020dd6f50","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":340,"wires":[["4bc751665e1836cd"]]},{"id":"375db6cb16b1c360","type":"debug","z":"8e68ed8020dd6f50","name":"debug 96","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":500,"y":420,"wires":[]},{"id":"e67b6f59eff2da29","type":"debug","z":"8e68ed8020dd6f50","name":"debug 97","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":800,"y":420,"wires":[]},{"id":"f30fa3274f9fca28","type":"json","z":"8e68ed8020dd6f50","name":"","property":"payload","action":"","pretty":false,"x":790,"y":340,"wires":[["e67b6f59eff2da29"]]},{"id":"18d3066ad1120ce9","type":"link out","z":"8e68ed8020dd6f50","name":"link out 26","mode":"link","links":["d483bec8e57dd5ba"],"x":955,"y":160,"wires":[]},{"id":"d483bec8e57dd5ba","type":"link in","z":"8e68ed8020dd6f50","name":"link in 32","links":["18d3066ad1120ce9"],"x":275,"y":280,"wires":[["4bc751665e1836cd"]]},{"id":"d3405136486044a7","type":"credentials","z":"8e68ed8020dd6f50","name":"","props":[{"value":"uptimeRobotKey","type":"flow"}],"x":350,"y":100,"wires":[[]]},{"id":"581d41f454fe94df","type":"inject","z":"8e68ed8020dd6f50","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":350,"y":40,"wires":[["d3405136486044a7"]]},{"id":"14b5e98591d4e0fb","type":"tls-config","name":"","cert":"","key":"","ca":"","certname":"","keyname":"","caname":"","servername":"","verifyservercert":true,"alpnprotocol":""}]

iot/external_website_uptime_monitoring.txt ยท Last modified: 2025/01/17 03:03 by office

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.