Member-only story
Very simple website monitoring
Someone I work with has recently had an issue with a website of theirs going offline seemingly randomly. They noticed it while doing some updates in their CMS when it dropped out. For a couple of minutes the only response they got were errors.
Since then the website has gone away several more time that they are aware of, for minutes at a time. Yet apparently, when contacting the hosting provider, by the time someone answers and gets around to checking, the site is back up and running. They give the standard response of “it seems to all be working” and that’s that.
So, I thought we should setup some basic monitoring and logging of when the site goes offline. A simple python script should allow us to do this. At the end of the day, as long as the app stays running we would get a log whenever the app was unable to connect and therefore the website was also inaccessible to it’s visitors.
In order to make website requests, we will use a python library called: requests.
This can be installed with pip.
pip install requests
We will also need to make use of time and logging. These should already be available with python.