Skip to content
This repository was archived by the owner on Aug 26, 2024. It is now read-only.
/ docker-monitor Public archive

Simple docker monitor informing about non-running and unhealthy containers

License

Notifications You must be signed in to change notification settings

mschoettle/docker-monitor

Repository files navigation

docker-monitor

CircleCI

Simple docker container monitor informing about non-running and unhealthy containers.

Checks the status of containers containing a given name. Reports containers that are not running (status is not running) or running but their health status is unhealthy. The health status is only reported if you are using HEALTHCHECK. Nothing will be reported if everything is fine to make it compatible with calling the script using a cronjob (cron will not send out emails on empty output).

How to call

docker-monitor makes use of the Docker SDK for Python to access information from the Docker Engine API.

You therefore need to install the docker Python library. It is best to use a virtual environment, for example, using venv:

  1. python3.11 -m venv .venv
  2. source .venv/bin/activate
  3. pip install -r requirements/base.txt
  4. python monitor.py --container-name <nameOfContainer>

Note that you could also use your existing system environment and just install the dependencies there, though that is generally not recommended.

Calling docker-monitor from a cronjob

To facilitate this task, you can use the helper script monitor.sh that ensures monitor.py is being called from the virtual environment.

Development

How to set up development environment

  1. python3.11 -m venv .venv
  2. source .venv/bin/activate
  3. pip install -r requirements/development.txt

Linting with flake8 and type checking with mypy is used. The configuration is located in setup.cfg. The project contains settings for vscode where these are enabled. However, they can also be executed from the project root as follows.

  • Linting with flake8: Execute flake8
  • Static type checking with mypy: Execute mypy

How to update dependencies

This project makes use of pip-upgrader to update the requirements files to the latest versions of dependencies.

  1. Run pip-upgrade to update the desired dependencies
  2. Verify that everything still works
  3. Commit the updates to the requirements file(s)

About

Simple docker monitor informing about non-running and unhealthy containers

Resources

License

Stars

Watchers

Forks

Packages

No packages published