check_gitlab_access_tokens_expiration

Monitoring plugin to check Gitlab personal access tokens expiration date

This Icinga/Nagios check plugin permit to check Gitlab personal, group or project access tokens expiration date.

Installation

apt install git python3-requests python3-dateutil python3-humanize
git clone https://git.easter-eggs.org/brenard/check_gitlab_access_tokens_expiration.git \
  /usr/local/src/check_gitlab_access_tokens_expiration
mkdir -p /usr/local/lib/nagios/plugins
ln -s /usr/local/src/check_gitlab_access_tokens_expiration/check_gitlab_access_tokens_expiration \
  /usr/local/lib/nagios/plugins/

Usage

usage: check_gitlab_access_tokens_expiration [-h] [-d] [-v] [-U URL]
                                             [-T ACCESS_TOKEN] [-G GROUP_ID]
                                             [-P PROJECT_ID] [-u USER_ID] [-m]
                                             [-t TIMEOUT] [-w WARNING]
                                             [-c CRITICAL] [-C CONFIG]
                                             [--config-section CONFIG_SECTION]
                                             [--config-url-key CONFIG_URL_KEY]
                                             [--config-access-token-key CONFIG_ACCESS_TOKEN_KEY]

options:
  -h, --help            show this help message and exit
  -d, --debug
  -v, --verbose
  -U URL, --url URL     Gitlab URL
  -T ACCESS_TOKEN, --access-token ACCESS_TOKEN
                        Gitlab access token (use to authenticate on API)
  -G GROUP_ID, --group-id GROUP_ID
                        If you want to check a group access token, specify the
                        group ID
  -P PROJECT_ID, --project-id PROJECT_ID
                        If you want to check a project access token, specify the
                        project ID
  -u USER_ID, --user-id USER_ID
                        Gitlab user ID to limit check on this user's access tokens
  -m, --my              Limit check on access tokens owned by same user used to
                        connect to Gitlab
  -t TIMEOUT, --timeout TIMEOUT
                        Specify timeout for HTTP requests (default: 20)
  -w WARNING, --warning WARNING
                        Warning threshold in days (default: 7)
  -c CRITICAL, --critical CRITICAL
                        Critical threshold in days (default: 2)

Configuration file:
  -C CONFIG, --config CONFIG
                        Configuration file (INI format)
  --config-section CONFIG_SECTION
                        Section of configuration file for Gitlab parameter
                        (default: gitlab)
  --config-url-key CONFIG_URL_KEY
                        Configuration key for Gitlab URL (default: url)
  --config-access-token-key CONFIG_ACCESS_TOKEN_KEY
                        Configuration key for Gitlab access token (default:
                        access_token)

Copyright

Copyright (c) 2024 Benjamin Renard

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.