
# Nextcloud by HTTP

## Overview

This template is designed for monitoring Nextcloud by HTTP via Zabbix, and it works without any external scripts.
Nextcloud is a suite of client-server software for creating and using file hosting services.
For more information, see the [`official documentation`](https://docs.nextcloud.com/server/latest/developer_manual/client_apis/OCS/ocs-api-overview.html#)


## Requirements

Zabbix version: 7.0 and higher.

## Tested versions

This template has been tested on:
- Nextcloud ver. 27.0.1, 32.0.0

## Configuration

> Zabbix should be configured according to the instructions in the [Templates out of the box](https://www.zabbix.com/documentation/7.0/manual/config/templates_out_of_the_box) section.

## Setup

Set macros `{$NEXTCLOUD.USER.NAME}`, `{$NEXTCLOUD.USER.PASSWORD}`, `{$NEXTCLOUD.ADDRESS}`.
The user must be included in the Administrators group.

### Macros used

|Name|Description|Default|
|----|-----------|-------|
|{$NEXTCLOUD.SCHEMA}|
HTTP or HTTPS protocol of Nextcloud.
|`https`|
|{$NEXTCLOUD.USER.NAME}|
Nextcloud username.
|`root`|
|{$NEXTCLOUD.USER.PASSWORD}|
Nextcloud user password.
|`<Put the password here>`|
|{$NEXTCLOUD.ADDRESS}|
IP or DNS name of Nextcloud server.
|`127.0.0.1`|
|{$NEXTCLOUD.LLD.FILTER.USER.MATCHES}|
Filter of discoverable users by name.
|`.*`|
|{$NEXTCLOUD.LLD.FILTER.USER.NOT_MATCHES}|
Filter to exclude discovered users by name.
|`CHANGE_IF_NEEDED`|
|{$NEXTCLOUD.USER.QUOTA.PUSED.MAX}|
Storage utilization threshold.
|`90`|
|{$NEXTCLOUD.USER.MAX.INACTIVE}|
How many days a user can be inactive.
|`30`|
|{$NEXTCLOUD.CPU.LOAD.MAX}|
CPU load threshold (the number of processes in the system run queue).
|`95`|
|{$NEXTCLOUD.MEM.PUSED.MAX}|
Memory utilization threshold.
|`90`|
|{$NEXTCLOUD.SWAP.PUSED.MAX}|
Swap utilization threshold.
|`90`|
|{$NEXTCLOUD.PHP.MEM.PUSED.MAX}|
PHP memory utilization threshold.
|`90`|
|{$NEXTCLOUD.STORAGE.FREE.MIN}|
Free space threshold.
|`1G`|
|{$NEXTCLOUD.PROXY}|
Proxy HTTP(S) address.
||

### Items

|Name|Description|Type|Key and additional info|
|----|-----------|----|-----------------------|
|Get server information|
This item provides useful server information, such as CPU load, RAM usage, disk usage, number of users, etc.

https://github.com/nextcloud/serverinfo
|HTTP agent|nextcloud.serverinfo.get_data
**Preprocessing**

- 
Check for not supported value: `any error`

⛔️Custom on fail: Set error to: `Could not get data.`

|
|Server information status|
Server information API status
|Dependent item|nextcloud.serverinfo.status
**Preprocessing**

- 
JSON Path: `$.ocs.meta.message`

- 
Discard unchanged with heartbeat: `1h`

|
|Version|
Nextcloud service version.
|Dependent item|nextcloud.serverinfo.version
**Preprocessing**

- 
JSON Path: `$.ocs.data.nextcloud.system.version`

⛔️Custom on fail: Discard value

- 
Discard unchanged with heartbeat: `1h`

|
|Free space|
The amount of free disk space.
|Dependent item|nextcloud.serverinfo.freespace
**Preprocessing**

- 
JSON Path: `$.ocs.data.nextcloud.system.freespace`

⛔️Custom on fail: Discard value

- 
Discard unchanged with heartbeat: `1h`

|
|CPU load, avg 1m|
The average system load (the number of processes in the system run queue), last 1 minute.
|Dependent item|nextcloud.serverinfo.cpu.avg.1m
**Preprocessing**

- 
JSON Path: `$.ocs.data.nextcloud.system.cpuload[0]`

⛔️Custom on fail: Discard value

- 
Discard unchanged with heartbeat: `1h`

|
|CPU load, avg 5m|
The average system load (the number of processes in the system run queue), last 5 minutes.
|Dependent item|nextcloud.serverinfo.cpu.avg.5m
**Preprocessing**

- 
JSON Path: `$.ocs.data.nextcloud.system.cpuload[1]`

⛔️Custom on fail: Discard value

- 
Discard unchanged with heartbeat: `1h`

|
|CPU load, avg 15m|
The average system load (the number of processes in the system run queue), last 15 minutes.
|Dependent item|nextcloud.serverinfo.cpu.avg.15m
**Preprocessing**

- 
JSON Path: `$.ocs.data.nextcloud.system.cpuload[2]`

⛔️Custom on fail: Discard value

- 
Discard unchanged with heartbeat: `1h`

|
|Memory total|
The size of the RAM.
|Dependent item|nextcloud.serverinfo.mem.total
**Preprocessing**

- 
JSON Path: `$.ocs.data.nextcloud.system.mem_total`

⛔️Custom on fail: Discard value

- 
Custom multiplier: `1024`

- 
Discard unchanged with heartbeat: `1h`

|
|Memory free|
The amount of free RAM.
|Dependent item|nextcloud.serverinfo.mem.free
**Preprocessing**

- 
JSON Path: `$.ocs.data.nextcloud.system.mem_free`

⛔️Custom on fail: Discard value

- 
Custom multiplier: `1024`

- 
Discard unchanged with heartbeat: `1h`

|
|Memory used, in %|
RAM usage, in percent.
|Dependent item|nextcloud.serverinfo.mem.pused
**Preprocessing**

- 
JavaScript: `The text is too long. Please see the template.`

- 
Discard unchanged with heartbeat: `1h`

|
|Swap total|
The size of the swap memory.
|Dependent item|nextcloud.serverinfo.swap.total
**Preprocessing**

- 
JSON Path: `$.ocs.data.nextcloud.system.swap_total`

⛔️Custom on fail: Discard value

- 
Custom multiplier: `1024`

- 
Discard unchanged with heartbeat: `1h`

|
|Swap free|
The amount of free swap.
|Dependent item|nextcloud.serverinfo.swap.free
**Preprocessing**

- 
JSON Path: `$.ocs.data.nextcloud.system.swap_free`

⛔️Custom on fail: Discard value

- 
Custom multiplier: `1024`

- 
Discard unchanged with heartbeat: `1h`

|
|Swap used, in %|
Swap usage, in percent.
|Dependent item|nextcloud.serverinfo.swap.pused
**Preprocessing**

- 
JavaScript: `The text is too long. Please see the template.`

- 
Replace: `NaN -> 0`

- 
Discard unchanged with heartbeat: `1h`

|
|Apps installed|
The number of installed applications.
|Dependent item|nextcloud.serverinfo.apps.installed
**Preprocessing**

- 
JSON Path: `$.ocs.data.nextcloud.system.apps.num_installed`

⛔️Custom on fail: Discard value

- 
Discard unchanged with heartbeat: `1h`

|
|Apps update available|
The number of applications for which an update is available.
|Dependent item|nextcloud.serverinfo.apps.update
**Preprocessing**

- 
JSON Path: `$.ocs.data.nextcloud.system.apps.num_updates_available`

⛔️Custom on fail: Discard value

- 
Discard unchanged with heartbeat: `1h`

|
|Instance update available|
This metric indicates that an update for Nextcloud is available. Note that this metric doesn't work on Nextcloud version 27 and lower.
|Dependent item|nextcloud.serverinfo.update
**Preprocessing**

- 
JSON Path: `$.ocs.data.nextcloud.system.update.available`

⛔️Custom on fail: Discard value

- Boolean to decimal
- 
Discard unchanged with heartbeat: `1h`

|
|Web server|
Web server description.
|Dependent item|nextcloud.serverinfo.apps.webserver
**Preprocessing**

- 
JSON Path: `$.ocs.data.server.webserver`

⛔️Custom on fail: Discard value

- 
Discard unchanged with heartbeat: `1h`

|
|PHP version|
PHP version
|Dependent item|nextcloud.serverinfo.php.version
**Preprocessing**

- 
JSON Path: `$.ocs.data.server.php.version`

⛔️Custom on fail: Discard value

- 
Discard unchanged with heartbeat: `1h`

|
|PHP memory limit|
By default, the PHP memory limit is generally set to 128 MB, but it can be customized based on the application's specific needs. The php.ini file is usually the standard location to set the PHP memory limit.
|Dependent item|nextcloud.serverinfo.php.memory.limit
**Preprocessing**

- 
JSON Path: `$.ocs.data.server.php.memory_limit`

⛔️Custom on fail: Discard value

- 
Discard unchanged with heartbeat: `1h`

|
|PHP memory used|
PHP memory used
|Dependent item|nextcloud.serverinfo.php.memory.used
**Preprocessing**

- 
JSON Path: `$.ocs.data.server.php.opcache.memory_usage.used_memory`

⛔️Custom on fail: Discard value

- 
Discard unchanged with heartbeat: `1h`

|
|PHP memory free|
PHP free memory size.
|Dependent item|nextcloud.serverinfo.php.memory.free
**Preprocessing**

- 
JSON Path: `$.ocs.data.server.php.opcache.memory_usage.free_memory`

⛔️Custom on fail: Discard value

- 
Discard unchanged with heartbeat: `1h`

|
|PHP memory wasted|
Memory allocated to the service but not in use.
|Dependent item|nextcloud.serverinfo.php.memory.wasted
**Preprocessing**

- 
JSON Path: `$.ocs.data.server.php.opcache.memory_usage.wasted_memory`

⛔️Custom on fail: Discard value

- 
Discard unchanged with heartbeat: `1h`

|
|PHP memory wasted, in %|
Memory allocated to the service but not in use, in percent.
|Dependent item|nextcloud.serverinfo.php.memory.wasted_percentage
**Preprocessing**

- 
JSON Path: `The text is too long. Please see the template.`

⛔️Custom on fail: Discard value

- 
Discard unchanged with heartbeat: `1h`

|
|PHP memory used, in %|
PHP memory used percentage
|Dependent item|nextcloud.serverinfo.php.memory.pused
**Preprocessing**

- 
JavaScript: `The text is too long. Please see the template.`

- 
Discard unchanged with heartbeat: `1h`

|
|PHP maximum execution time|
By default, the maximum execution time for PHP scripts is set to 30 seconds. If a script runs for longer than 30 seconds, PHP stops the script and reports an error. You can control the amount of time PHP allows scripts to run by changing the 'max_execution_time' directive in your php.ini file.
|Dependent item|nextcloud.serverinfo.php.max_execution_time
**Preprocessing**

- 
JSON Path: `$.ocs.data.server.php.max_execution_time`

⛔️Custom on fail: Discard value

- 
Discard unchanged with heartbeat: `1h`

|
|PHP maximum upload file size|
By default, the maximum upload file size for PHP scripts is set to 128 megabytes. However, you may want to change this limit. For example, you can set a lower limit to prevent users from uploading large files to your site. To do this, change the 'upload_max_filesize' and 'post_max_size' directives.
|Dependent item|nextcloud.serverinfo.php.upload_max_filesize
**Preprocessing**

- 
JSON Path: `$.ocs.data.server.php.upload_max_filesize`

⛔️Custom on fail: Discard value

- 
Discard unchanged with heartbeat: `1h`

|
|Database type|
Database type.
|Dependent item|nextcloud.serverinfo.db.type
**Preprocessing**

- 
JSON Path: `$.ocs.data.server.database.type`

⛔️Custom on fail: Discard value

- 
Discard unchanged with heartbeat: `1h`

|
|Database version|
Database description.
|Dependent item|nextcloud.serverinfo.db.version
**Preprocessing**

- 
JSON Path: `$.ocs.data.server.database.version`

⛔️Custom on fail: Discard value

- 
Discard unchanged with heartbeat: `1h`

|
|Database size|
Size of database.
|Dependent item|nextcloud.serverinfo.db.size
**Preprocessing**

- 
JSON Path: `$.ocs.data.server.database.size`

⛔️Custom on fail: Discard value

- 
Discard unchanged with heartbeat: `1h`

|
|Active users, last 5 minutes|
The number of active users in the last 5 minutes.
|Dependent item|nextcloud.serverinfo.active_users.last5m
**Preprocessing**

- 
JSON Path: `$.ocs.data.activeUsers.last5minutes`

⛔️Custom on fail: Discard value

- 
Discard unchanged with heartbeat: `1h`

|
|Active users, last 1 hour|
The number of active users in the last 1 hour.
|Dependent item|nextcloud.serverinfo.active_users.last1h
**Preprocessing**

- 
JSON Path: `$.ocs.data.activeUsers.last1hour`

⛔️Custom on fail: Discard value

- 
Discard unchanged with heartbeat: `1h`

|
|Active users, last 24 hours|
The number of active users in the last day.
|Dependent item|nextcloud.serverinfo.active_users.last24hours
**Preprocessing**

- 
JSON Path: `$.ocs.data.activeUsers.last24hours`

⛔️Custom on fail: Discard value

- 
Discard unchanged with heartbeat: `1h`

|

### Triggers

|Name|Description|Expression|Severity|Dependencies and additional info|
|----|-----------|----------|--------|--------------------------------|
|Nextcloud: Server information unavailable|
Failed to get server information.
|`last(/Nextcloud by HTTP/nextcloud.serverinfo.status)<>"OK"`|High||
|Nextcloud: Version has changed|
Nextcloud version has changed. Acknowledge to close the problem manually.
|`change(/Nextcloud by HTTP/nextcloud.serverinfo.version)=1 and length(last(/Nextcloud by HTTP/nextcloud.serverinfo.version))>0`|Info|**Manual close**: Yes|
|Nextcloud: Disk space is low|
Condition should be the following:
- the disk free space is less than `{$NEXTCLOUD.STORAGE.FREE.MIN}`;
|`last(/Nextcloud by HTTP/nextcloud.serverinfo.freespace)<{$NEXTCLOUD.STORAGE.FREE.MIN}`|Average|**Manual close**: Yes|
|Nextcloud: CPU load is too high|
High CPU load.
|`min(/Nextcloud by HTTP/nextcloud.serverinfo.cpu.avg.1m,5m) > {$NEXTCLOUD.CPU.LOAD.MAX}`|Average||
|Nextcloud: High memory utilization|
The system is running out of free memory.
|`min(/Nextcloud by HTTP/nextcloud.serverinfo.mem.pused,5m) > {$NEXTCLOUD.MEM.PUSED.MAX}`|Average||
|Nextcloud: High swap utilization|
The system is running out of free swap.
|`min(/Nextcloud by HTTP/nextcloud.serverinfo.swap.pused,5m) > {$NEXTCLOUD.SWAP.PUSED.MAX}`|Average||
|Nextcloud: Number of installed apps has been changed|
Applications have been installed or removed.
|`change(/Nextcloud by HTTP/nextcloud.serverinfo.apps.installed)<>0`|Info|**Manual close**: Yes|
|Nextcloud: Application updates are available|
Updates are available for some of the installed applications.
|`last(/Nextcloud by HTTP/nextcloud.serverinfo.apps.update)<>0`|Warning|**Manual close**: Yes|
|Nextcloud: Server not up to date|
A new Nextcloud version is available.
|`last(/Nextcloud by HTTP/nextcloud.serverinfo.update)=1`|Info|**Manual close**: Yes|
|Nextcloud: PHP version has changed|
The PHP version has changed. Acknowledge to close the problem manually.
|`change(/Nextcloud by HTTP/nextcloud.serverinfo.php.version)=1 and length(last(/Nextcloud by HTTP/nextcloud.serverinfo.php.version))>0`|Info|**Manual close**: Yes|
|Nextcloud: High PHP memory utilization|
The PHP is running out of free memory.
|`min(/Nextcloud by HTTP/nextcloud.serverinfo.php.memory.pused,5m) > {$NEXTCLOUD.PHP.MEM.PUSED.MAX}`|Average||
|Nextcloud: Database version has changed|
The Database version has changed. Acknowledge to close the problem manually.
|`change(/Nextcloud by HTTP/nextcloud.serverinfo.db.version)=1 and length(last(/Nextcloud by HTTP/nextcloud.serverinfo.db.version))>0`|Info|**Manual close**: Yes|

### LLD rule Nextcloud: User discovery

|Name|Description|Type|Key and additional info|
|----|-----------|----|-----------------------|
|Nextcloud: User discovery|
User discovery.
|HTTP agent|nextcloud.user.discovery
**Preprocessing**

- 
JSON Path: `$.ocs.data.users`

⛔️Custom on fail: Set value to: `[]`

- 
JavaScript: `The text is too long. Please see the template.`

|

### Item prototypes for Nextcloud: User discovery

|Name|Description|Type|Key and additional info|
|----|-----------|----|-----------------------|
|User "{#NEXTCLOUD.USER}": Get data|
Get common information about user
|HTTP agent|nextcloud.user.get_data[{#NEXTCLOUD.USER}]
**Preprocessing**

- 
Check for not supported value: `any error`

⛔️Custom on fail: Set error to: `Could not get data.`

|
|User "{#NEXTCLOUD.USER}": Status|
User account status.
|Dependent item|nextcloud.user.enabled[{#NEXTCLOUD.USER}]
**Preprocessing**

- 
JSON Path: `$.ocs.data.enabled`

⛔️Custom on fail: Discard value

- Boolean to decimal
- 
Discard unchanged with heartbeat: `1h`

|
|User "{#NEXTCLOUD.USER}": Storage location|
The location of the user's store.
|Dependent item|nextcloud.user.storageLocation[{#NEXTCLOUD.USER}]
**Preprocessing**

- 
JSON Path: `$.ocs.data.storageLocation`

⛔️Custom on fail: Discard value

- 
Discard unchanged with heartbeat: `1h`

|
|User "{#NEXTCLOUD.USER}": Last login|
The time the user has last logged in.
|Dependent item|nextcloud.user.lastLogin[{#NEXTCLOUD.USER}]
**Preprocessing**

- 
JSON Path: `$.ocs.data.lastLogin`

⛔️Custom on fail: Discard value

- 
Custom multiplier: `0.001`

- 
Discard unchanged with heartbeat: `1h`

|
|User "{#NEXTCLOUD.USER}": Last login, days ago|
The number of days since the user has last logged in.
|Dependent item|nextcloud.user.inactive[{#NEXTCLOUD.USER}]
**Preprocessing**

- 
JavaScript: `The text is too long. Please see the template.`

- 
Discard unchanged with heartbeat: `1h`

|
|User "{#NEXTCLOUD.USER}": Quota free space|
The size of the free available space in the user's storage.
|Dependent item|nextcloud.user.quota.free[{#NEXTCLOUD.USER}]
**Preprocessing**

- 
JSON Path: `$.ocs.data.quota.free`

⛔️Custom on fail: Discard value

- 
Discard unchanged with heartbeat: `1h`

|
|User "{#NEXTCLOUD.USER}": Quota used space|
The size of the used available space in the user storage.
|Dependent item|nextcloud.user.quota.used[{#NEXTCLOUD.USER}]
**Preprocessing**

- 
JSON Path: `$.ocs.data.quota.used`

⛔️Custom on fail: Discard value

- 
Discard unchanged with heartbeat: `1h`

|
|User "{#NEXTCLOUD.USER}": Quota total space|
The size of space available in the user's storage.
|Dependent item|nextcloud.user.quota.total[{#NEXTCLOUD.USER}]
**Preprocessing**

- 
JSON Path: `$.ocs.data.quota.total`

⛔️Custom on fail: Discard value

- 
Discard unchanged with heartbeat: `1h`

|
|User "{#NEXTCLOUD.USER}": Quota used space, in %|
Usage of the allocated storage space, in percent.
|Dependent item|nextcloud.user.quota.pused[{#NEXTCLOUD.USER}]
**Preprocessing**

- 
JSON Path: `$.ocs.data.quota.relative`

⛔️Custom on fail: Discard value

- 
Discard unchanged with heartbeat: `1h`

|
|User "{#NEXTCLOUD.USER}": Quota|
The size of space available in the user's storage.
|Dependent item|nextcloud.user.quota[{#NEXTCLOUD.USER}]
**Preprocessing**

- 
JSON Path: `$.ocs.data.quota.quota`

⛔️Custom on fail: Discard value

- 
Replace: `none -> -99`

- 
Discard unchanged with heartbeat: `1h`

|
|User "{#NEXTCLOUD.USER}": Display name|
User visible name.
|Dependent item|nextcloud.user.displayname[{#NEXTCLOUD.USER}]
**Preprocessing**

- 
JSON Path: `$.ocs.data.displayname`

⛔️Custom on fail: Discard value

- 
Discard unchanged with heartbeat: `1h`

|
|User "{#NEXTCLOUD.USER}": Language|
User language.
|Dependent item|nextcloud.user.language[{#NEXTCLOUD.USER}]
**Preprocessing**

- 
JSON Path: `$.ocs.data.language`

⛔️Custom on fail: Discard value

- 
Discard unchanged with heartbeat: `1h`

|

### Trigger prototypes for Nextcloud: User discovery

|Name|Description|Expression|Severity|Dependencies and additional info|
|----|-----------|----------|--------|--------------------------------|
|Nextcloud: User "{#NEXTCLOUD.USER}" status changed|
User account status has changed.
|`change(/Nextcloud by HTTP/nextcloud.user.enabled[{#NEXTCLOUD.USER}]) = 1`|Info||
|Nextcloud: User "{#NEXTCLOUD.USER}": inactive|
The user has not logged in for more than {$NEXTCLOUD.USER.MAX.INACTIVE:"{#NEXTCLOUD.USER}"} days.
|`last(/Nextcloud by HTTP/nextcloud.user.inactive[{#NEXTCLOUD.USER}]) > {$NEXTCLOUD.USER.MAX.INACTIVE:"{#NEXTCLOUD.USER}"}`|Info||
|Nextcloud: User "{#NEXTCLOUD.USER}": High quota utilization|
More than {$NEXTCLOUD.USER.QUOTA.PUSED.MAX:"{#NEXTCLOUD.USER}"} percent of the allocated storage space has been used.
|`min(/Nextcloud by HTTP/nextcloud.user.quota.pused[{#NEXTCLOUD.USER}],5m) > {$NEXTCLOUD.USER.QUOTA.PUSED.MAX:"{#NEXTCLOUD.USER}"}`|Warning||

## Feedback

Please report any issues with the template at [`https://support.zabbix.com`](https://support.zabbix.com)

You can also provide feedback, discuss the template, or ask for help at [`ZABBIX forums`](https://www.zabbix.com/forum/zabbix-suggestions-and-feedback)

