Monitoring plugin to check if containers are upgradable
Find a file
2024-07-11 01:36:13 +02:00
.editorconfig Add .editorconfig file 2024-07-11 01:36:13 +02:00
.pre-commit-config.yaml Code cleaning & and shellcheck pre-commit hook 2024-07-11 01:36:13 +02:00
check_container_upgrade Code cleaning & and shellcheck pre-commit hook 2024-07-11 01:36:13 +02:00
README.md Improve rebuild feature: handle check upgrade status changes, run rebuild via cron and add a deploy cron job 2024-07-08 02:17:03 +02:00

Check container upgrade

Monitoring plugin to check if containers are upgradable. By default all running container are checked.

Checks are done by running Icinga/Nagios compatible check plugins inside containers. These plugins are listed inside the CHECK_PLUGINS associative array (on top of the file) and by default, the following plugin are declared:

  • /usr/lib/nagios/plugins/check_apt: for Debian based image, provide by the monitoring-plugins-basic debian package
  • /usr/lib/nagios/plugins/check_apk: for Alpine based image, see project for install instructions

Note: The first plugin detected as installed will be used.

Installation

git clone https://gitea.zionetrix.net/bn8/check_container_upgrade.git /usr/local/src/check_container_upgrade
mkdir -p /usr/local/lib/nagios/plugins
ln -s /usr/local/src/check_container_upgrade/check_container_upgrade /usr/local/lib/nagios/plugins/
echo "nagios ALL=NOPASSWD: /usr/local/lib/nagios/plugins/check_container_upgrade" > /etc/sudoers.d/nagios-containers
chmod 0400 /etc/sudoers.d/nagios-containers
echo "command[check_container_upgrade]=sudo /usr/local/lib/nagios/plugins/check_container_upgrade" > /etc/nagios/nrpe.d/containers.cfg
service nagios-nrpe-server reload

Usage

Usage : check_container_upgrade [-d] [-E /path/to/engine] [container1,...]
    -E [path]               Force a specific engine (possible values: auto docker podman,
                            default: auto)
    -x [container]          Exclude specified container (could be repeat)
    -M [integer]            Max number of container checks to run in parallel
                            (default: 4, 0=no limit)
    -f [docker-compose.yml] To check upgrade on docker compose project, specified the path of the
                            docker-compose.yml file
    -b|--build|--rebuild    Trigger container build if upgrade detected (only possible if a docker
                            compose file if provided)
    --rebuild-path          Specify rebuild data directory path (default: /var/log/check_container_upgrade)
    --rebuild-cron          Start in rebuild cron mode: rebuild containers detected and mark to be
                            rebuilt on status file.
    --deploy-cron           Start in deploy cron mode: deploy containers known as rebuilt in status
                            file.
    -d                      Debug mode
    -l                      Log file
    -C                      Console logging (even if log file is specify)
    -X                      Enable bash tracing (=set -x)
    -h                      Show this message

Copyright (c) 2024 Benjamin Renard brenard@zionetrix.net

License

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.