Monitoring plugin to check if containers are upgradable
Go to file
2024-05-21 20:40:23 +02:00
.pre-commit-config.yaml Introduce pre-commit hooks 2024-04-18 11:16:47 +02:00
check_container_upgrade Now consider rebuild feature as stable 2024-05-21 20:40:23 +02:00
README.md Now consider rebuild feature as stable 2024-05-21 20:40:23 +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-lock		Specify rebuild lock file path (default: /var/tmp/check_container_upgrade.lock)
	--rebuild-log		Specify rebuild log file path (default: /var/tmp/check_container_upgrade.log)
	-d			Debug mode
	-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.