Configuring Checkup for Server Status Checks

Here is a super-fast way to get started with Checkup, which provides "[d]istributed, lock-free, self-hosted health checks and status pages". Checkup is pretty great, but has poor documentation re: getting started, at least as of November 2018.

If you follow this tutorial you will end up with a status page like the one I set up at https://status.noisebridge.info/ hosted behind Nginx, with a cronjob running checkup once per hour to update your status page.

Tutorial

Install Go:

curl https://raw.githubusercontent.com/elimisteve/install-go/master/install-go.sh | bash  
source ~/.bashrc  

Install checkup:

go get -u -v github.com/sourcegraph/checkup/cmd/checkup  

Here's an example checkup config file (on my server, at /home/noisebridge/checkup.json):

{
  "checkers": [
    {
      "type": "http",
      "endpoint_name": "HTTP: Unicorn homepage (by <@elimisteve>)",
      "endpoint_url": "https://noisebridge.info/",
      "must_contain": "noisebridge"
    },
    {
      "type": "tls",
      "endpoint_name": "Unicorn homepage (TLS check) (by <@elimisteve>)",
      "endpoint_url": "noisebridge.info:443"
    },

    {
      "type": "http",
      "endpoint_name": "HTTP: Effective.af instance for Noisebridge (by <@elimisteve>)",
      "endpoint_url": "https://effective.noisebridge.info/",
      "must_contain": "Unicorn"
    },
    {
      "type": "tls",
      "endpoint_name": "Effective.af instance (TLS check) (by <@elimisteve>)",
      "endpoint_url": "effective.noisebridge.info:443"
    },

    {
      "type": "http",
      "endpoint_name": "HTTP: Wiki (notifying <@Rando>)",
      "endpoint_url": "https://www.noisebridge.net/wiki/Noisebridge",
      "must_contain": "<title>Noisebridge</title>"
    },
    {
      "type": "tls",
      "endpoint_name": "Wiki (TLS check) (notifying <@Rando>)",
      "endpoint_url": "noisebridge.net:443"
    }
  ],

  "storage": {
    "provider": "fs",
    "dir": "/home/noisebridge/status_checks",
    "url": "https://status.noisebridge.info/checks"
  },

  "notifier": {
    "name": "slack",
    "username": "status-bot",
    "channel": "#unicorn",
    "webhook": "https://hooks.slack.com/services/..."
  }
}

Clone the checkup GitHub repo so you have the HTML/CSS/JS needed to host the status page:

mkdir ~/repos  
cd ~/repos  
git clone https://github.com/sourcegraph/checkup.git  

Next, in checkup/index.html, replace js/s3.js with js/fs.js.

Now edit checkup/statuspage/js/config.js; here's mine:

checkup.config = {  
    "timeframe": 7 * time.Day,

    // How often, in seconds, to pull new checks and update the page.
    "refresh_interval": 60,

    // Configure read-only access to stored checks. This configuration
    // depends on your storage provider. Any credentials and other values
    // here will be visible to everyone, so use keys with ONLY read access!
    "storage": {
        "url": "https://status.noisebridge.info/checks"
    },

    // The text to display along the top bar depending on overall status.
    "status_text": {
        "healthy": "Situation Normal",
        "degraded": "Degraded Service",
        "down": "Service Disruption"
    }
};

Note that the storage URL used here must match the storage URL in your checkup.json file.

Nginx config (/etc/nginx/sites-enabled/status.noisebridge.info) for serving both the status (home)page itself and the .json files that store the results of the individual checks:

server {  
    listen 80;
    server_name status.noisebridge.info;
    return 302 https://status.noisebridge.info$request_uri;
}

server {  
  server_name status.noisebridge.info;

  access_log /var/www/html/logs/status-access.log;
  error_log /var/www/html/logs/status-error.log;

  location / {
    alias /home/noisebridge/repos/checkup/statuspage/;
    index index.html;
  }

  location /checks/ {
    alias /home/noisebridge/status_checks/;
  }

    #listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/noisebridge.info/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/noisebridge.info/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

You may need to uncomment my

#listen [::]:443 ssl ipv6only=on; # managed by Certbot

line, if you're not already hosting another HTTPS-enabled site on your same server.

Cronjob to run the checks (at the top of) every hour:

0 * * * * /home/noisebridge/gocode/bin/checkup --store -c /home/noisebridge/checkup.json  

Congratulations! Aside from certbot config (which is out of scope for this blog post), you should now have a working checkup-powered status page!