Hearing about Ethereum Mining
A friend of mine started mining Ethereum after sharing a coworking space with some large scale miners.
He told me about it and since I already had a gaming PC with an old graphics card, it seemed like a good reason to upgrade.
Procuring the hardware
When we started looking into it in June 2017, Ethereum mining was really popular. To the point that you could not buy a current generation graphics card.
Every store, online or otherwise was sold out and had massive waiting lists.
I collected the bookmarks of all the sites that were likely to have stock of them at some point, kept checking them several times a day and eventually got lucky.
I spotted a Gigabyte AMD Radeon RX580 Gaming 8GB Graphics Card in stock on ebuyer.com one evening for a decent price. The problem was that the page was broken, it wouldn't allow me to add it to my basket.
The next day I called them as soon as they opened and told them about the broken page.
They fixed it while I was on the phone and I bought it as soon as I hung up.
5 minutes later it was out of stock again.
EthOs mining Operating System
I looked into mining on Windows and Linux and was introduced to EthOs by a friend.
The idea is that it is an operating system, dedicated to mining.
You boot it up, edit the config to point it at your pool and your wallet and it just starts mining.
It works really well, for single GPU configurations like mine or multi GPU like my friend Chris used, who introduced me to Ethereum and EthOs.
The hashrate monitoring script
The only problem that I had with EthOs, is that if a worker crashes, it just sits there until you notice, using electricity, but not mining.
This happened to me a few times and is really frustrating.
The solution is to reboot the machine, which always gets it running again with no issues.
So, my idea was to create a script that could run on a cronjob and detect worker crashes and reboot the machine.
This is what I came up with:
Push notification for crashes
As part of the script, I integrated the pushover notification service.
I had used it before for tasks at work.
It is really easy to set up and in combination with the android app, gets me notifications directly to my phone that I can trigger for any reason.
So as part of this script, I have 2 notifications set up.
- One to notify me when the script triggers a reboot
- One for when the system boots up into EthOs properly
Problems I had to overcome
I came across a few problems that I had to debug and fix before arriving at the script above.
Debugging was really frustrating, as it meant waiting for a worker to crash, which was intermittent and sometimes took a couple weeks between crashes.
The first problem that I hit was that the original regular expression I wrote checked for 2 decimal places, which is what a running hashrate gives you, but when it crashes it gives a single number '0'.
I managed to figure this one out by running the script manually when it had crashed with some debugging statements, found the issue, fixed it and when I ran the fix, it rebooted the system.
So at this point, I was confident that it worked because I had manually run it in a crashed worker state and it had rebooted the machine as it should.
A few weeks later, I had the worker crash and it did not reboot automatically.
I ran the script manually and it rebooted as expected, so it was a problem with running it as a cronjob.
After some debugging and advice, it turned out to be the relative paths in the script, like to the check file and to the
/opt/ethos/bin/r command that reboots the machine.
I sorted those out and hoped for the best.
A week later, I got a pushover notification on my phone that my machine had been rebooted because of a crashed worker and that it was back up and running.