Let's Install Healthchecks - Cron Job Monitoring Service - On Linux 🌱

What is Healthchecks?

Healthchecks is a cron job monitoring service. It listens for HTTP requests and email messages ("pings") from your cron jobs and scheduled tasks ("checks"). When a ping does not arrive on time, Healthchecks sends out alerts.

Healthchecks comes with a web dashboard, API, 25+ integrations for delivering notifications, monthly email reports, WebAuthn 2FA support, team management features: projects, team members, read-only access. -https://github.com/healthchecks/healthchecks

Installing HeathChecks

  1. Log into the Linux device
  2. Run the following commands in the terminal
    # update software repositories
    sudo apt update
    # install available software updates
    sudo apt upgrade -y
    # install prerequisites
    sudo apt install git gcc python3-dev python3-venv libpq-dev -y
    # create a working directory
    mkdir healthchecks
    # change directory to the working directory
    cd healthchecks
    # prepare the working directory
    python3 -m venv hc-venv
    source hc-venv/bin/activate
    # install wheel
    pip3 install wheel
    # clone healthchecks from github
    git clone https://github.com/healthchecks/healthchecks.git
    # install healthchecks
    pip install -r healthchecks/requirements.txt
    # cd into ./healthchecks
    cd healthchecks
    # initialize database
    ./manage.py migrate
    # create an admin user
    ./manage.py createsuperuser
    # enter an email address
    # enter and confirm a password
    # run healthchecks server
    ./manage.py runserver
  3. Open a web browser and navigate to http://DNSorIP:8000
  4. Login with the admin account created earlier
  5. Welcome to HealthChecks

Running Healthchecks as a Service

  1. Go back to the open terminal and press CTRL+C to kill the running Healthchecks process
  2. Continue with the following commands
    # change directories back to home
    cd ~
    # move the healthchecks folder to opt
    sudo mv ./healthchecks /opt/
    # create healthchecks service file
    sudo nano /etc/systemd/system/healthchecks.service
  3. Paste the following configuration into healthchecks.service

    [Unit]
    Description=Healthchecks
    After=multi-user.target

    [Service]
    ExecStart=/opt/healthchecks/hc-venv/bin/python /opt/healthchecks/healthchecks/manage.py runserver
    Restart=always
    WorkingDirectory=/opt/healthchecks/healthchecks

    [Install]
    WantedBy=multi-user.target

  4. Press CTRL+O, Enter, CTRL+X to write the changes
  5. Continue with the following commands
    # reload systemd services
    sudo systemctl daemon-reload
    # start and enable the healthchecks service
    sudo systemctl enable healthchecks --now
  6. Back in the web browser refresh the Healthchecks page