Monitoring Nextcloud via Conky on Desktop (ubuntu/debian)

Hi everybody. I share with you this bash monitoring script kit which allow to creat quite easily some conky for the nextcloud feature “External Monitoring”.

screenshot-2019_10_07-conky_nextcloud_external_moniroting_tool03
We will see here how to monitor your nextcloud server(s) from a conky on your Debian/Ubuntu desktop.

The Bash script kit used to create the conky itself uses the nextcloud functionality “External Monitoring Tool” (based on Open Collabora).

By default the conky provided as an example displays the main informations but not all. This way you can easily choose what to display yourself.

Cluster and self-signed https : The script allows you to force the IP address for a domain name (see the second connection function). You can thus retrieve information on each node of your web cluster. This function, unlike the first one, does not check the authenticity of the https certificate, so avoid using it on an unsecured link.

Install :

  1. Not mandatory but strongly recommended for security: create a dedicated admin user with a very strong password, then connect to it via the WEBUI and create a connection Token on which you delete access to the file system.

  2. Download the following folder and move it in ~/.conky/conky-perso/ You can choose another destination if you want, but you need change the path in the code.

  3. Edit the script ~/.conky/conky-perso/conky_nextcloud/conky_nextcloud.bash . Specify the nc_login, the nc_password (token) and the server hostname.

  4. Give the good permissions on the script

chmod 550 ~/.conky/conky-perso/conky_nextcloud/conky_nextcloud.bash

  1. Add the conky in your manager and lunch it. Enjoy !
5 Likes

For creat Session Token (random strong dedied password)

  1. Connect on your Nextcloud and go in Settings.
  2. Click on “Security”, in the section “Devices & sessions” : you can creat and remove token.

More infos : https://docs.nextcloud.com/server/17/user_manual/session_management.html

1 Like

Hi, thanks for the tool!

But I get some trouble to make it work.

Here’s what the 1st part of the bash script looks like:

#!/bin/bash
## SCRIPT VERSION::1.1
function nextcloudUpdateInfos {
INFOS_NEXTCLOUD_SRV1=$(curl https://mySpecialUser:aK88x-74ok9-7Hz4P-oYrXs-qdZZa@cloud.mydomain/ocs/v2.php/apps/serverinfo/api/v1/info)
# WARNING, FOR SECURITY REASON : USE ONLY TOKEN NOT DIRECTLY PASSWORD, REMOVE FILEACCESS AND IF POSSIBLE USE A DEDIED ADMIN USER
#INFOS_NEXTCLOUD_SRV1=$(cat ~/.conky/conky-perso/conky_dev/test.txt)
}

Where mySpecialUser is an admin user I created for this purpose and mydomain is replacing the real one, as you can guess.

Now when I try to launch this conky, I get:

$conky -c ~/.conky/conky-perso/conky_nextcloud/conky_nextcloud.bash
conky: Syntax error (/home/blabla/.conky/conky-perso/conky_nextcloud/conky_nextcloud.bash:2: unexpected symbol near ‘#’) while reading config file.
conky: Assuming it’s in old syntax and attempting conversion.
conky: [string “…”]:139: attempt to index local ‘settings’ (a nil value)

The machine is an Ubuntu 18.04 with:
conky-all 1.10.8-1 amd64 highly configurable system monitor (all features enabled)

Hello @manu.p. This is the ‘conkyrc’ file to give to the command ‘conky -c’.
The file ‘conkyrc’ is a configuration file for the conky core.

Example :

└─ $ ▶ conky -c conkyrc
conky: Syntax error (conkyrc:2: unexpected symbol near '#') while reading config file. 
conky: Assuming it's in old syntax and attempting conversion.
conky: desktop window (1600042) is subwindow of root window (142)
conky: window type - normal
conky: drawing to created window (0x5000002)
conky: drawing to double buffer
conky: Unknown setting 'maximum_height'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2518  100  2518    0     0   8122      0 --:--:-- --:--:-- --:--:--  8122
(standard_in) 1: syntax error
expr: syntax error
^Cconky: received SIGINT or SIGTERM to terminate. bye!

The displayed errors are not a problem, the conky is displayed on the desktop :slight_smile: (tested :wink: )

Not tested. But you cann the content of line 2. " ## SCRIPT VERSION::1.1or set it perhaps to # SCRIPT VERSION::1.1 if it solves the problem.

The error displayed come from the conkyrc file i think. If delete the header comments i have a strange error about ‘=’.
But the conky work, i think it’s the conky core that has a little bug.

Hi @voxdemonix, thanks for replying.

Here’s what the man conky gives for the -c option:

-c | --config= FILE
Config file to load instead of $HOME/.conkyrc

Now, the problem is not the “unexpected symbol near ‘#’) while reading config file.” but:

conky: [string “…”]:139: attempt to index local ‘settings’ (a nil value)

@manu.p
Hmmm, I can’t reproduce this bug (and this with gitlab’s copy and paste code).

According to here https://forum.defold.com/t/weird-attempt-to-index-nil-value-error-solved/56059 it could be a problem line 139 with a transition between array => string, but it’s not the case according to my own tests (bash commands respond all time a string where each line are separate by /r/n )

I will search but actually i don’t know how to solve this strange bug. Do you have curl installed ? (sudo apt install curl) (normally “curl” is installed by default on ubuntu)

PS: i use a english translator for speak, if I say crap or you’re unsure, just talk.

Yes, curl is installed.

Anyway, I’m no longer trying to use this conky, switched to some different monitoring solution.

Don’t know which english translator you’re using, just would suggest the very good https://deepl.com