Health checking on your websites
If you are running one or a few your websites, you definitely would like to avoid any access issue to your site. However, you cannot stop it happens. When your website does have some access issues, you need to know at the first place before any of your visitors, and then you can have some time to fix it.
A straightforward way to monitor your website is writing a small script that can send a request to your site and check if the response is what we are expected. If you cannot hear a response or the response is something you are not acceptable, then an issue can be identified and send a notification to your preferred channel.
This is a very simple python script that we can use
import urllib import json import urllib2 import time def notify_slack(options): wekbhook_url = 'my-slack-webhook-url' data = json.dumps(options) request = urllib2.Request(wekbhook_url, data) urllib2.urlopen(request) def check_url(url, expected_status = 200): try: