From f6489b1dbb906b4a5b6d8acad115e264de6968b1 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Sun, 14 Jul 2024 23:54:44 +0200 Subject: [PATCH] README: add doc about crons --- README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/README.md b/README.md index cfa17e9..6d4af7f 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,12 @@ Checks are done by running Icinga/Nagios compatible check plugins inside contain **Note:** The first plugin detected as installed will be used. +This script also include a set of cron modes to automatically rebuild and deploy containers image of a docker compose project: + +- **check cron (use `--check-mode`):** check if containers need to be updated and marked then to be rebuilt; +- **rebuild cron (use `--rebuild-mode`):** rebuild containers marked to be rebuilt; +- **deploy cron (use `--deploy-cron`):** deploy rebuilt containers. + ## Installation ``` @@ -21,6 +27,29 @@ echo "command[check_container_upgrade]=sudo /usr/local/lib/nagios/plugins/check_ service nagios-nrpe-server reload ``` +## Configure crons + +```bash +mkdir /var/log/check_container_upgrade +cat << EOF > /etc/cron.d/containers +PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +00 2 * * * root /usr/local/lib/nagios/plugins/check_container_upgrade -f /srv/docker/docker-compose.yml --build -v -l /var/log/containers/check_container_upgrade.log --check-cron +30 2 * * * root /usr/local/lib/nagios/plugins/check_container_upgrade -f /srv/docker/docker-compose.yml --build -v -l /var/log/containers/check_container_upgrade.log --rebuild-cron +0 4 * * * root /usr/local/lib/nagios/plugins/check_container_upgrade -f /srv/docker/docker-compose.yml --build -v -l /var/log/containers/check_container_upgrade.log --deploy-cron +30 4 * * * root /usr/bin/docker image prune -a -f > /dev/null +EOF +cat << EOF > /etc/logrotate.d/containers +/var/log/check_container_upgrade/*.log { + weekly + missingok + rotate 53 + compress + copytruncate + notifempty +} +EOF +``` + ## Usage ```