Skip to content

Instantly share code, notes, and snippets.

@stralex7
Last active April 12, 2018 11:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stralex7/29b02159af174eff1556bb62da480077 to your computer and use it in GitHub Desktop.
Save stralex7/29b02159af174eff1556bb62da480077 to your computer and use it in GitHub Desktop.
#!/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)
@stralex7
Copy link
Author

"9.3 - ETH" - miner version.
"21" - running time, in minutes.
"182724" - total ETH hashrate in MH/s, number of ETH shares, number of ETH rejected shares.
"30502;30457;30297;30481;30479;30505" - detailed ETH hashrate for all GPUs.
"0;0;0" - total DCR hashrate in MH/s, number of DCR shares, number of DCR rejected shares.
"off;off;off;off;off;off" - detailed DCR hashrate for all GPUs.
"53;71;57;67;61;72;55;70;59;71;61;70" - Temperature and Fan speed(%) pairs for all GPUs.
"eth-eu1.nanopool.org:9999" - current mining pool. For dual mode, there will be two pools here.
"0;0;0;0" - number of ETH invalid shares, number of ETH pool switches, number of DCR invalid shares, number of DCR pool switches.

@stralex7
Copy link
Author

stralex7 commented Apr 12, 2018

Enable logs from previous boots:

 mkdir /var/log/journal
 systemd-tmpfiles --create --prefix /var/log/journal
 systemctl restart systemd-journald

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment