Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #127

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,20 @@
## 截图

![Hawkeye](https://user-images.githubusercontent.com/12611275/46849889-0d2d0980-ce24-11e8-832e-35f6f935bf3b.png)



## dbg 更新

- 2019/11/14
- 更新邮件发送title





## **最近更新**

- 2019-07-02 v3.0.1
- 添加健康检查接口 /api/health
- 添加企业微信告警
Expand Down
9 changes: 5 additions & 4 deletions server/utils/notice.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import smtplib
from email.header import Header
from email.mime.text import MIMEText
import time


class SMTPServer(object):
Expand All @@ -11,10 +12,10 @@ def __init__(self, smtp_config):
self.username = smtp_config.get('username')
self.password = smtp_config.get('password')
try:
if self.tls:
self.smtp = smtplib.SMTP(self.host, self.port, timeout=300)
else:
if self.tls:
self.smtp = smtplib.SMTP_SSL(self.host, self.port, timeout=300)
else:
self.smtp = smtplib.SMTP(self.host, self.port, timeout=300)
except Exception as error:
print(error)

Expand Down Expand Up @@ -48,7 +49,7 @@ def mail_notice(smtp_config, receivers, content):
message = MIMEText(content, _subtype='html', _charset='utf-8')
message['From'] = Header('{}<{}>'.format(smtp_config.get('from'), smtp_config.get('username')), 'utf-8')
message['To'] = Header(';'.join(receivers), 'utf-8')
message['Subject'] = Header('[GitHub] 监控告警', 'utf-8')
message['Subject'] = Header('[GitHub] 监控告警--'+time.asctime(), 'utf-8')
try:
smtp = SMTPServer(smtp_config)
print('login')
Expand Down