check_nextcloud: Update to latest git version

This commit is contained in:
Jan Wagner 2024-03-31 21:08:35 +02:00
parent 758756937c
commit 95224ebfa5
2 changed files with 86 additions and 5 deletions

View file

@ -1,11 +1,13 @@
# check_nextcloud
# Nagios/Centron check | Nextcloud serverinfo
Nagios/Centreon plugin for nextcloud serverinfo API (https://github.com/nextcloud/serverinfo)
This branch contains the check for Python 3. A version for Python 2.7 can be found [here](https://github.com/BornToBeRoot/check_nextcloud/tree/stable-python2.7).
## Syntax / Help
```
./check_nextcloud.py -u username -p password -H cloud.example.com -c [system|storage|shares|webserver|php|database|users]
./check_nextcloud.py -u username -p password -H cloud.example.com -c [system|storage|shares|webserver|php|database|users|apps]
Options:
@ -16,12 +18,14 @@ Options:
on the nextcloud server
-p PASSWORD, --password=PASSWORD
Password of the user
-t TOKEN, --nc-token=TOKEN
NC-Token for the Serverinfo API
-H HOSTNAME, --hostname=HOSTNAME
Nextcloud server address (make sure that the address
is a trusted domain in the config.php)
-c CHECK, --check=CHECK
The thing you want to check
[system|storage|shares|webserver|php|database|activeUsers|uploadFilesize]
[system|storage|shares|webserver|php|database|activeUsers|uploadFilesize|apps]
--upload-filesize Filesize in MiB, GiB without spaces (default="512.0GiB")
--protocol=PROTOCOL Protocol you want to use [http|https]
(default="https")
@ -76,3 +80,77 @@ OK - Upload max filesize: 2.0GiB
CRITICAL - Upload max filesize is set to 512.0MiB, but should be 2.0GiB
```
## Icinga config example
Adjust the command path to your local situation.
```
object CheckCommand "check_nextcloud" {
command = [ "/var/lib/nagios/src/check_nextcloud/check/check_nextcloud.py" ]
arguments = {
"--nc-token" = {
value = "$nextcloud_token$"
description = "NC-Token for the Serverinfo API"
}
"--hostname" = {
value = "$nextcloud_hostname$"
description = "Hostname"
}
"--api-url" = {
value = "$nextcloud_api_url$"
set_if = "$nextcloud_api_url$"
description = "Api-url"
}
"--check" = {
value = "$nextcloud_check$"
description = "Which check to run"
}
"--perfdata-format" = {
value = "nagios"
description = "The perfdata format we like"
}
}
}
```
```
apply Service for (checkname in ["system","storage","shares","webserver","php","database","activeUsers","uploadFilesize","apps"]) {
import "generic-service"
name = "check-nextcloud-" + checkname
check_interval = 30m
retry_interval = 10m
display_name = "Nextcloud monitor " + checkname
vars.notification_interval = 1d
vars.nextcloud_check = checkname
vars.nextcloud_hostname = host.vars.nextcloud_hostname
vars.nextcloud_token = host.vars.nextcloud_token
vars.nextcloud_api_url = host.vars.nextcloud_api_url
vars.notification["mail"] = { }
check_command = "check_nextcloud"
assign where (host.address || host.address6) && host.vars.nextcloud_token
}
```
```
object Host "server42.example.com" {
display_name = "My Nextcloud server"
address = "<IP>"
...
# The token can be set with: occ config:app:set serverinfo token --value yourtoken
vars.nextcloud_token = "XXX"
vars.nextcloud_hostname = "nextcloud.example.com"
# Optional if you e.g. use a subdirectory.
vars.nextcloud_api_url = "/subdir/ocs/v2.php/apps/serverinfo/api/v1/info"
}
```