Developers Forum for XinFin XDC Network

Cover image for [Informative] Uptime Monitoring for Apothem Testnet Masternodes
s4njk4n
s4njk4n

Posted on • Updated on

[Informative] Uptime Monitoring for Apothem Testnet Masternodes

Note 1: This article is designed as an Addendum to this article on Uptime Monitoring for XDC Mainnet masternodes running on Ubuntu 20.04LTS. The processes for masternodes running on the Apothem Testnet are similar to those covered in the Mainnet article but the client ports and paths to certain commands differ. Below you will find section headings that correspond to the same headings in the Mainnet article. Each section will contain the relevant port information specific to Apothem and appropriately altered code snippets for you to use to establish uptime monitoring for your masternode on the Apothem Testnet. Please refer back to the original Mainnet article for information other than code snippets and ports.

Note 2: Although this guide refers to masternodes, it will also work for standby nodes as well as non-validator nodes (as long as they are reachable via a public IP address). For non-validator nodes using HTTP/Websocket JSON-RPC connection, you'll also need to take into account your specific port access requirements when dealing with ports 8898 and/or 8999.


Registering on Uptime Robot

No changes from the section in the Mainnet article.


Creating a monitor that will intermittently ping your node server

No changes from the section in the Mainnet article.


Creating a monitor for your client's RPC endpoint

Go to THIS PAGE shown in the image below.

Uptime Robot Locations and IPs

Right click on the green "IPv4 and IPv6 combined (.txt)" link on that page and copy the link URL. This is a link to the file containing a list of the IP addresses we need to whitelist. Store the link URL by pasting it to a notepad if needed. We will need to use it shortly on our Terminal.

For the following steps to work, we assume that you have set up the firewall on your server using ufw as per the instructions in THIS ARTICLE. If you have not done so, please go to that article and follow the instructions in the section on setting up your ssh port and firewall.

UFW Uncomplicated Firewall

After following the setup instructions there, you will have:

  • Moved your SSH port from 22 to something else
  • Have installed ufw
  • Established a default policy that blocks all incoming connections (with the 2 exceptions of port 30304 and whichever port you chose to use for SSH)
  • Left ports 8898 and 8999 blocked (filtered) on the assumption that the node is not being used by external applications to access the XDC blockchain via Websocket/HTTP JSON-RPC

From this point on, we assume those steps are done and that is how your firewall setup looks.

Now open up a terminal window and ssh to your node server. When using the following command, remember to replace “root” in this command with your actual username for the remote server, replace the "22" with whichever port you have set up for ssh on your server, and replace "ip.address" with the actual IP address of the remote server:

ssh -lroot -p22 ip.address
Enter fullscreen mode Exit fullscreen mode

Use wget to download the Uptime Robot file containing the IP addresses we need to whitelist. Use the link URL we copied from the Uptime Robot website to specify the file location:

wget <URLtoIPaddresses>
Enter fullscreen mode Exit fullscreen mode

It should look something like:
wget command

Install dos2unix:

sudo apt install dos2unix
Enter fullscreen mode Exit fullscreen mode

Use dos2unix to convert the file to the Unix format:

dos2unix IPv4andIPv6.txt
Enter fullscreen mode Exit fullscreen mode

Now run this command to provide restricted access to port 8999 on your VPS to only the IP addresses listed in the file:

while IFS= read -r ip; do sudo ufw allow from "$ip" to any port 8999; done < IPv4andIPv6.txt
Enter fullscreen mode Exit fullscreen mode

You can check your firewall now and you should see ports 30304 and your SSH port open, along with now all of the port 8999 entries for each IP address you have just added:

sudo ufw status
Enter fullscreen mode Exit fullscreen mode

Stop your Apothem Testnet client and reboot your server:

cd ~/XinFin-Node/testnet
./docker-down.sh
reboot
Enter fullscreen mode Exit fullscreen mode

After allowing enough time for your server to reboot, ssh to it again. Remember to replace “root” in this command with your actual username for the remote server, replace the "22" with whichever port you have set up for ssh on your server, and replace "ip.address" with the actual IP address of the remote server:

ssh -lroot -p22 ip.address
Enter fullscreen mode Exit fullscreen mode

Restart the Apothem Testnet client and logout of your server:

cd ~/XinFin-Node/testnet
./docker-up.sh
logout
Enter fullscreen mode Exit fullscreen mode

Now back on the Uptime Robot website again, repeat the "Add a New Monitor" process again but this time:

  • For Monitor Type, select "HTTP(s)".
  • Give your monitor a different nickname.
  • Enter the address of your node's RPC endpoint. eg http://your.nodes.IP.address:8999
  • Set the Monitoring Interval to 5mins as before.
  • The Monitor Timeout just determines how long the monitor will wait for a response before determining that the RPC is offline. Should be ok to leave at 30sec.
  • If you haven't specifically set up an SSL certificate on your node then you can uncheck the boxes next to "Monitor SSL errors" and "Enable SSL expiry reminders".
  • Leave "HTTP Method" as HEAD.
  • Tick the box next to your email address.
  • Click the "Create Monitor" button.

Individually test both of the monitors you have just created as per the process described in the Mainnet article.


You now have an uptime monitor checking every 5 minutes that:

  • Your server is pingable and therefore online/reachable on network; and
  • Your Apothem Testnet client is running as its RPC endpoint is up; and
  • You have secured the HTTP JSON-RPC endpoint by making it only accessible from the Uptime Robot IP addresses you have whitelisted on your firewall

In case of any technical queries on XDC Network, feel free to drop your queries on XDC.Dev forum.

Quick links:

XinFin.org
XDC Chain Network Tools and Documents
XDC Network Explorer
XDC Dev Forum
Beta — XDC Web Wallet
XDC faucet

XinFin — XDC Social Links:

Twitter
GitHub
Telegram
Facebook
LinkedIn
YouTube


Discussion (0)