Skip to content

Instantly share code, notes, and snippets.

@Atticuss
Created February 3, 2016 16:41
Show Gist options
  • Save Atticuss/54f511cddbbe13a61c90 to your computer and use it in GitHub Desktop.
Save Atticuss/54f511cddbbe13a61c90 to your computer and use it in GitHub Desktop.
import subprocess,json,sys
numGPU = 4
hashcatLoc = '/home/atticuss/cudaHashcat-2.01/cudaHashcat64.bin'
cmd = [hashcatLoc, '-m', '0', '3858f62230ac3c915f300c664312c63f', '-a', '3', '?a?a?a?a?a?a?a?a?a', '--status', '--status-timer=1']
limit = 60 * 30 #30 minutes
temps = {}
fanspeeds = {}
count = 0
def handleLine(line):
global temps,fanspeeds,count,limit
if 'HWMon' in line:
gpu = int(line.split('#')[1].split('.')[0].strip())
temp = int(line.split(',')[1].split('c')[0].strip())
fanspeed = int(line.split(',')[2].split('%')[0].strip())
if gpu == 1:
temps[count] = {}
fanspeeds[count] = {}
temps[count][gpu] = temp
fanspeeds[count][gpu] = fanspeed
if gpu == numGPU:
count += 1
text = '\r%s/%s'%(count,limit)
sys.stdout.write(text)
sys.stdout.flush()
with subprocess.Popen(cmd,shell=False,stdout=subprocess.PIPE) as proc:
while proc.poll() is None and count <= limit:
handleLine(proc.stdout.readline().decode('utf-8'))
print('\ndumping temps to file')
with open('temps.txt','w') as f:
f.write(json.dumps(temps))
print('dumping fanspeeds to file')
with open('fanspeeds.txt','w') as f:
f.write(json.dumps(fanspeeds))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment