The shell scripted (1.2) version of rig-monitor is no longer supported nor maintained.

Version 2.0 – written in Golang has been released and includes many improvements. Installation instructions for version 1.2 are still available here and blog post about the re-write decision here.

The latest version (1.2) of rig-monitor adds the following features:

  • Support for claymore single and dual mining mode
  • Integration with ethermine pool (currentStats, payouts) API
  • Integration with MPOS-based pools (e.g. miningpoolhib) pool (getdashboarddata) API
  • Integration with nanopool API (generalinfo, payments). Supports all crypto pools (ETH, ETC, SIA, PASC, XMR and ZEC)
  • Integration with coinmarketcap API for monitoring crypo prices in different quote currencies, trading volume and market cap. Supports conversion to different quote currencies.
  • Revised template dashboards

Here are the installation steps.

 PREREQUISITES

Mining rigs

  • Rigs running Claymore’s miner (tested with 9.6+ versions). Both Windows and Linux are supported.
  • Remote manangment port enabled. This option is enabled (READONLY) and running on port 3333 by default.

Management server

  • linux server (I am using a rasbperry pi version B with 512Mb RAM and a 4Gb SD). If you want to manage 10+ rigs with a data retention longer than 1-2 days then I suggest to user a more power raspberry pi or server)
  • msysql
  • grafana-server 4.3.x or 4.4.x (for raspberry pi linux get it here or here for x86 distros)
  • rig-monitor (my scripts. See below)

Other

  • TP Link HS110 smart plugs (optional) installed and configured.
  • admin access to the internet gateway of your rig farm (this is needed to access the raspberry pi remotely via SSH)

INSTALLATION

Update and upgrade installed packages

sudo apt-get update
sudo apt-get upgrade

Install dependencies

sudo apt-get install mysql-server
sudo apt-get install w3m
sudo apt-get install jq

Don’t forget to write down mysql’s root password

Download and install grafana server

The link below is for raspberry pi v1 (version 4.3.2), for other versions download it from here or here for x86 distros).

wget https://github.com/fg2it/grafana-on-raspberry/releases/download/v4.3.2/grafana_4.3.2_armhf.deb
sudo dpkg -i grafana_4.3.2_armhf.deb
sudo apt-get install -f

Configure grafana server

Edit /etc/grafana/grafana.ini with your favorite editor.

There are lots of options there, but you should, at least enable the ones bellow:

Under the [paths] section uncomment the following lines

data = /var/lib/grafana
logs = /var/log/grafana
plugins = /var/lib/grafana/plugins

Under the [server] section uncomment the following lines

protocol = http
http_port = 3000

Under the [database] section uncomment the following lines. Grafana needs to store it’s metadata in a database. It comes with sqlite, which I am going to use. Alternatively you could configure it to use mysql if you wish.

type = sqlite3

Under the [security] section uncomment the following lines

admin_user = admin
admin_password = admin

Under the [auth.basic] section uncomment the following lines

enabled = true

Start grafana-server

sudo service grafana-server start

Check if server is running

sudo service grafana-server status

Check if grafana UI is running properly. Open web browser and enter grafana web server URL: http://<management server IP>:3000

Enable startup on boot

sudo update-rc.d grafana-server defaults

In case the service doesn’t start automatically after boot you can fix it by running

sudo systemctl enable grafana-server.service

Download and install rig-monitor

Download the zip or clone the repo from here.

The package includes the following scripts:

  • update-rig-info.sh – Read rig info from config file (./conf/rig-monitor.conf) and push it to DB. This will run from crontab once a day, but it can also be run manually to update rig changes.
  • rig-monitor.sh – Read rig and gpu status info from claymore via remote management port. If smart plugs option is enabled and configured it will also collect power rig power consumption. This scrip will run from crontab every minute.
  • pool-monitor.sh – Read from all pool/wallet combinations defined in config file. This will run from crontab every 10 mins as most pools only update the API data every 10 mins as well.
  • coinmarket.sh – Read from all base/quote cunrrency combinations from coinmarketcap.com. This script will run from crontab every 5 mins
  • cleanup.sh – Clean up old data from DB and backup old logs to data_bkup dir

Configuration

The following options can be configured by editing the config file (./conf/rig-monitor.conf)

Mysql user account and password which will be used to ingest and read rig, gpu info and data.

GRAFANA_DB_USER='grafana'
GRAFANA_DB_PWD='grafana'

Date format used in data file name. DDMMYYYY (default) or MMDDYYYY

DATE_FORMAT='DDMMYYYY'

Smart plugs configured (default). This is required if power usage monitoring is required (and TPLINK HS110 plugs are configured.

SMART_PLUGS=1

Data retention period in days (default=7). If you want to manage 10+ rigs with a data retention longer than 2-3 days then I suggest to user a more power raspberry pi or server.

DATA_RETENTION=7

Read config file (./conf/rig-monitor.conf) and update rig info interval (in minutes). Default is 1 day

RIG_INFO_UPDATE=1440

List of rigs. Add the details of the rigs to be monitored. Fields (in order):

  • RIG NAME
  • RIG IP
  • PLUG IP
  • # of INSTALLED GPUS
  • TARGET HASHRATE ETHEREUM, TARGET HASHRATE DECRED/SIACOIN/LBRY/PASCAL (can be left empty if not in use)
  • TARGET TEMP
  • MAX POWER
RIG_LIST=(
'riglx01,192.168.2.7,192.168.2.70,6,180,,75,1200'
'riglx02,192.168.2.8,192.168.2.80,5,180,,75,1200'
'riglx03,192.168.2.9,192.168.2.90,6,180,,75,1000'
)

List of pools/wallets. Add the details of the pools/wallets to be monitored. Fields (in order):

  • POOL_TYPE – pool backend backend e.g. ethermine, mpos, etc..
  • CURRENCY – only used for nanopool L E.G.
  • ETH,ETC,ZEC,SIA,PASC,XMR
  • LABEL – to differentiate between pools using same backend e.g. MPOS API_URL -URL for pool API e.g. https://api.ethermine.org
  • API_TOKEN – required for pools that need API token to pull stats e.g. miningpoolhub
  • WALLET_ADDRESS – some MPOS pools use the API token instead of the wallet address to uniquely identify miners
POOL_LIST=( 
'ETHERMINE,NOT_USED,ETHERMINE,https://api.ethermine.org,N0T_USED,0x2e4af23c44fa2e7483cef44125c3dbe998fe5a81'
'MPOS,NOT_USED,MUSICOIN,http://musicoin.miningpoolhub.com,e357aca77c7ae88bc067d30e7f0fff269587586e797b531959278f120a4b62ff,NOT_USED'
'NANOPOOL,SIA,NANOPOOL,https://api.nanopool.org,NOT_USED,3007a5b3b4cfdb3e21333a9f8bbea62e3d57e54bf17c134e5f4d2b5c64aab88ab63a07475233'
)

List of currency pairs. Fields (in order)

Currency pairs: base currency/quote currency

Valid valued for quote currency are: “AUD”, “BRL”, “CAD”, “CHF”, “CLP”, “CNY”, “CZK”, “DKK”, “EUR”, “GBP”, “HKD”, “HUF”, “IDR”, “ILS”, “INR”, “JPY”, “KRW”, “MXN”, “MYR”, “NOK”, “NZD”, “PHP”, “PKR”, “PLN”, “RUB”, “SEK”, “SGD”, “THB”, “TRY”, “TWD”, “USD”,”ZAR”

COIN_LIST=(
'bitcoin,EUR'
'ethereum,EUR'
'musicoin,EUR'
)

Create DB and rig-monitor metadata

The command below with create the grafana user in mysql and required DB tables. If you have changed the GRAFANA_DB_USER and GRAFANA_DB_PWD in the config file then you should edit <rig-monitor dir>/sql/create_db.sql accordingly

mysql -u root -p<mysql root password> < ./rig-monitor/sql/create_db.sql

If you have problems accessing mysql then simply try entering the password manually.

mysql -u root

If that fails then check the solution here

Populate the DB with the existing rig info by runnning

./update-rig-info.sh

Configuring remote access to grafana (optional)

I needed to access the dashboards remotely, but I don’t want to make the grafana web server directly accessible via the internet; you know because of vulnerabilities. There are multiple ways to do this e.g. VPN, SSH tunnel, etc… I chose the SSH tunnel because of simplicity.

  • Make my raspberry pi accessible from the internet via SSH. You’ll have to configure your internet router to route traffic from whatever port you want to use to your router’s SSH port. I am using port 19000 so basically traffic router to my gateway public IP address (e.g. 8.8.8.8:19000) will be routed to my server SSH ip and port (e.g. 192.168.2.100:22)
  • Use a Dynamic DNS service to keep my domain name and IP updated and accessible. I am using dynu.com (they have a free tier), but you can chose another.
    • Register at dynu.com
  • Create your DNS entry
  • Update the config file (<rig-monitor dir/conf/rig-monitor.conf) with the DYNU credentials and host name
# dynu username
DYNU_USER='dynu'
# dynu username
DYNU_PWD='dynu'
# dynu hostname
DYNU_HOST='myhost.domain.com'

Update crontab

Add following entries to crontab

35 * * * * <rig-monitor dir>/dns_update.sh > /dev/null
0 1 * * * <rig-monitor dir>/update-rig-info.sh > /dev/null
* * * * * <rig-monitor dir>/rig-monitor.sh > /dev/null
*/10 * * * * <rig-monitor dir>/pool-monitor.sh > /dev/null
*/10 * * * * <rig-monitor dir>/coinmarket.sh > /dev/null
0 2 * * * <rig-monitor dir>/cleanup.sh > /dev/null

Configure grafana DB source

Now log on as admin to grafana via browser (http://<server ip>:3000). Go to Data Sources, click add and fill out the following fields:

Name: rigdatadb
Type: MySQL
Host: localhost:3306
Database: rigdata
User: grafana
Password: grafana

Click ‘Save & Test’. Everything should be working now.

Import dashboards

Import template dashbords via sqlite:

sudo sqlite3 /var/lib/grafana/grafana.db
sqlite> .separator ","
sqlite> .import dashboards.csv dashboard
sqlite> .quit

Set grafana alerts

Grafana supports multiple alert methods. Currently I am using telegram so forward alter notifications to my cell phone. This is how you do it

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.

Access grafana dashboads via SSH tunnel

Open SSH client tunnel with following command

ssh -L 8080:<ip address of raspberry pi>:3000 pi@<dynu hostname> -p 19000

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

Leave me a comment if you have any issues/questions.
—————————————————————————————————–
Did you enjoy this post? Buy me a beer
ETH: 0x0f2d4397CecB53883411cfe75882622c312c8340
MUSICOIN: 0x9a44a57041acd5f1511bf13a663d136ddbde1fb1

Leave a Reply

Your email address will not be published. Required fields are marked *