A Python Snippet to check the HIVEON pool & rig health
python·@emrebeyler·
0.000 HBDA Python Snippet to check the HIVEON pool & rig health
If you have a rig mining at [Hiveon](https://hiveon.net), then this script may help you to do automations & notifications. Checking the rig health from this is not the best but I've needed a quick solution for now. (Still delaying to play with HiveOS at API level.)
<center></center>
<center>Notification example on my mobile</center>
***
I was looking for a quick way to restart the rig automatically if it's not sharing to the pool anymore. But cut these logic & lines from here and only left the notifications part.
Here is the logic:
- Check rig stats from Hiveon
- if the hash rate is 0 or the rig looks like it's not connected, then send a notification about the status. Notifications are handled w/ [Pushover](https://pushover.net/).
- Repeat (Even though, repeat side should be handled via a crontab entry.)
***
```
import requests
import sys
from pushover import Client
PUSHOVER_TOKEN = "<pushover_token>"
machines = [{
"name": "Rig 2.0",
"wallet": "<wallet>",
"pushover_client_key": "<receiver_key>"
}]
def send_notification(message, client_key):
Client(
client_key,
api_token=PUSHOVER_TOKEN
).send_message(message, title="HiveON Alert")
def check_miners(name, wallet, pushover_client_key):
r = requests.get(f"https://hiveon.net/api/v0/miner/{wallet}?currency=ETH")
r.raise_for_status()
data = r.json().get("data")
hash_rate = int(data.get("hashrate"))
if not hash_rate or data.get("offlineWorkerCount") > 0:
message = f"{name} is not mining! Check the rig."
send_notification(message, pushover_client_key)
sys.exit(-1)
else:
mh = round(hash_rate / 1e6, 2)
bill = requests.get(
f"https://hiveon.net/api/v0/miner/{wallet}/bill?currency=ETH")
bill.raise_for_status()
stats = bill.json().get("stats")
balance = stats.get("balance")
message = f"{name} is currently mining with " \
f"{mh} mH. Balance: {balance} ETH."
print(message)
if __name__ == '__main__':
for rig in machines:
check_miners(rig["name"], rig["wallet"], rig["pushover_client_key"])
```
***
<center></center>
***
Requires Python3.7+ and requests library. Note that, Hiveon API calls mentioned here are just reverse engineereed. They may change at any time and point. Use the script at your own risk.👍 eval, bulent1976, ahmeterbay, bitcoinator, raoul.poenar, korle, laissez-faire, steemwhalepower, ydavgonzalez, criptoanarquista, samueladams314, isisfemale, leviackerman, hivevenezuela, yugimuto, magodelcaosnegro, hivebtc, sagadegeminis, constantinopla, bellaciao, jesucristo, yodinzaku, lordarianthus, spiritminer, drfate, confucio, splintergod, magnor, meele, kretchtallevor, onyxsentinel, khymeria, sicmundus, lainiwakura, roymustang, darkarmy, reiayanami, kaiosama, pitagoras, steinitz, anillounico, emrebeyler, crokkon, hivecur2, joele, ctime, tipitip, revisesociology, gabbynhice, nokodemion, tahirozgen, daath, buzzbee, moneytron, cpt-sparrow, choco11oreo11, thehive, joseph6232, emaillisahere, caoimhin, djtrucker, podg3, misstaken, daisybuzz, jussbren, suigener1s, boohugs, thehouse, tommys.shop, hivewaves, paulman, ronavel, starino, music.legend, jan23com, littleshadow, yeswecan, the-table, honeychip, ew-and-patterns, marshalmugi, cardtrader, danielsaori, maxer27, kibela, anech512, olivier.jacobs, silverquest, kran6, kran7, kran8, kran9, kran10, kran11, kran12, kran13, kran14, kran15, kran16, kran17, sharker, acta, funnyman, sudefteri, kahvesizlik, realgoodcontent, gmlrecordz, somebody, yulan, damla, exec, chorock, laoyao, xiaohui, lingfei, sbi8, midnightoil, oflyhigh, helene, steinhammer, blackbunny, wherein, sbi-tokens, cnstm, rasalom, lianjingmedia, raspibot, mark-waser, digital-wisdom, ethical-ai, jwaser, bwaser, ellepdub, herpetologyguy, morgan.waser, strong-ai, technoprogressiv, isnochys, likwid, ecotone, promobot, altonos, samflow, fourfourfun, jacekw, cst90, thomasthewolf, muratkbesiroglu, jumbot, bilimkurgu, hayirhah, baycan, coinmeria, agememnon, ahmetchef, luciomcabee, sm-skynet, kingscrown, anti-bully, boatymcboatface, theshell, justyy, moneybaby, nervi, steemituplife, cooperfelix, alinalazareva, evilest-fiend, not-a-bird, mahyulmaulana, elmauza, kosimoos, angelanichole, sereze, murattatar, bigmoneyman, tinowhale, steempampanga, mhm-philippines, fromhell2sky, lidiceml, allyson19, ruh, pablorg94, payroll, emotionalsea, starrouge, unforgettable, steinz, shaka, soyrosa, uwelang, vannour, obvious, nateaguila, nonsowrites, pladozero, jang, ahmetmertugrul, tdogvoid, ruel.cedeno, forkonti, ceruleanblue, semihbalkanli, cardboard, cfminer, acidyo, mister-meeseeks, marvschurchill1, ghaazi, hivelist, mytechtrail, bluerobo, blue-witness, dpoll.curation, dpoll.witness, gulf41, gitplait, tykee, kamchore, bala41288, enforcer48, nathen007, long888, eturnerx, investegg, yury-vas, rafaelaquino, we-are, tangmo, msp-foundation,