Monitoring Nextcloud in Zabbix

I will give an example of monitoring Nextcloud in Zabbix.

First, add the line to the Zabbix agent configuration file (instead of ixnfo.com, we will indicate our domain with nextcloud):

UserParameter=nextcloud[*],curl -s --user "admin":"$2" https://ixnfo.com/ocs/v2.php/apps/serverinfo/api/v1/info | grep "$1" | cut -d "<" -f 2 | cut -d ">" -f 2 | head -n 1

Restart the Zabbix agent to apply the changes:

sudo service zabbix-agent restart

In order not to specify the admin user password in each data element, open the Zabbix server panel and add a macro with the admin user password in the Nextcloud host settings, for example, call the macro {$NEXTCLOUD_PASS}.

Now create a template for example named Nextcloud and add it to the host with Nextcloud.

In the template, create data elements with the keys below (also for all we choose the type – Zabbix agent and the type of information – Numeric (unsigned)):

nextcloud[num_users,{$NEXTCLOUD_PASS}]
nextcloud[last5minutes,{$NEXTCLOUD_PASS}]
nextcloud[last1hour,{$NEXTCLOUD_PASS}]
nextcloud[last24hours,{$NEXTCLOUD_PASS}]
nextcloud[version,{$NEXTCLOUD_PASS}]
nextcloud[num_files,{$NEXTCLOUD_PASS}]
nextcloud[num_shares_groups,{$NEXTCLOUD_PASS}]
nextcloud[num_shares_user,{$NEXTCLOUD_PASS}]
nextcloud[num_shares,{$NEXTCLOUD_PASS}]
nextcloud[num_shares_link,{$NEXTCLOUD_PASS}]
nextcloud[num_shares_link_no_password,{$NEXTCLOUD_PASS}]
nextcloud[max_execution_time,{$NEXTCLOUD_PASS}]
nextcloud[upload_max_filesize,{$NEXTCLOUD_PASS}]

Where “last5minutes” is the counter of active users for the last 5 minutes, the rest of the elements seem to be clear. Thus, for example, last5minutes is passed to Zabbix agent as $1, password macro as $2.

If graphs are not drawn, then for example, check what is displayed by the command and whether curl is installed (instead of ixnfo.com we will indicate our domain with nextcloud):

curl -s --user "admin":"password" https://ixnfo.com/ocs/v2.php/apps/serverinfo/api/v1/info
curl -s --user "admin":"password" https://ixnfo.com/ocs/v2.php/apps/serverinfo/api/v1/info | grep "last5minutes" | cut -d "<" -f 2 | cut -d ">" -f 2 | head -n 1
sudo apt install curl

See also my articles:
Examples of Zabbix Triggers
Install Nextcloud in Ubuntu

Leave a comment

Leave a Reply