In [my last post](https://steemit.com/monero/@masterlamps/create-fancy-graph-with-metrics-from-xmrig-1-3) I showed how to configure the [HTTP API](https://github.com/xmrig/xmrig/blob/master/doc/API.md) of [XMRIG](https://github.com/xmrig/xmrig/releases/tag/v5.11.1) and query it with [curl](https://curl.haxx.se/), now I will use my [Raspberry Pi 2 Model B](https://www.raspberrypi.org/products/raspberry-pi-2-model-b/) to query my rigs and store the retrieved data in an [InfluxDB](https://www.influxdata.com/products/influxdb-overview/). # Install [InfluxDB](https://www.influxdata.com/products/influxdb-overview/) [InfluxDB](https://www.influxdata.com/products/influxdb-overview/) is an time series database develeped by [InfluxData](https://www.influxdata.com/). It is written in Go and glorified for being a single binary and optimized for fast, high-availability storage and retrieval of time series data from different source like IoT devices, application metrics or network operation monitoring. It provides a SQL like querie language and differnt accees like API calls or CLI. ## Add the [InfluxDB](https://www.influxdata.com/products/influxdb-overview/) repository to the rpi Dependening on the version of Debian is running on your Raspberry Pi different Urls are necessary to be added to the respository of the paket manager. The following code will add Url according to the used Debian version. <code>wget -qO- https://repos.influxdata.com/influxdb.key | sudo apt-key add - source /etc/os-release test $VERSION_ID = "7" && echo "deb https://repos.influxdata.com/debian wheezy stable" | sudo tee /etc/apt/sources.list.d/influxdb.list test $VERSION_ID = "8" && echo "deb https://repos.influxdata.com/debian jessie stable" | sudo tee /etc/apt/sources.list.d/influxdb.list test $VERSION_ID = "9" && echo "deb https://repos.influxdata.com/debian stretch stable" | sudo tee /etc/apt/sources.list.d/influxdb.list test $VERSION_ID = "10" && echo "deb https://repos.influxdata.com/debian buster stable" | sudo tee /etc/apt/sources.list.d/influxdb.list sudo apt-get update</code> ### Install [InfluxDB](https://www.influxdata.com/products/influxdb-overview/) <code>sudo apt-get install influxdb</code> ### Start service provided from the installation package <code>sudo service influxdb start</code> ### Configure [InfluxDB](https://www.influxdata.com/products/influxdb-overview/) [InfluxDB](https://www.influxdata.com/products/influxdb-overview/) come with multiple configuration options and default configuration can beviewed with <code>influxd config</code>. The service use the configuration file stored in /etc/influxdb/influxdb.conf, but most of the options are commented out. [InfluxDB](https://www.influxdata.com/products/influxdb-overview/) uses for uncommented options the defaults settings. In order to enable HTTP requests with configuration of the service needs to be changed. For this remove the # for options **enabled, bind-address and auth-enabled** in configuration file. To change the configuration of the service open it with a text: <code>sudo nano /etc/influxdb/influxdb.conf</code>  After that restart the service so the change can be take effect. <code>sudo service influxdb restart</code> ### Connect to [InfluxDB](https://www.influxdata.com/products/influxdb-overview/) instance The backend is now setup now for access the data managed by the service an additional package is necessary. For access the databases in CLI install **influxdb-client**. <code>sudo apt-get install influxdb</code>  ### Access the databases The managed databases by [InfluxDB](https://www.influxdata.com/products/influxdb-overview/) are accessable by <code>show databases</code>  ### Create database for the metrics The metrics of the rigs shall be stored in their own database called **rigs**. Databases are created with <code>CREATE DATABASE rigs</code>.  ### Test database Before you can insert or select data, you have to select on databases with <code>use rigs</code>.  [InfluxDB](https://www.influxdata.com/products/influxdb-overview/) provides a SQL like language and INSERT statement like this: <code>insert xmrigs,rig=testrick,currency=rx/0 value=12344.32</code> This statement will create table called xmrigs with attributes rig, currency and the measure value 12344.32. The time stamp will be automatically added by the database. The data can queried by: <code>select * from xmrigs</code>  # Collect metrics from [XMRIG](https://github.com/xmrig/xmrig/releases/tag/v5.11.1) rigs The data will be collected by a script for each rig, which queries the rig HTTP API, parse HTTP result and store the date in database. The data will be queried periodcally by cronjobs. ## Query rigs API First I created the script with collecting the data from the [XMRIG HTTP API](https://github.com/xmrig/xmrig/blob/master/doc/API.md), parse the resulting [JSON](https://en.wikipedia.org/wiki/JSON), and extract with [jq](https://stedolan.github.io/jq/) the fields I need. [XMRIG](https://github.com/xmrig/xmrig/releases/tag/v5.11.1) offers diffrent endpoints, I will use /1/summary. From this endpoint I will collect the **worker-id, algo and first entry the hashrate table**. <code>#collect data from API json=$(curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer wWhearsgoL4w6zPT" http://x.x.x.x:9971/1/summary) #extract hashrate, worker_id, currency hashrate=$(echo $json | jq -r '.hashrate.total[0]') workerid=$(echo $json | jq -r '.worker_id') currency=$(echo $json | jq -r '.algo')</code> ## Store Data in [InfluxDB](https://www.influxdata.com/products/influxdb-overview/) After that I extended that script with a call to the HTTP API of [InfluxDB](https://www.influxdata.com/products/influxdb-overview/). For writing data, the endpoint /write is used. It is uses as query option the database you want to write to and takes as binary data the data to write. <code>curl -i -XPOST 'http://localhost:8086/write?db=rigs' --data-binary "xmrigs,rig=$workerid,currency=$currency value=$hashrate"</code> ## Create cronjobs for data retrieval The periodacal execution of the retrieval script, I will do with cronjobs. The metrics shall be queried every minute, which 5 * for each script call. To open the crontab call <code>crontab -e</code>.  After some time the database should be filled with some entries from different rigs.  Now the database is setup and filled with data on timely manner. Installing [Grafana](https://grafana.com/) and creating a dashboard for the data I will do in another post. Please up vote, comment and resteem my post. If you like this please donate to 42D2sPUubqCCqK3MD8BnDDSyjgNqbrLH6HcHXrZWaqYZfUqyoDcRsfTQNp345N1NSDLr8qBJ5QqjQ4V95nix6qH9Je8BX2U Thank you so much in advance.
author | master-lamps | ||||||
---|---|---|---|---|---|---|---|
permlink | create-fancy-graph-with-metrics-from-xmrig-2-3 | ||||||
category | monero | ||||||
json_metadata | {"links":["https://steemit.com/monero/@masterlamps/create-fancy-graph-with-metrics-from-xmrig-1-3","https://github.com/xmrig/xmrig/blob/master/doc/API.md","https://github.com/xmrig/xmrig/releases/tag/v5.11.1","https://curl.haxx.se/","https://www.raspberrypi.org/products/raspberry-pi-2-model-b/","https://www.influxdata.com/products/influxdb-overview/","https://www.influxdata.com/products/influxdb-overview/","https://www.influxdata.com/products/influxdb-overview/","https://www.influxdata.com/","https://www.influxdata.com/products/influxdb-overview/","https://repos.influxdata.com/influxdb.key","https://repos.influxdata.com/debian","https://repos.influxdata.com/debian","https://repos.influxdata.com/debian","https://repos.influxdata.com/debian","https://www.influxdata.com/products/influxdb-overview/","https://www.influxdata.com/products/influxdb-overview/","https://www.influxdata.com/products/influxdb-overview/","https://www.influxdata.com/products/influxdb-overview/","https://www.influxdata.com/products/influxdb-overview/","https://www.influxdata.com/products/influxdb-overview/","https://www.influxdata.com/products/influxdb-overview/","https://github.com/xmrig/xmrig/releases/tag/v5.11.1","https://github.com/xmrig/xmrig/blob/master/doc/API.md","https://en.wikipedia.org/wiki/JSON","https://stedolan.github.io/jq/","https://github.com/xmrig/xmrig/releases/tag/v5.11.1","http://x.x.x.x:9971/1/summary","https://www.influxdata.com/products/influxdb-overview/","https://www.influxdata.com/products/influxdb-overview/","http://localhost:8086/write?db=rigs","https://grafana.com/"],"image":["https://images.esteem.app/DQmWX6NqMyTu8R1sHPVE69MCsnZNBBJgpRpkFHrP3NGZLZs/image.png","https://images.esteem.app/DQmVKAJTi6WgszM2n3qyYfVaTK32sJAGaoLXB7Q6BXjWPXA/image.png","https://images.esteem.app/DQmUNSBcP6tqT6MBVNdUAaGRCp3yvVtRZPK2f7xAVBY9wWJ/image.png","https://images.esteem.app/DQmcUjxXXW3YhjHeTeDeSCqsuWZdWiMXL5AVocUKbrp2oyS/image.png","https://images.esteem.app/DQmUQ4QprtbsExHtpvZmBwLDBSUSz6JmRiRzgozxz5c9HSC/image.png","https://images.esteem.app/DQmcNEeFkePWnV5pHu23inruAZ3SeN81xSMPabbvrQy4cLz/image.png","https://images.esteem.app/DQmcJcTJ1swr9xbqq5L34EjEzqJNVec8brkajfY3vAX2v7g/image.png","https://images.esteem.app/DQmaktDBrxXGAgKteTJjJYw5GF7Yf3RsbchJwzPDV3mprrZ/image.png"],"tags":["monero","xmrig","xmr","influxdb","grafana","raspberrypi","metrics"],"app":"esteem/2.2.7-surfer","format":"markdown+html","community":"esteem.app"} | ||||||
created | 2020-05-21 15:30:03 | ||||||
last_update | 2020-05-21 15:30:03 | ||||||
depth | 0 | ||||||
children | 3 | ||||||
last_payout | 2020-05-28 15:30:03 | ||||||
cashout_time | 1969-12-31 23:59:59 | ||||||
total_payout_value | 0.414 HBD | ||||||
curator_payout_value | 0.425 HBD | ||||||
pending_payout_value | 0.000 HBD | ||||||
promoted | 0.000 HBD | ||||||
body_length | 7,520 | ||||||
author_reputation | 64,188,838,587,049 | ||||||
root_title | "Create Fancy Graph with metrics from XMRIG (2/3)" | ||||||
beneficiaries |
| ||||||
max_accepted_payout | 1,000,000.000 HBD | ||||||
percent_hbd | 10,000 | ||||||
post_id | 97,505,856 | ||||||
net_rshares | 2,386,205,262,041 | ||||||
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
good-karma | 0 | 400,626,797,273 | 40.95% | ||
demo | 0 | 300,961,117 | 40.95% | ||
feruz | 0 | 2,529,611,318 | 40.95% | ||
esteemapp | 0 | 1,971,593,165,105 | 40.95% | ||
spoylerbg | 0 | 0 | 100% | ||
tomaszs77 | 0 | 0 | 100% | ||
esteem.app | 0 | 6,526,697,458 | 40.95% | ||
machroezar | 0 | 752,754,207 | 20.47% | ||
peeyush | 0 | 0 | 4% | ||
mini-zephalexia | 0 | 2,680,489,915 | 32.76% | ||
wirago | 0 | 0 | 100% | ||
valentin86 | 0 | 0 | 100% | ||
yayan | 0 | 995,633,992 | 20.47% | ||
demo123 | 0 | 199,151,656 | 100% | ||
muntaharaceh | 0 | 0 | 100% | ||
naythan | 0 | 0 | 100% | ||
golden.future | 0 | 0 | 18% | ||
ciriz | 0 | 0 | 100% | ||
der-fahrlehrer | 0 | 0 | 99% | ||
masterlamps | 0 | 0 | 100% | ||
walarhein | 0 | 0 | 60% | ||
peterpanpan | 0 | 0 | 10% | ||
parung76 | 0 | 0 | 100% | ||
vedan-san | 0 | 0 | 100% | ||
sidjay | 0 | 0 | 100% | ||
kyawkyawaung123 | 0 | 0 | 100% | ||
pyramidone | 0 | 0 | 100% | ||
skohieone | 0 | 0 | 100% | ||
kingturk | 0 | 0 | 100% | ||
farshad1298 | 0 | 0 | 100% | ||
pmm.podcasts | 0 | 0 | 100% | ||
anewlakdk84 | 0 | 0 | 100% |
**Yay!** <br>Your post has been **boosted with ESTM**. Keep up the good work! <br>Dear reader, Install Android: https://android.esteem.app, iOS: https://ios.esteem.app mobile app or desktop app for Windows, Mac, Linux: https://desktop.esteem.app<br>Learn more: https://esteem.app <br>Join our discord: https://discord.me/esteem
author | esteemapp |
---|---|
permlink | re-2020522t81617872z |
category | monero |
json_metadata | {"tags":["esteem"],"app":"esteem/2.2.6-welcome","format":"markdown+html","community":"hive-125125"} |
created | 2020-05-22 06:16:18 |
last_update | 2020-05-22 06:16:18 |
depth | 1 |
children | 0 |
last_payout | 2020-05-29 06:16:18 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 327 |
author_reputation | 420,443,679,514,793 |
root_title | "Create Fancy Graph with metrics from XMRIG (2/3)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 97,517,112 |
net_rshares | 0 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
skohieone | 0 | 0 | 100% |
Congratulations @master-lamps! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s) : <table><tr><td><img src="https://images.hive.blog/60x70/http://hivebuzz.me/@master-lamps/upvotes.png?202005312047"></td><td>You distributed more than 400 upvotes. Your next target is to reach 500 upvotes.</td></tr> </table> <sub>_You can view [your badges on your board](https://hivebuzz.me/@master-lamps) And compare to others on the [Ranking](https://hivebuzz.me/ranking)_</sub> <sub>_If you no longer want to receive notifications, reply to this comment with the word_ `STOP`</sub> **Do not miss the last post from @hivebuzz:** <table><tr><td><a href="/hivebuzz/@hivebuzz/shop"><img src="https://images.hive.blog/64x128/https://i.imgur.com/soiD80C.png"></a></td><td><a href="/hivebuzz/@hivebuzz/shop">Introducing HiveBuzz Shop - Offer gifts with your favorite badges</a></td></tr></table> ###### Support the HiveBuzz project. [Vote for our proposal](https://hivesigner.com/sign/update_proposal_votes?proposal_ids=%5B%22109%22%5D&approve=true)!
author | hivebuzz |
---|---|
permlink | hivebuzz-notify-master-lamps-20200531t211913000z |
category | monero |
json_metadata | {"image":["http://hivebuzz.me/notify.t6.png"]} |
created | 2020-05-31 21:19:12 |
last_update | 2020-05-31 21:19:12 |
depth | 1 |
children | 0 |
last_payout | 2020-06-07 21:19:12 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 1,094 |
author_reputation | 369,474,964,709,674 |
root_title | "Create Fancy Graph with metrics from XMRIG (2/3)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 97,698,726 |
net_rshares | 0 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
skohieone | 0 | 0 | 100% |
Great work.
author | masterlamps | ||||||
---|---|---|---|---|---|---|---|
permlink | re-master-lamps-2020521t23746821z | ||||||
category | monero | ||||||
json_metadata | {"tags":["monero","xmrig","xmr","influxdb","grafana","raspberrypi","metrics"],"app":"esteem/2.2.7-surfer","format":"markdown+html","community":"esteem.app"} | ||||||
created | 2020-05-21 21:07:51 | ||||||
last_update | 2020-05-21 21:07:51 | ||||||
depth | 1 | ||||||
children | 0 | ||||||
last_payout | 2020-05-28 21:07:51 | ||||||
cashout_time | 1969-12-31 23:59:59 | ||||||
total_payout_value | 0.000 HBD | ||||||
curator_payout_value | 0.000 HBD | ||||||
pending_payout_value | 0.000 HBD | ||||||
promoted | 0.000 HBD | ||||||
body_length | 11 | ||||||
author_reputation | 220,443,053 | ||||||
root_title | "Create Fancy Graph with metrics from XMRIG (2/3)" | ||||||
beneficiaries |
| ||||||
max_accepted_payout | 1,000,000.000 HBD | ||||||
percent_hbd | 10,000 | ||||||
post_id | 97,510,885 | ||||||
net_rshares | 8,665,606 | ||||||
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
master-lamps | 0 | 8,665,606 | 100% |