Last active
February 1, 2018 11:32
-
-
Save simse/f8d41873979123ebb7ab3bf6a647a16b to your computer and use it in GitHub Desktop.
This will connect to a Claymore miner and get statistics and automatically do some conversions. Will ignore any secondary coin.
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
def talkToClaymore(ip, port, password): | |
#Iniate socket and connect to Claymore | |
claymore_connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
claymore_connection.connect((ip, port)) | |
#Send request to Claymore | |
request_data = '{"id":0,"jsonrpc":"2.0","method":"miner_getstat1","psw":"%s"}' % password | |
claymore_connection.send(request_data.encode('utf-8')) | |
#Receive Claymore data | |
claymore_response = claymore_connection.recv(2048) | |
claymore_connection.close() | |
claymore = json.loads(claymore_response)['result'] | |
#Parse data | |
gpus = [] | |
for x in range(0, int(len(claymore[6].split(';')) / 2)): | |
gpus.append({ | |
#Find the hashrate of the GPU and convert to megahash | |
'hashrate': int(claymore[3].split(';')[x]) / 1000, | |
#Find GPU temperature. We multiply the index by 2 to get every second value. | |
'temperature': claymore[6].split(';')[int(x) * 2], | |
#Find GPU fan speed. We multiply the index by 2 and plus 1 to get the value right after the temperature value | |
'fanSpeed': claymore[6].split(';')[int(x) * 2 + 1] | |
}) | |
claymore_data = { | |
#Find Claymore version | |
'version': claymore[0], | |
#Returns uptime in *minutes* | |
'uptime': claymore[1], | |
#Return total hashrate, converted to megahash | |
'totalHashrate': int(claymore[2].split(';')[0]) / 1000, | |
#Returns total shares completed | |
'totalEthShares': claymore[2].split(';')[1], | |
#Returns rejected shares | |
'totalEthRejectedShares': claymore[2].split(';')[2], | |
#Returns GPU count using temperature and fan speed | |
'gpuCount': int(len(claymore[6].split(';')) / 2), | |
#Detailed statistics for each GPU | |
'gpus': gpus, | |
#Returns current pool | |
'pool': claymore[7] | |
} | |
return claymore_data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment