Monitoring of RPortd

Get notified about issues with your rport server

The more clients you manage with RPort the more important it is to constantly monitor the faultless operation of the server. You must get notified quickly if errors occur.

If you have a monitoring solution in place, integrate your rport server there. If you run the rport server on a cloud service like AWS or Azure, you can use their monitoring.

A basic monitoring should supervise:

  1. The uptime of the server itself (ICMP Ping)

  2. Check if the port for the clients connections, 80 by default, is up.

  3. Check if the port of the API/UI, 443 is up and certificates have not expired.

  4. There is always enough disk space free on the server.

  5. Your backups are executed constantly and flawlessly.

Use the free Better Uptime service

While there a many monitoring services available at different prices, we will explain how to do it with Betteruptime.com as an example. For a reliable monitoring of a single RPort server, the free Basic plan is perfect.

Create monitors

On the left-side main menu click on Monitors and on the right side click the button "Create Monitor". When asked what to monitor, do not enter any URL, select "Alert us when the URL above, doesn't respond to a tcp port". The input form will change. Now enter as follows.

  • Host to monitor: <FQDN-OR-IP-OF-RPORT>

  • TCP Port: the port where clients connect

  • Keyword to find in response: leave empty

  • Send data to port: keep the default

Next, create a monitor for the RPort API and the user interface. Enter the URL of your RPort API. If the port is not the default port 443, append the port to the URL separated by a colon. You should get a green checkmark.

Unfold the “Advanced Setting” and enter a pronounceable monitor name like "RPort API/UI". On the SSL verification options enable "SSL expiration Alert 3 days before".

Monitor the disk space

To monitor the disk space of your RPort sever with Better Uptime click on Heartbeats on the left-side main menu. On the right side, click “Create Heartbeat”. Create the heartbeat as follows:

  • What service will this heartbeat track?: “RPort Server Disk Space”

  • Expect a heartbeat every: 30 minutes

  • with a grace period of: 5 minutes

After creating the heartbeat, a URL is created for you. Copy this URL to your clipboard and enter it to the below script on line 6.

On the rport server, store the following script under /usr/local/bin/discheartbeat.sh.

/usr/local/bin/discheartbeat.sh
#!/bin/sh
set -e
# Set the threshold. If disc space used percent if above, your heartbeat fires an alert.
MAX_ALLOWED=90
# Set the URL Better Uptime has created for your heartbeat
URL="https://betteruptime.com/api/v1/heartbeat/???????"
export LANG=en
LANG=en df -h --output=target,fstype,pcent|grep -E -v "(tmpfs|Mounted)"|
{
    while read -r LINE;do
        pused=$(echo $LINE|awk '{print $3}'|tr -d "%")
        fs=$(echo $LINE|awk '{print $1}')
        # Compare the used space percent with the threshold
        if [ "$pused" -gt "$MAX_USED_ALLOWED" ];then
            echo "Used space on $fs = $pused is above MAX_ALLOWED $MAX_ALLOWED"|logger -t discheartbeat
            exit 1
        fi
    done
    curl -sf "${URL}" >/dev/null 2>&1
    echo "all discs checked"|logger -t discheartbeat
}sh

Make the script executable and run it as a half-hourly cronjob.

chmod +x /usr/local/bin/discheartbeat.sh 
echo '*/30 * * * * root /usr/local/bin/discheartbeat.sh'>/etc/cron.d/discheartbeat

Now your disks are checked every 30 minutes. If none of your disks is filled by more than 90 percent, an "all good" confirmation will be sent to Better Uptime. If any disk exceeds the maximum allowed, the heartbeat is skipped, and you will receive an alert.

To make sure your heartbeat is running, you can check the syslog by grep discheartbeat /var/log/syslog.

On the list of active heartbeats, you will get a green light when your disks have enough space.

Last updated