Last active
April 12, 2018 11:48
-
-
Save stralex7/29b02159af174eff1556bb62da480077 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import socket | |
import json | |
import time | |
import os | |
import sys | |
# reset if mh drops below this num | |
min_hashes=61900 | |
# time for reboot + claymore to get share and start hashing | |
loop_seconds = 60 | |
delay_seconds = 90 | |
host='127.0.0.1' | |
port=8080 | |
def check_rig(host,port): | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
try: | |
s.connect((host, port)) | |
print("connected") | |
s.send('{"id":0,"jsonrpc":"2.0","method":"miner_getstat1"}\n'.encode("utf-8")) | |
j=s.recv(2048) | |
s.close() | |
resp=json.loads(j.decode("utf-8")) | |
resp=resp['result'] | |
res0 = resp[2].split(';') | |
hashes = int(res0[0]) | |
print("KH/s=" + str(hashes) + " Accepted:" +res0[1]+" Rejected:"+res0[2]) | |
hash_ok=min_hashes < hashes | |
print("hashes ok is: " + str(hash_ok)) | |
sys.stdout.flush() | |
return hash_ok | |
except TimeoutError: | |
print("connection timeout") | |
sys.stdout.flush() | |
except ConnectionRefusedError: | |
print("connection refused") | |
sys.stdout.flush() | |
except: | |
print("exception") | |
sys.stdout.flush() | |
return False | |
print("Initial start delay") | |
sys.stdout.flush() | |
time.sleep(delay_seconds) | |
# main loop | |
while True: | |
if not check_rig(host,port): | |
print("resetting rig") | |
os.system('/sbin/reboot') | |
# else: | |
# print("rig ok!") | |
# print( "loop sleep" ) | |
time.sleep(loop_seconds) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Enable logs from previous boots: