Skip to content

Commit

Permalink
Added pool checkers
Browse files Browse the repository at this point in the history
Runs independent of bot, as backup.
  • Loading branch information
o4ugDF54PlqU committed Jul 5, 2021
1 parent 22842a3 commit 430f0e8
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 1 deletion.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ I wrote this on and for Windows and ethminer, so other platforms and miners will

Don't forget to put in your bot key from discord.

Comes with a pool checker script independent of Discord as backup.

# Setup
1. Install python 3
1. Install dependencies with setup.py or manually
Expand All @@ -22,9 +24,10 @@ Don't forget to put in your bot key from discord.
- times_to_check is the number of consecutive times the pool hashrate must be below desired_hash before rebooting, just to make sure (note: pool apis update once every 10 minutes)
- worker_name is the name of your worker, same as the one set in ethminer
1. To get the "ping" command to work correctly, you'll need to install wkhtmltopdf for imgkit. Instructuctions: https://pypi.org/project/imgkit/
1. Add the bot to the startup folder/task scheduler
1. Add the bot to the startup folder/task scheduler/crontab
- If you want to hide the bot window, simply rename the script extension from .py to .pyw
1. **Make sure to put --api-bind 127.0.0.1:3333 in your ethminer script**
1. Optional: repeat above steps for the independent pool checker if you want a backup in case you lose internet and the bot breaks or something. The checker will only check once (3 times over 30 minutes by default), so you need to set it up to repeat in task scheduler.

# Features:
- Sends a message to a predetermined channel on reboot (useful to know when a power outage happens or keep track of instability)
Expand All @@ -35,6 +38,7 @@ Don't forget to put in your bot key from discord.
- Checks with pool API every 10 minutes. If hashrate lower than limit times_to_check times in a row, @everyone, reboot and send screenshot for diagnostic.
- Also does a ping every check. Simply delete if you don't want periodic data.
- For the multi versions, simply add the worker name in front of each command (eg "worker001 reboot")
- Backup pool checkers that work independently of the Discord API. Will also reboot if a connection cannot established to the pool for 30 minutes in a row. Note: This is a new feature and has not been tested extensively yet.
- Bonus: ethermine calculator, calculates 24h shares because the default 1h is dumb

![image](https://user-images.githubusercontent.com/36900762/115118918-e725e880-9fcf-11eb-87a4-a74c10ae2ff7.png)
Expand Down
54 changes: 54 additions & 0 deletions ethermine checker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import json
import requests
import time
import os

# pool hash check, reboot if hash lower than desired_hash times_to_check times in a row
address = "696b18d7e003be5b4d1a66b981313e1959d69066"
desired_hash = 169000000
times_to_check = 3
worker_name = "worker001" # I don't think it's case sensitive

desired_log = []

time.sleep(60)

while times_to_check > 0:
time.sleep(600)
try:
r = requests.get(f'https://api.ethermine.org/miner/:{address}/workers')
found_worker = False

for worker in r.json()["data"]:

if worker["worker"] == worker_name:

if worker["reportedHashrate"] < desired_hash:
current_hash = worker["reportedHashrate"]
print(f"low hash detected: {current_hash}")
desired_log.append(False)

else:
print("satisfactory hashrate")
desired_log.append(True)

found_worker = True
break

if found_worker == False:
print("worker not found on pool")
desired_log.append(False)

except requests.ConnectionError:
print("error, no internet")
desired_log.append(False)
except AttributeError:
print("not logged on yet")
desired_log.append(False)

times_to_check -= 1

if any(desired_log):
print("satisfactory")
else:
os.system("shutdown -t 10 -r")
42 changes: 42 additions & 0 deletions hiveon checker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import json
import requests
import time
import os

# pool hash check, reboot if hash lower than desired_hash times_to_check times in a row
address = "696b18d7e003be5b4d1a66b981313e1959d69066"
desired_hash = 169000000
times_to_check = 3
worker_name = "WORKER001" # note: case sensitive

desired_log = []

time.sleep(60)

while times_to_check > 0:
time.sleep(600)
try:
r = requests.get(f'https://hiveon.net/api/v1/stats/miner/{address}/ETH/workers')
worker_data = r.json()["workers"][worker_name]

if int(worker_data["reportedHashrate"]) < desired_hash:
current_hash = r.json()["reportedHashrate"]
print(f"low hash detected: {current_hash}")
desired_log.append(False)
else:
print("satisfactory hashrate")
desired_log.append(True)

except requests.ConnectionError:
print("error, no internet")
desired_log.append(False)
except KeyError:
print("not in pool")
desired_log.append(False)

times_to_check -= 1

if any(desired_log):
print("satisfactory")
else:
os.system("shutdown -t 10 -r")

0 comments on commit 430f0e8

Please sign in to comment.