Skip to content

Instantly share code, notes, and snippets.

@krtschmr
Last active March 12, 2018 10:12
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 krtschmr/a915ee7fa9c9c42961a2376dfebf208b to your computer and use it in GitHub Desktop.
Save krtschmr/a915ee7fa9c9c42961a2376dfebf208b to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import os
import sys
import time
import datetime
import commands
import json
gDebugMode = 1
gLogFile = "/home/ethos/gpu_hashrates.log"
def DumpActivity(dumpStr):
print dumpStr
pLogFile = open(gLogFile, "a")
pLogFile.write("%s @ %s\n" % (dumpStr, str(datetime.datetime.now())))
pLogFile.close()
# wait till 4 minutes runtime, so we can be sure that mining did start
while( float(commands.getstatusoutput("cat /proc/uptime")[1].split()[0]) < 4 * 60):
time.sleep(5)
current = 0
max = 0
# start checking
while 1:
status, output = commands.getstatusoutput("echo '{\"id\":0,\"jsonrpc\":\"2.0\",\"method\":\"miner_getstat1\"}' | netcat localhost 3333")
j = json.loads(output)
current = sum(map(int, j["result"][3].split(";"))) / 1000.0
if(max < current):
max = current
# if we have less then 50% of our max hashrate, some shit with claymore went wrong. in our case a nicehash disconnect.
if( max > 0.00 and (current/max * 100.0) < 50.0):
DumpActivity("Reboot initiated | Max: " + str(max) + " | Current: " + str(current))
os.system("sudo reboot")
break
time.sleep(30)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment