docker-uptime-monitor
Alpine based Docker image to monitor the uptime of a service. The image is inpired by the UptimeRobot job.
What you need
- A Slack account
- Incoming Webhooks enabled
- A Webhook URL
- Docke Engine and Docker Compose installed
How to configure it
Mandatory environment variables
CHANNEL
: Slack channel where alerts will be publishedWEBHOOK
: Webhook URL
Optional environment variables
EMOJI
: Emoji to be used as avatar (default::moyai:
)FREQ
: Cron job frequency (default:*/5 * * * *
)SERVICE
: The service name (default:MyService
)USERNAME
: The bot name (default:MyBot
)TZ
: Timezone (default:Etc/UTC
)
Build arguments
extra_packages
: Space separated list of packages to be installed (default:''
)
How to use it
-
Implement your check script (see
monitor/check.sh
) in order to echo1
when your service is UP and0
when the service is DOWN. If needed, extra or specific packages can be installed by defining them inextra_packages
build argument. -
Create a compose file like the following
version: '3' services: monitor: build: context: . args: extra_packages: 'coreutils' environment: CHANNEL: '#monitor' WEBHOOK: 'https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX' FREQ: '*/1 * * * *' EMOJI: ':alien:' SERVICE: 'TheAlienService' USERNAME: 'ET' TZ: 'Europe/Rome'
and run the image
$ docker-compose up --build
-
Check your Slack channel and enjoy it!