dantebarba / whatsmyhealth

A simple docker container to make healthchecks. Based on healthchecks.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What's my health? Build Status

Whatsmyhealth is a Docker image to perform a healthcheck over a HTTP service based on a cron schedule, with healthchecks.io monitoring.

If no service is specified, the script will send an OK ping to the provided url.

The idea came from the need to monitor the connection of my NAS, and integrate an alert system like healthchecks.io, which provides different connections to different providers (Email, Telegram, Slack...)

It is based on and inspired by Brian J. Cardiff project @ https://github.com/bcardiff/docker-rclone

Usage

Docker example

docker run -it --rm -e  CRON="* * * * *" -e CHECK_URL="http://healthchecks.io/myurl" -e TZ="America/Argentina/Buenos_Aires" -e TEST_URL="https://httpstat.us/200" dantebarba/whatsmyhealth:latest

Docker compose example

version: '2'

services:
  nas-health-status:
    image: dantebarba/whatsmyhealth
    container_name: nas-health-status
    environment:
      CHECK_URL: https://hc-ping.com/myurl
      TEST_URL: http://httpstat.us/200
      TZ: 'America/Argentina/Buenos_Aires'
      CRON: '* * * * *'

Options

A few environment variables allow you to customize the behavior:

  • TEST_URL: url to be checked using curl. Expects HTTP 200. It will fail if status code is different than 200.
  • LOG_FILE: set the log file name. Defaults to /tmp/sync.log
  • CRON: crontab schedule 0 0 * * * to perform sync every midnight. Also supprorts cron shortcuts: @yearly @monthly @weekly
  • FORCE_TEST: forces test upon start. Defaults to 0.

  • CHECK_URL: the healthchecks.io url.

  • FAIL_URL: allows to define a custom /fail url. Uses $CHECK_URL/fail by default.

  • TZ: set the timezone to use for the cron and log America/Argentina/Buenos_Aires

  • LOG_LEVEL: set the log-level of crond. Defaults to 0.

    Log levels available:

    -l emerg or panic  LOG_EMERG   0   [* system is unusable *]
    -l alert           LOG_ALERT   1   [* action must be taken immediately *]
    -l crit            LOG_CRIT    2   [* critical conditions *]
    -l error or err    LOG_ERR     3   [* error conditions *]
    -l warn or warning LOG_WARNING 4   [* warning conditions *]
    -l notice          LOG_NOTICE  5   [* normal but significant condition *] the default
    -l info            LOG_INFO    6   [* informational *]
    -l debug           LOG_DEBUG   7   [* debug-level messages *] same as -d option 

About

A simple docker container to make healthchecks. Based on healthchecks.io

License:MIT License


Languages

Language:Shell 86.9%Language:Dockerfile 13.1%