monit-docker
Project description
monit-docker project
monit-docker is a free and open-source, we developp it to monitor container status or resources and execute some commands inside containers or manage containers with dockerd, for example:
- reload php-fpm if memory usage is too high
- restart container if status is not running
- remove all containers
Quickstart
Using monit-docker in Docker with crond
docker-compose up -d
See docker-compose.yml and MONIT_DOCKER_CRONS environment variable to configure commands.
Commands:
Simple commands
Restart containers with name starts with foo if memory percent > 60% or cpu percent > 90%:
monit-docker monit --name "foo*" --cmd-if 'mem_percent > 60 ? restart' --cmd 'cpu_percent > 90 ? restart'
Restart containers with name starts with bar and foo if cpu percent greather than 60% and less than 70%:
monit-docker monit --name "bar*" --name "foo*" --cmd-if '60 > cpu_percent < 70 ? restart'
Restart containers with name starts with bar and status equal to pause or running:
monit-docker monit --name "bar*" --cmd-if 'status in (pause,running) ? restart'
Run command in container with image name contains /php-fpm/ and if memory usage > 100 MiB:
monit-docker --image '*/php-fpm/*' monit --cmd-if 'mem_usage > 100 MiB ? (kill -USR2 1)'
Advanced commands with configuration file or environment variable MONIT_DOCKER_CONFIG
Run commands with aliases declared in configuration file (e.g.: monit-docker.yml.example):
Restart container id 4c01db0b339c if condition alias @status_not_running is true:
monit-docker monit --id 4c01db0b339c --cmd-if '@status_not_running ? restart'
Execute commands alias @start_pause containers with name starts with foo if condition alias @status_not_running is true:
monit-docker monit --name "foo*" --cmd-if '@status_not_running ? @start_pause'
Remove force container group php if status is equal to running:
monit-docker monit --ctn-group php --cmd-if 'status == running ? @remove_force'
Restart containers group nodejs if memory percent > 10% and cpu percent > 60%:
monit-docker monit --ctn-group nodejs --cmd-if '@mem_gt_10pct_and_cpu_gt_60pct ? restart'
Remove force all containers:
monit-docker monit --cmd '@remove_force'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for monit_docker-0.0.18-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53e7b4cc5c20df72e5423322a68ccf99d4fed787a50d36bb5b39b43156c762c9 |
|
MD5 | 5949f7a35b0fce4bbc6ef7a0480e3081 |
|
BLAKE2b-256 | 989b2cd646af69a9b774e466992bcb925c862cda93aa0d61acc89ff1b341df79 |