check_gitlab

check_gitlab

For newest version please check gitlab page !

Gitlab Naemon/Icinga/Nagios plugin which checks various stuff via Gitlab API(v4) and output of gitlab-ctl services.

Tested with: Naemon 1.0.5, 1.0.6; Ruby 2.3.0, 2.3.3

Requirements

  • Ruby >2.3

Usage

./check_gitlab.rb
check_gitlab v0.2.0 [https://gitlab.com/6uellerBpanda/check_gitlab]

This plugin checks various parameters of Gitlab

Mode:
  health       Check the Gitlab web endpoint for health
  services     Check if any service of 'gitlab-ctl status' is down
  group_size   Check size of group in MB
  ci-pipeline  Check duration of a CI pipeline
  ci-runner    Check status of CI runners

Usage: check_gitlab.rb [options]

Options:
    -s, --address ADDRESS            Gitlab address
    -t, --token TOKEN                Access token
    -i, --id ID                      Project/Group ID
    -k, --insecure                   No ssl verification
    -m, --mode MODE                  Mode to check
    -n, --name NAME                  Name of group
    -e, --exclude EXCLUDE            Exclude group
    -w, --warning WARNING            Warning threshold
    -c, --critical CRITICAL          Critical threshold
    -d, --debug                      Print extra debugging/status output (available for health check)
    -v, --version                    Print version information
    -h, --help                       Show this help message

Options

  • -s: gitlab url, only https supported, https://gitlab.example.com

  • -k: if you've a self signed cert

  • -t: access token, required for all api calls

  • -i: project id, group name

  • -n: Name of the group

  • -e: Exclude a group

  • -d: debug/verbose output. at the moment only possible with health mode

Modes

Health check

Checks the status of the readiness endpoint. See https://docs.gitlab.com/ce/user/admin_area/monitoring/health_check.html for more information.

Optional debug/verbose output possible.

naemon@gitlab:plugins$ ./check_gitlab.rb -m health -s  [-k] -t 
OK - Gitlab probes are in healthy state

Services

If any service of 'gitlab-ctl status' reports down service status will be critical.

Requires a sudo entry to get output of gitlab-ctl command.

naemon ALL = NOPASSWD: /usr/bin/gitlab-ctl status
naemon@gitlab:plugins$ ./check_gitlab.rb -m services
Critical - logrotate, mattermost is down

CI Pipeline

Checks duration of CI pipeline in seconds with perfdata. (/projects/:id/pipelines)

naemon@gitlab:plugins$ ./check_gitlab.rb -m ci-pipeline -s  [-k] -t  -i  -w 100 -c 200
Critical - Pipeline #265 took 265s | duration=265s;100;150

CI Runner

Checks status of CI runner. (/runners/all)

naemon@gitlab:plugins$ ./check_gitlab.rb -m ci-runner -s  [-k] -t  -i  -w 0 -c 1
Warning - 1 runner active, 1 runner not active

Group size

Checks size of a group in megabytes with perfdata. (/groups)

Authenticated user/token needs admin rights.

Search can produce more then one result if name overlaps. Limit it via the exclude option - only one group possible. In general it will use the first found group which matches.

naemon@gitlab:plugins$ ./check_gitlab.rb -m group_size -s  [-k] -t  -i  -n  -w 3000 -c 4000
Warning - Utils: used space 3251MB | Utils=3251MB;3000;4000