Skip to content

Instantly share code, notes, and snippets.

@krtschmr
Last active March 12, 2018 10:12
Show Gist options
  • Save krtschmr/a915ee7fa9c9c42961a2376dfebf208b to your computer and use it in GitHub Desktop.
Save krtschmr/a915ee7fa9c9c42961a2376dfebf208b to your computer and use it in GitHub Desktop.

Revisions

  1. krtschmr renamed this gist Mar 12, 2018. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. krtschmr revised this gist Mar 12, 2018. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -27,11 +27,13 @@ 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( (current/max * 100.0) < 50.0):
    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
  3. krtschmr revised this gist Mar 12, 2018. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,6 @@ import commands
    import json
    gDebugMode = 1
    gLogFile = "/home/ethos/gpu_hashrates.log"
    gRigName = commands.getstatusoutput("cat /etc/hostname")[1]

    def DumpActivity(dumpStr):
    print dumpStr
    @@ -36,7 +35,7 @@ while 1:
    DumpActivity("Reboot initiated | Max: " + str(max) + " | Current: " + str(current))
    os.system("sudo reboot")
    break
    time.sleep(25)
    time.sleep(30)



  4. krtschmr created this gist Mar 12, 2018.
    42 changes: 42 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    #!/usr/bin/python
    import os
    import sys
    import time
    import datetime
    import commands
    import json
    gDebugMode = 1
    gLogFile = "/home/ethos/gpu_hashrates.log"
    gRigName = commands.getstatusoutput("cat /etc/hostname")[1]

    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( (current/max * 100.0) < 50.0):
    DumpActivity("Reboot initiated | Max: " + str(max) + " | Current: " + str(current))
    os.system("sudo reboot")
    break
    time.sleep(25)