Health Checks for Free

The Challenge

Spend least amount of recurring money to monitor your application.

Frugality, one of the core principal had almost kind of became a habit from my first job at Amazon).

The Goal

Get notified when I am online when my server goes down.

Backstory: I am running the Open Source Go application on a single $5 Digital Ocean server. No Load Balancers, No fancy hardware, no high end configuration, no Docker, just the application running on Caddy for self signed Certificates, no vault(https://www.vaultproject.io).

Search for the tools

Ideally having another server monitor this process is the basic idea, but I did not want to setup/maintain another DO server in a different location. Since pushing is not an option, polling is another

One of the options considered was Pingdom ~$7/month (free version is hidden which I found assuming while talking a friend later)

PagerDuty is one of the famous paying options of $9/month. Found few other solutions like Pingdom, but none of them had international calling or right integrations to notify me.

I finally I went down with was HealthChecks. The idea is to set an expectation of a cron which runs every X minutes etc., and meeting that expectation of cron finished running successfully or not. It has limits on the number of crons made per user and the history stored. I used Pushbullet extensively to pass websites from mobile to the desktop.

HealthChecks had integration with Pushbullet which helped me configure the notifications. A notification meant something went wrong with the server.

The script


while [ 1 ] ; do
t=$(curl -D - -s https://gitnotify.com/home | head -1 | egrep -o 200)
if [[ "$?" -eq "0" ]]; then
  curl --retry 3 https://hchk.io/12345678-abcd-1234-abcd-123456789012
fi
echo -ne " $t "
date
sleep 58
done

The False Positives:

The health check used to fail occasionally there used to be errors occasionally with the curl command informing that it cannot resolve the IP address of the domain or could not connect to the server (from the gateway). I choose not to spend time on this problem though since it was intermittent.

 Share!