Skip to content

Instantly share code, notes, and snippets.

@dan-v
Last active September 2, 2019 11:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dan-v/044c1e746b19e480760d52dd7f083cbc to your computer and use it in GitHub Desktop.
Save dan-v/044c1e746b19e480760d52dd7f083cbc to your computer and use it in GitHub Desktop.
telegraph_claymore.py
#!/usr/bin/env python
import json
import collections
try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen
CLAYMORE_URL = 'http://localhost:3333/'
ETH_TOTAL = 2
ETH_HASHES = 3
SC_TOTAL = 4
SC_HASHES = 5
GPU_INFO = 6
response = urlopen(CLAYMORE_URL)
claymore_result = json.loads(response.read().split('<br>')[0].split('\n')[1])['result']
eth_hash_total = claymore_result[ETH_TOTAL].split(";")[0]
eth_hash_rates = claymore_result[ETH_HASHES].split(";")
sia_hash_total = claymore_result[SC_TOTAL].split(";")[0]
sia_hash_rates = claymore_result[SC_HASHES].split(";")
device_count = len(eth_hash_rates)
gpu_temps = []
gpu_fan_speed_percentages = []
raw_gpu_info = claymore_result[GPU_INFO].split(";")
for i,k in zip(raw_gpu_info[0::2], raw_gpu_info[1::2]):
gpu_temps.append(i)
gpu_fan_speed_percentages.append(k)
output = collections.OrderedDict()
output['eth_hash_total'] = float(eth_hash_total)/1000.00
output['sia_hash_total'] = float(sia_hash_total)/1000.00
output['eth_hash_rates'] = collections.OrderedDict()
for i, val in enumerate(eth_hash_rates):
output['eth_hash_rates']['gpu_' + str(i)] = float(val)
output['sia_hash_rates'] = collections.OrderedDict()
for i, val in enumerate(sia_hash_rates):
output['sia_hash_rates']['gpu_' + str(i)] = float(val)
output['gpu_temps'] = collections.OrderedDict()
for i, val in enumerate(gpu_temps):
output['gpu_temps']['gpu_' + str(i)] = int(val)
output['gpu_fan_speed_percentages'] = collections.OrderedDict()
for i, val in enumerate(gpu_fan_speed_percentages):
output['gpu_fan_speed_percentages']['gpu_' + str(i)] = int(val)
print(json.dumps(output))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment