Offical nextcloud documentation is at https://nextcloud-talk.readthedocs.io/en/latest/commands/

The Talk add-on allows returning information when the user invokes a command preceded with a forward-slash.
I have created 3 custom commands that help NextCloud admins know certain server information that would otherwise have to come from other tools ie: monitoring/graphing software:

  1. Disk space used, available, and percent used via df utility
  2. Latency related info via common ping utility (install if not exists for you, normally net-utils pkg or similar)
  3. Listing server-side mounts via standard mount command

Using Help

For help simply type /help and you should see something similar to below:

talk-bot
/wiki - A simple command to find wikipedia articles for a term
/hackernews - A simple command to list the Top 5 top, new or best stories
/calc - A basic calculator for Nextcloud Talk based on gnu BC
/ping - Usage: /ping <domain/ip address> or use it without domain/ip parameter
/diskspace - Returns disk space information from the server you are connected. Alias=/df
/mount - Returns mount information from the server you are connected

The first 3 bot commands are defaults, and the following 3 are custom commands described in this Github Gist.

Docker Exec into NextCloud Container

If you are running NextCloud in a Docker container you will need to enter a pseudo bash shell using this syntax:

docker exec -it bash

OCC:List

Once you are inside your containers shell we will invoke the OCC NextCloud utility using the syntax occ talk:command:list and occ talk:command:add.

sudo -u abc /config/www/nextcloud/occ talk:command:list

# sudo -u abc /config/www/nextcloud/occ talk:command:list
Response values: 0 - No one, 1 - User, 2 - All
Enabled values: 0 - Disabled, 1 - Moderators, 2 - Users, 3 - Guests

+----+-----+-------------+------------+----------------------------------------------------------------------------------+----------+---------+
| id | app | name | command | script | response | enabled |
+----+-----+-------------+------------+----------------------------------------------------------------------------------+----------+---------+
| 1 | | talk | help | help | 1 | 3 |
| 2 | | Wikipedia | wiki | php /config/www/nextcloud/apps/spreed/sample-commands/wikipedia.php {ARGUMENTS} | 2 | 3 |
| 3 | | Hacker News | hackernews | php /config/www/nextcloud/apps/spreed/sample-commands/hackernews.php {ARGUMENTS} | 2 | 3 |
| 4 | | Calculator | calculator | /config/www/nextcloud/apps/spreed/sample-commands/calc.sh {ARGUMENTS} | 1 | 3 |
| 5 | | Calculator | calc | alias:calculator | 2 | 3 |
| 8 | | Ping | ping | /config/www/scripts/ping.sh {ARGUMENTS} | 1 | 2 |
| 12 | | Disk Space | diskspace | /config/www/scripts/df.sh {ARGUMENTS} | 1 | 2 |
| 13 | | Disk Space | df | alias:diskspace | 1 | 2 |
| 17 | | Show Mounts | mount | /config/www/scripts/mount.sh | 1 | 2 |
+----+-----+-------------+------------+----------------------------------------------------------------------------------+----------+---------+

OCC:Add

sudo -u abc /config/www/nextcloud/occ talk:command:add diskspace "Disk Space" "/config/www/scripts/df.sh {ARGUMENTS}" 1 2
sudo -u abc /config/www/nextcloud/occ talk:command:add ping "Ping" "/config/www/scripts/ping.sh {ARGUMENTS}" 1 2
sudo -u abc /config/www/nextcloud/occ talk:command:add mount "Show Mounts" "/config/www/scripts/mount.sh {ARGUMENTS}" 1 2
sudo -u abc /config/www/nextcloud/occ talk:command:add df "Disk Space" "alias:diskspace" 1 2

df.sh

#!/usr/bin/env bash

BIN_DF=$(which "df")
if ! [ -x "$BIN_DF" ]; then
echo "df (coreutils package) not installed."
echo "See the official documentation for more information"
exit 1
fi

case "$1" in
--help)
echo -e '/diskspace - Returns disk space information from the server you are connected. Alias=/df';
echo -e 'Example: /diskspace\nAlias: /df';
exit 0
;;
"")
df -hT / /data
;;
esac
exit 0

ping.sh

#!/usr/bin/env bash

BIN_PING=$(which "ping")
if ! [ -x "$BIN_PING" ]; then
echo "Ping (inetutils package) not installed."
echo "See the official documentation for more information"
exit 1
fi

case "$1" in
--help)
echo "/ping - Usage: /ping <domain/ip address> or use it without domain/ip parameter"
exit 0
;;
"")
ping -4 -c 5 travisflix.com
;;
*)
ping -4 -c 5 "$1"
;;
esac
exit 0

mount.sh

#!/usr/bin/env bash

case "$1" in
--help)
echo -e '/mount - Returns mount information from the server you are connected\n';
echo -e 'Example: /mount';
exit 0
;;
"")
mount
;;
esac
exit 0

If you have any questions/comments regarding this article, click here or scroll down below (login isn't required to post comments and there's no waiting period).