README: add doc about crons

This commit is contained in:
Benjamin Renard 2024-07-14 23:54:44 +02:00
parent a4639f158d
commit f6489b1dbb

View file

@ -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
```