Script for monitoring rewards and total delegations in Grafana
This will be a short and straightforward tutorial on how to set up a script and monitoring the output in Grafana.
Firstly, follow shipmateFRnl's guide on how to set up Grafana, Telegraf, and InfluxDB here.
Installing the script
My full script for monitoring your delegations and rewards is posted here. An alternative to my script if you have multiple wallets, is the script of ShipChainEurope which can be downloaded here. However, it uses different paths as me, so you’d have to edit it accordingly. To install the script, follow the commands posted here one by one:
$ mkdir ./filedump/
Here we make a directory where all text and JSON files will be generated because we don't want to clog our working directory.$ nano ./filedump/stakerewards.sh
and copy and paste the script here. Then pressCTRL+\
to find & replaceuser
with your own username. PressCTRL+O
to save the file and thenCTRL+X
to exit the text editor.- Make the script executable by running the command
$ chmod +x ./filedump/stakerewards.sh
- Now run the command
crontab -e
and then copy-paste the following at the bottom of the file*/30 * * * * /home/user/filedump/stakerewards.sh
and by replacinguser
with your own username.
This will cause the script the run every 30 minutes.
Monitoring the output files of the script
Configuring Telegraf
- Copy-paste this at the bottom of your Telegraf configuration file.
$ sudo nano /etc/telegraf/telegraf.conf
then pressCTRL+\
to find & replaceuser
with your own username. PressCTRL+O
to save the file and thenCTRL+X
to exit the text editor. $ sudo systemctl restart telegraf
to restart the Telegraf service.$ sudo systemctl status telegraf
to verify there are no errors.
Configuring Grafana
- Install Farksi Blenstat panel with
$ sudo grafana-cli plugins install farski-blendstat-panel
- Restart Grafana
$ sudo systemctl restart grafana-server
- Now go to the Grafana page in your web browser on your desktop, something like
IP-address:3000
if you didn't change your default port yet. There we will import the following JSON that can be downloaded here. How the other inputs that are used in this dashboard will be covered in a future post. Alternatively, you can add and configure the panels yourself in an existing dashboard.
If you successfully followed all steps, you should see all rewards, delegations, and their current market price in Grafana.