Comments (3)
Here is how to add the email notifications:
lib/notify_email.py:
import smtplib
from email.mime.text import MIMEText
import lib.settings as settings
import lib.logger
log = lib.logger.get_logger('Notify_Email')
class NOTIFY_EMAIL():
def notify_start(self):
if settings.NOTIFY_EMAIL_TO != '':
self.send_emails(settings.NOTIFY_EMAIL_TO,'Stratum Server Started','Stratum server has started!')
def notify_found_block(self,worker_name):
if settings.NOTIFY_EMAIL_TO != '':
text = '%s on Stratum server found a block!' % worker_name
self.send_emails(settings.NOTIFY_EMAIL_TO,'Stratum Server Found Block',text)
def send_emails(self,to,subject,message):
tos = to.split(";")
for tov in tos:
self.send_email(tov,subject,message)
def send_email(self,to,subject,message):
msg = MIMEText(message)
msg['Subject'] = subject
msg['From'] = settings.NOTIFY_EMAIL_FROM
msg['To'] = to
try:
s = smtplib.SMTP(settings.NOTIFY_EMAIL_SERVER)
if settings.NOTIFY_EMAIL_USERNAME != '':
if settings.NOTIFY_EMAIL_USETLS:
s.ehlo()
s.starttls()
s.ehlo()
s.login(settings.NOTIFY_EMAIL_USERNAME, settings.NOTIFY_EMAIL_PASSWORD)
s.sendmail(settings.NOTIFY_EMAIL_FROM,to,msg.as_string())
s.quit()
except smtplib.SMTPAuthenticationError as e:
log.error('Error sending Email: %s' % e[1])
except Exception as e:
log.error('Error sending Email: %s' % e[0])
mining/interfaces.py:
...
import lib.notify_email
...
class ShareManagerInterface(object):
def __init__(self):
self.block_height = 0
self.prev_hash = 0
# Send out the e-mail saying we are starting.
notify_email = lib.notify_email.NOTIFY_EMAIL()
notify_email.notify_start()
...
def on_submit_block(self, is_accepted, worker_name, block_header, block_hash, timestamp, ip, share_diff):
log.info("Block %s %s" % (block_hash, 'ACCEPTED' if is_accepted else 'REJECTED'))
dbi.found_block([worker_name, block_header, block_hash, -1, timestamp, is_accepted, ip, self.block_height, self.prev_hash, share_diff ])
# Send out the e-mail saying we found a block.
if is_accepted:
notify_email = lib.notify_email.NOTIFY_EMAIL()
notify_email.notify_found_block(worker_name)
...
Add to conf/config_sample.py:
NOTIFY_EMAIL_TO = '' # Where to send Start/Found block notifications
NOTIFY_EMAIL_TO_DEADMINER = '' # Where to send dead miner notifications
NOTIFY_EMAIL_FROM = 'root@localhost' # Sender address
NOTIFY_EMAIL_SERVER = 'localhost' # E-Mail Sender
NOTIFY_EMAIL_USERNAME = '' # E-Mail server SMTP Logon
NOTIFY_EMAIL_PASSWORD = ''
NOTIFY_EMAIL_USETLS = True
from stratum-mining.
hmm, i can think about it, i wont be adding dead miner notifications im afraid. just block notifications and any severe error notifications
from stratum-mining.
added email notifications into the issue-4 branch
from stratum-mining.
Related Issues (20)
- ERROR block_updater # UpdateWatchdog.run failed HOT 6
- Issue Fake shares HOT 3
- error when sudo python setup.py install HOT 3
- Unable to install python setup.py HOT 8
- ERROR mining # Failed Connect(HTTP 500 or Invalid JSON),Check Username and Password! HOT 1
- When twisted is executed with stratum, an error occurs that the index of the tuple becomes out of range. HOT 2
- ERROR bitcoin_rpc_manager # Check Height -- Pool 0 Down! HOT 9
- False (0) INVALID workername
- SUBMITBLOCK RESULT: {"result":"bad-txnmrklroot","error":null,"id":"1"} HOT 1
- Extract Hashing Code to support Other Coins
- Simplify CoinBaser
- Add MPOS SSO Support
- Clean up Half Node. And try to remove blocking code
- This will skip all SSL-based transports HOT 1
- Stratum not open 3333 port HOT 6
- Is this stratum-mining distribute rewards between workers HOT 1
- Couldn't find index page for 'autobahn' HOT 1
- multi crypto HOT 1
- Great
- Best front-end to use with stratum-mining? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stratum-mining.