**check_gitlab_tokens** checks all newer tokens of projects and groups if they expire soon. You can set a warning and a critical level in days.
Gitlab has an api requrest `/personal_access_tokens` but it doesn't have the information about the project or usergroup where it is defined.
This check executes additional requests to show it and offers the url to the web linkinterface.
The check returns
* unknown - the http request to gitlab api failed
* critical - min. 1 token is expiring soon
* warning - min. 1 token reached the warning level (and no criritical token was found)
* ok - api request was successful; no critical or warning token was found.
## Requirements
* curl
* Bash REST API client<br>A set of class like functions with a http. prefix. <br>Docs: <https://os-docs.iml.unibe.ch/bash-rest-api-client/>
Extract or Git pull the Bash REST API client somewhere in your filesystem. eg. /opt/bash-api-client/. With the parameter `-r <FILE>` you point to the file `rest-api-client.sh`.
Extract or Git pull the Bash REST API client somewhere in your filesystem. eg. /opt/bash-api-client/. With the parameter `-r <FILE>` you point to the file `rest-api-client.sh`.
## Configuration
The script needs to connect to the Gitlab API.
You need to create a token in a admin group to read all tokens of all projects.
Put 2 bash variabbles into `/etc/icinga2/gitlab.cfg`:
```shell
GITLAB_API='https://gitlab.example.com/api/v4'
GITLAB_TOKEN='glpat-1234567890'
```
You can use another filename for this configuration - but then you need the parameter `-g <FILE>`to reference it.
## Syntax
...
...
@@ -18,7 +42,7 @@ Extract or Git pull the Bash REST API client somewhere in your filesystem. eg. /