minerstat mining tutorial #32: Custom mining clients
Before introducing this new feature to all of the minerstat users, implementation of the custom miner required you to write to us and request a custom miner, which we would then implement and prepare for your usage. From now on, you are able to implement your own custom mining client by yourself. This doesn’t mean we will stop adding new mining clients per request but gives all of you an option to use a custom mining client without any delay. It also gives farms an opportunity to have control over their own private miners without anyone accessing the mining client files.
Our goal was to create this feature in a way that allows flexibility as much as privacy.
In this tutorial, we will show you two things:
- How to prepare a package that can be used as a custom mining client with minerstat mining OS.
- How to create a new mining client on your minerstat dashboard and then use it in the worker’s config. The same procedure can be applied to the scheduler, config templates, and profit switch.
💡 While the second step is very straightforward and its difficulty is not much different than using the minerstat dashboard, the first one requires some development and programming knowledge.
1. Preparing mining client’s package
In this tutorial, we will show you an example of how to create a package for implementing ArioMiner. We decided to use this miner as an example as it was previously suggested for implementation by one of our customers and the fact that ArioMiner doesn’t use JSON API for reporting. From the point of mining management software, it is really welcome of mining client developers to provide a JSON API. From this example, you can see that you can use minerstat mining OS even if there is no JSON API report.
The package that you will prepare for msOS should contain:
- The mining client and all of its files.
- Modified API file (you can find the template here).
To check the files while you are reading this tutorial, you can first download the prepared package. The package is a
.zip file that contains two files:
The first is executable mining client with all necessary files and the second is a modified
api file. Since ArioMiner doesn’t report the results, we will enable logging that will save some of the data to
log.txt file. The API bash script will then read the data that is available in the
log.txt and serve it in the required format. If you will be implementing any other mining client, its approach might be different and the data will need to be read differently.
Let’s take a look at the
Hashrate (in H/s)
To read the hashrate from the
log.txt file, the following code is used.
hashrate_total=$(tac /home/minerstat/minerstat-os/clients/ariominer/log.txt | grep "Hash Rate:" | head -n 1 | cut -f1 -d"/" | sed 's/[^0-9.]*//g' | cut -f1 -d".")
Please note that hashrate must always be provided in H/s (1 kH/s = 1 000 H/s; 1 MH/s = 1 000 000 H/s; 1 GH/s = 1 000 000 000 H/s; and so on).
Uptime (in seconds)
To read the uptime in seconds from the
log.txt file, the following code is used.
uptime_in_sec=$(tac /home/minerstat/minerstat-os/clients/ariominer/log.txt | grep "Time:" | head -n 1 | sed 's@.*Time: @@' | cut -f1 -d"S" | sed 's/[^0-9.]*//g')
Please note that uptime must always be provided in seconds.
log.txt doesn’t report information about the pool. Because of this, we have to enter the pool data manually.
To read the accepted and rejected shares from the
log.txt file, the following code lines are used.
shares_accepted=$(tac /home/minerstat/minerstat-os/clients/ariominer/log.txt | grep "Shares:" | head -n 1 | sed 's@.*Shares: @@' | cut -f1 -d"F" | sed 's/[^0-9.]*//g')
shares_rejected=$(tac /home/minerstat/minerstat-os/clients/ariominer/log.txt | grep "Rejected:" | head -n 1 | sed 's@.*Rejected: @@' | sed 's/[^0-9.]*//g')
At the end of the file, the following format must stay unchanged.
Without that last line, the data would not get processed and sent from msOS to your minerstat dashboard.
So, when you have both mining client executables and API file ready, you can compress them in a .zip or .tar.gz and upload it to your selected server (even local one that is accessible only from the rig).
2. Adding mining client to the dashboard
The next step is to add the mining client to the dashboard. Navigate to the custom clients page. Click on the button to add a new mining client and enter all necessary information. Each mining client requires the following information: name, package URL, executable file name, client config type, client args/config, and extra args.
For ArioMiner example we will add the following information.
The name is used on the dashboard, worker’s config, profit switch, config templates, and scheduler.
The URL to your mining client. It can also be a local URL or URL that is accessible only from your rig which assures you maximum possible privacy.
Executable file name
The first file you have created in the first step of this tutorial. The name is case sensitive.
Client config type
If your mining client reads configs from the external file, select
Config file and if your mining client reads configs from arguments, select
Provide default config for your client.
--mode miner--pool http://aropool.com:80/ --wallet 4fAkEHALahEbDRobAbJgW3Mi9eTFNK2dTa7VD6ngR4ve1znXhh1jX3RoHibUdttGCoGAjLtcSLWJRvXTbaL4g3CK --name test -c 0 -g 93 -x 100
Define extra arguments that will be called on the client run. We will enable logging by adding an extra argument as defined below. This will allow API bash script to read the information about hashrate, uptime, and rejected and accepted shares.
| tee log.txt
When you have entered all of the fields you can click Save.
The next step is to navigate to the worker’s config page and select your new mining client as a default mining client. All custom mining clients are denoted with blue color. Enter your configuration and save changes.
msOS will download the mining client from the URL you provided and prepare everything for your miner to start running under defined conditions.
You are now mining with your new, custom mining client.
More from this series:
- How to start
- Overclock with ClockTune™
- Alerts and triggers
- Profit switch and mining calculator
- Team and customers
- Balance monitoring
- Statistics and data exporting
- How to organize and use groups
- Billing and payments
- Worker configuration
- Control room
- Locator and bulk imports
- 24h logs and diagnostic
- How to replace a mining client