There we go! Got this python code working so if either of my workers drops below x hash rate it will email me at my gmail account. Scheduled this to run once every 15 minutes.
(change apikey to your key, website - since this is semi-private i left it out, userid, email login/pass and modify workers[] and speed[] for however many workers you have and adjust speed accordingly)
import json
import urllib2
apikey = 'APIKEY'
url = 'https://WEBSITE.tc/users/USERID/workers.json?apikey=' + apikey
js = urllib2.urlopen(url).read()
data = json.loads(js)
workers = [username['username'] for username in data]
speed = [speed['speed'] for speed in data]
print workers[0], ": ", speed[0]
print workers[1], ": ", speed[1]
from email.header import Header
from email.mime.text import MIMEText
from getpass import getpass
from smtplib import SMTP_SSL
login, password = '
[email protected]', 'PASSWORD'
if speed[0] < 350000:
workerhash = str("Worker " + workers[0]) + " hash rate low: " + str(speed[0])
msg = MIMEText(workerhash, _charset='utf-8')
msg['Subject'] = Header('Hash Rate Low', 'utf-8')
msg['From'] = login
msg['To'] = login
s = SMTP_SSL('smtp.gmail.com', 465, timeout=10)
#s.set_debuglevel(1)
try:
s.login(login, password)
s.sendmail(msg['From'], msg['To'], msg.as_string())
finally:
s.quit()
if speed[1] < 200000:
workerhash = str("Worker " + workers[1]) + " hash rate low: " + str(speed[1])
msg = MIMEText(workerhash, _charset='utf-8')
msg['Subject'] = Header('Hash Rate Low', 'utf-8')
msg['From'] = login
msg['To'] = login
s = SMTP_SSL('smtp.gmail.com', 465, timeout=10)
#s.set_debuglevel(1)
try:
s.login(login, password)
s.sendmail(msg['From'], msg['To'], msg.as_string())
finally:
s.quit()
Note: This is one of the very few python programs I have made (I once wrote print "Hello World" before
), but it seems like it works to me.
Now I just need to have my phone play a loud panic mp3 when an email comes in with the subject of "Hash Rate Low"