1. Configure Rig Reset Triggers
  2. Configure SSH or Team Viewer Launch from Grafana Dashboard
  3. Configuring Telegram Notifications
  4. Running rig-monitor in a Private Network and Accessing it from the Internet

1. Configure Rig Reset Triggers

rig-monitor has the ability to power off, power on a rig if certain (user-defined) metrics drop below the configured (user-defined) thresholds.

Pre-requisites

Powering off, powering on rigs require an external device that can be controlled by rig-monitor. Currently rig-monitor supports Wemo Insight smart plugs, TP-Link smart plugs, revive devices and external devices that can be controlled via API and scripts.

Configuration

In order to enable reset triggers you need to set the following parameters under the [main] section . Bear in mind that you need to do this for every rig that you wish to use triggers on.

Define reset devices

The rigList is an array parameter that holds every rig’s configuration, one rig per line/item e.g.

"<rig id>,<miner>,<primary pool>,<secondary pool>,<rig mgmt url>,<installed GPUs>,<target hr>,<target hr2>,<pwr mgmt device type>, <pwr mgmt ip address>,<max PSU wattage>,<max GPU temp>"

e.g.

"rig01,claymore,label_mininghub_music,label_nanopool,http://192.168.1.10:3333,6,160,60,tplink,192.168.2.10,1200,75",

Look into the config file for details on all the parameters, but the salient parameters to configure reset triggers are the following:

  • pwr mgmt device type – currently rig-monitor supports 4 values:
    • tplink – use TP-Link HS110 smart plug for power usage monitoring and powering off/on rigs
    • wemo – use Wemo Insight smart plug for power usage monitoring and powering off/on rigs
    • noplug – no smart plug installed, instead use max PSU wattage param as “static” power usage (BTW, this is useful if you want to use the profitability charts based on estimated or manually measured power usage)
    • script – use an external script to trigger power off/on rigs through external device
  • pwr mgmt IP address – takes different values depending on the pwr mgmt device type setting:
    • if device type is tplink or wemo smart plug then use smart plug IP address e.g.  192.168.2.10
    • if device type is revive then use the following format: <ip>|<port>|<<Authorization key> e.g. 192.168.1.100|1|99999999999
    • if device type is noplug then leave empty
    • if device type is script then use script absolute path or relative path to grm dir. I recommend to put your script user the grm/external dir and in that case the path would be external/script.sh (BTW, this works on all architectures)
Define the power management rules

The PowerMgmtRules is an array parameter that holds the user defined triggers per rig, one rig per line/item e.g.

Items in each line are comma separated and each line starts with the rig name followed by 2 reset rules. Each rule has the following format:

<rig id>,<rule #1 enabled>,<influxDB field>,<influxDB table>,<lower limit>,<timer>,<rule #2 enabled>,<influxDB field>,<influxDB table>,<lower limit>,<timer>

e.g.

"rig01,true,hr,miner_system,50,600,true,power_usage,env_data,300,500"

So in the example above the rule #1 is enabled for field hr (“hashrate”) in miner_system table. rig-monitor will trigger a reset is the hashrate drops below 50 for longer than 600 seconds (10 minutes).

And for rule #2, which is also enabled,  rig-monitor will trigger a reset is the power consumption (power_usage field in env_data table) drops below 300 (watts) for longer than 500 seconds (9minutes and 40seconds).

The power management logic execution interval is specified by the SmartPlugPollingInterval setting which is also used by the power monitoring feature.

Once a power management rule is validated the rig-monitor will power-cycle (or call the defined custom script) the respective rig’s smart plug (turn off, sleep 5 seconds, turn on). After each reset, rig-monitor will ignore the rig’s power management rules for 5 minutes (hardcoded value) so to allow the rig to reboot and resume operation. This also applies for all rule #2, so for instance is rule #1 is validated, and a reset is triggered, then rule #2 will be ignored, and every other check for the next 5 minutes.

2. Configure SSH or Team Viewer Launch from Grafana Dashboard

One of rig-monitor’s main limitations is the ability to integrate with external applications. This is actually not a Grafana limitation, but a generic browser limiation due to security concerns. Nevertheless, there are some ways to overcome this and improve operational efficiency when using grafana dashboards.

Below I’ll be showing you how to launch both SSH terminals (for rigs running Linux) and TeamViewer (for rigs running Windows).

Unfortunately my tests are limited to mac OSX, but, unless otherwise stated,  the solution should work for most browsers/OS combinations. I have not tested this extensively, nor have I plans to do so.

Team Viewer (for Windows-based rigs)

Team Viewer app should register a custom browser protocol during installation. This works well in OSX (as it should on Windows), with both Safari and Chrome. You can read more about it here.

You can test it by copying and paste the following link on any browser:

teamviewer10://control?device=<team viewer id>&authorization=password
SSH (for Linux-based rigs)

As far as I understand the method below only works on OSX/Safari (It failed on Chrome), but if your laptop/desktop is running Windows you can probably use an SSH client that registers a custom protocol like Teamviewer (putty???).

You can test it by copying and paste the following link on Safari:

ssh://user@hostname

If someone gets it to work on other OS/browser configuration then I’d appreciate it if you could share it with the me so I can update these instructions.

Integrating with Grafana

I chose to integrated it as part of the “Overall Rig Status Panel”.

In order to do so I have added an extra column. It doesn’t really matter the content of the column so I simply added another column with the rig_id and a different name (“rm”) to the SQL under the Metrics tab:

SELECT rig_id as "rm", installed_gpus,active_gpus/installed_gpus, last(hr), target_hr FROM "miner_system" WHERE label='[[pool]]' and $timeFilter group by "rig_id"

Now let’s add adjust the column name and add the links. Go to Column Styles tab and click +Add option in the left bottom corner. Now fill out the fields:

  • Apply to Columns name:     rm
  • Column Header:                   Teamviewer (or SSH)
  • Type:                                     String
  • Link
    • for Team Viewer:    teamviewer10://control?device=$__cell&authorization=password
    • for SSH:                  ssh://user@$__cell
  • Value Mappings/Type:        Value to Text
  • Mapping (one line per rig):
    • for SSH:                  <rig name>         <rig IP>
    • for TeamViewer:     <rig name>         <TeamViewer ID>

3. Configuring Telegram Notifications

You can configure rig-monitor to send notifications to your cell phone via telegram app. There are two distinct methods supported:

  1. Grafana – With Grafana’s telegram support you can configure different alarm levels (and severities) on mulitple charts’ metrics.
  2. rig-monitor – With rig-monitor’s native telegram support – available starting from version 3.2 – you can trigger notifications so that when a rig is rebooted (via power management rules) a “rig restart” message is sent to the configured channel e.g. Record count for hr below defined threshold (3000). Resetting rig37 rig via TPLINK(192.168.1.9)

Configuring Telegram Notifications on Grafana

1. Install Telegram app on your cell phone
2. On your phone open this link. This will open a chat with Telegram’s Botfather
3. Create new bot using /newbot. Then name your bot and give it a username. The bot will reply with a token e.g. 3653462710:AAGgPlkjdflasd78dsf;SDFMAklsadfgDpHzl-AP
4. Create a telegram group and add your bot to it
5. Copy and past the following link to your browser: https://api.telegram.org/bot<TOKEN>/getUpdates. In my case that would be
https://api.telegram.org/bot3653462710:AAGgPlkjdflasd78dsf;SDFMAklsadfgDpHzl-AP/getUpdates

That command should produce an output like this

{"ok":true,"result":[{"update_id":87899789,
"message":{"message_id":2,"from":{"id":762837642,"is_bot":false,"first_name":"John","last_name":"Doe","language_code":"root"},"chat":{"id": 762837642,"first_name":"Rodrigo","last_name":"Fernandes","type":"private"},"date":1503863332,"text":"/help","entities":[{"offset":0,"length":5,"type":"bot_command"}]}}]}
 if the output is simply
 {"ok":true,"result":[]}

then send a couple of messages in the group chat and try again.

6. Write down the id code above we will need it to confirm the notifications in Telegram
7. On Grafana’s main menu go to Alerting / Notifications Channel and click New Channel. Fill in a name, select Type as Telegram, check “Send on all alerts” and “Include image” checkboxes, fill in the BOT API token with the token from step 3 and fill in the “Chat ID” with the ID from step 5.

Configuring Telegram on rig-monitor

Steps 1-6 are exactly the same as for setting up Telegram notifications on Grafana. For the last step, edit the config file and fill out the telegram section params:

[telegram]
enabled = true
debug = false
api = "ASDfdg45GGDFASDfdg45GGDFASDfdg45GGDF"
chatID = 043592

4. Running rig-monitor in a Private Network and Accessing it from the Internet

In most cases, small farm owners won’t have a public IP address to access the farm’s rig-monitor server. In that case, you will  need a secure way to access the Grafana dashboards when you are offsite. You will also most probably need a dynamic DNS solution to overcome the regular IP renewal that most ISP force on home gateways/routers.

Setting up Dynamic DNS

There are several ways to setup it up, depending on your choice of Dynamic DNS service. Most services provide an API and native OS clients. rig-monitor supports www.dynu.com, which has a free tier up to 4 hosts. If you wish to use rig-monitor’s embedded support for www.dynu.com the you’ll need to enable and setup the respective section in the config file:

[dynu]
enabled = false
username = "dynu"
password = "dynu"
hostname = "host.dynu.com"
# in seconds
updateInterval = 1800

 

Setting up access to Grafana dashboard via SSH tunnel

There are a couple of pre-requisites for this:

  1. Install and enable SSH in your server. Most Linux distros include and install the ssh daemon by default, but for Windows you’ll probably need to install a 3rd SSH server like freeSSHh (BTW, I read that Windows10 includes a version of openSSH)
  2. Configure your router to forward SSH requests to rig-monitor’s SSH server. This step is router specific but, basically, you need to make sure SSH requests (port 22) reaching your router’s WAN interface are forward to rig-monitor’s IP address (and port 22).

To test everything is working try opening a SSH session your rig-monitor server from your laptop/desktop using the dynamic DNS host name you created e.g.

ssh user@mydynudomain.com

If that works then close the SSH session and try opening a SSH tunnel with following command

ssh -L 8080:<ip address of rig-monitor>:3000 user@<dynu hostname>

where

  • <ip address of rig-monitor> is your home network private IP address assigned to rig-monitor
  • 3000 is Grafana’s default listening port 
  • <dynu hostname> is the Dynamic DNS host name you have setup in the first step

Now go to your browser and enter the following URL: http://localhost:8080
The grafana UI should come up.