-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 86ce3e8
Showing
12 changed files
with
592 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[email] | ||
#发送多个用','号隔开 | ||
email_to = [email protected] | ||
subject = 汉口火车站项目监测报告 | ||
from = 江岸watcher |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#logger.conf | ||
|
||
############################################### | ||
|
||
[loggers] | ||
keys=root,FileAndScreen | ||
|
||
[logger_root] | ||
level=DEBUG | ||
handlers=hand01,hand02 | ||
|
||
[logger_FileAndScreen] | ||
handlers=hand01,hand02 | ||
qualname=FileAndScreen | ||
propagate=0 | ||
|
||
############################################### | ||
|
||
[handlers] | ||
keys=hand01,hand02 | ||
|
||
[handler_hand01] | ||
class=StreamHandler | ||
level=DEBUG | ||
formatter=form02 | ||
args=(sys.stderr,) | ||
|
||
[handler_hand02] | ||
class=handlers.RotatingFileHandler | ||
level=DEBUG | ||
formatter=form02 | ||
args=('./log/main.log', 'a', 1024*1024*200, 5) | ||
|
||
############################################### | ||
|
||
[formatters] | ||
keys=form01,form02 | ||
|
||
[formatter_form01] | ||
format=%(asctime)s %(filename)s[line:%(lineno)d %(levelname)s] %(message)s | ||
datefmt=%a, %d %b %Y %H:%M:%S | ||
|
||
[formatter_form02] | ||
format=%(asctime)s %(filename)s[line:%(lineno)d %(levelname)s] %(message)s | ||
datefmt=%a, %Y-%m-%d %H:%M:%S |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
[ | ||
{ | ||
"type":"mysql", | ||
"dbcomment":"江夏边界数据库100.11.211.97", | ||
"host":"100.11.211.97", | ||
"port":3306, | ||
"user":"hkcrw", | ||
"passwd":"hkcr@JX07", | ||
"db":"hk_cr", | ||
"sqls":[ | ||
{"sql":"select count(*) from ads_ctrl_cnt_d where stat_date = DATE_SUB(CURDATE(),INTERVAL 1 day)", | ||
"comment":"昨日同步频次分析数据条数"}, | ||
{"sql":"select count(*) from ads_kapc_face_rt where stat_date = DATE_SUB(CURDATE(),INTERVAL 1 day)", | ||
"comment":"昨日同步人脸预警数据条数"}, | ||
{"sql":"select count(*) from ads_kapc_vehicle_rt where stat_date = DATE_SUB(CURDATE(),INTERVAL 1 day)", | ||
"comment":"昨日同步mac预警数据条数"}, | ||
{"sql":"select count(*) from ads_kapc_wifi_rt where stat_date = DATE_SUB(CURDATE(),INTERVAL 1 day)", | ||
"comment":"昨日同步wifi预警数据条数"}, | ||
{"sql":"select count(*) from ods_hkface_rt where stat_date = DATE_SUB(CURDATE(),INTERVAL 1 day)", | ||
"comment":"昨日同步人脸抓拍数据条数"} | ||
] | ||
}, | ||
{ | ||
"type":"mysql", | ||
"dbcomment":"江汉数据库100.37.1.80", | ||
"host":"100.37.1.80", | ||
"port":3306, | ||
"user":"hkcrw", | ||
"passwd":"hkcr@JX07", | ||
"db":"KAPC_HK_CR", | ||
"sqls":[ | ||
{"sql":"select count(*) from ods_wifi_rt where stat_date = CURDATE()", | ||
"comment":"今日wifi原始数据保存条数"}, | ||
{"sql":"select count(*) from ods_wifi_rt where stat_date = DATE_SUB(CURDATE(),INTERVAL 1 day)", | ||
"comment":"昨日wifi原始数据保存条数"}, | ||
{"sql":"SELECT count(*) FROM ods_hk_cr_vechile_rt where passtime > DATE_FORMAT(CURDATE(),'%Y-%m-%d %H:%i:%s')", | ||
"comment":"今日车卡采集原始数据条数"}, | ||
{"sql":"SELECT count(*) FROM ods_hk_cr_vechile_rt where passtime > DATE_FORMAT(DATE_SUB(CURDATE(),INTERVAL 1 day),'%Y-%m-%d %H:%i:%s') and passtime <DATE_FORMAT(CURDATE(),'%Y-%m-%d %H:%i:%s')", | ||
"comment":"昨日车卡采集原始数据条数"} | ||
] | ||
}, | ||
{ | ||
"type":"shell", | ||
"comment":"江汉人脸图片服务器", | ||
"host":"100.37.11.9", | ||
"port":22, | ||
"user":"root", | ||
"passwd":"123456", | ||
"cmds":[ | ||
{"cmd":"free -m", | ||
"comment":"服务器内存使用情况"}, | ||
{"cmd":"df -h", | ||
"comment":"服务器磁盘使用情况"} | ||
] | ||
}, | ||
{ | ||
"type":"shell", | ||
"comment":"江汉人脸图片服务器", | ||
"host":"100.37.1.120", | ||
"port":22, | ||
"user":"root", | ||
"passwd":"123456", | ||
"cmds":[ | ||
{"cmd":"free -m", | ||
"comment":"服务器内存使用情况"}, | ||
{"cmd":"df -h", | ||
"comment":"服务器磁盘使用情况"}, | ||
{"cmd":"ls /home/ftp/ | wc -l", | ||
"comment":"待处理文件个数"} | ||
] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
__title__ = '' | ||
__author__ = 'Administrator' | ||
__mtime__ = '2018-10-26' | ||
# code is far away from bugs with the god animal protecting | ||
I love animals. They taste delicious. | ||
┏┓ ┏┓ | ||
┏┛┻━━━┛┻┓ | ||
┃ ☃ ┃ | ||
┃ ┳┛ ┗┳ ┃ | ||
┃ ┻ ┃ | ||
┗━┓ ┏━┛ | ||
┃ ┗━━━┓ | ||
┃ 神兽保佑 ┣┓ | ||
┃ 永无BUG! ┏┛ | ||
┗┓┓┏━┳┓┏┛ | ||
┃┫┫ ┃┫┫ | ||
┗┻┛ ┗┻┛ | ||
""" | ||
|
||
import pymysql | ||
from email import encoders | ||
from email.header import Header | ||
from email.mime.text import MIMEText | ||
from email.utils import parseaddr, formataddr | ||
import smtplib | ||
|
||
|
||
def _format_addr(s): | ||
name, addr = parseaddr(s) | ||
return formataddr(( \ | ||
Header(name, 'utf-8').encode(), \ | ||
addr.encode('utf-8') if isinstance(addr, unicode) else addr)) | ||
|
||
|
||
from_addr = '[email protected]' | ||
password = 'sqm163' | ||
to_addr = ['[email protected]', '[email protected]'] | ||
smtp_server = 'smtp.163.com' | ||
|
||
msg_content = """Hi | ||
This message from email_test""" | ||
msg = MIMEText(msg_content, 'plain', 'utf-8') | ||
msg['From'] = _format_addr(u'监测报告 <%s>' % from_addr) | ||
msg['To'] = _format_addr(to_addr) | ||
msg['Subject'] = Header(u'这是报告', 'utf-8').encode() | ||
|
||
server = smtplib.SMTP(smtp_server, 25) | ||
server.set_debuglevel(1) | ||
server.helo(smtp_server) | ||
server.ehlo(smtp_server) | ||
server.login(from_addr, password) | ||
server.sendmail(from_addr, to_addr, msg.as_string()) | ||
server.quit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
__title__ = '' | ||
__author__ = 'Administrator' | ||
__mtime__ = '2018-10-31' | ||
# code is far away from bugs with the god animal protecting | ||
I love animals. They taste delicious. | ||
┏┓ ┏┓ | ||
┏┛┻━━━┛┻┓ | ||
┃ ☃ ┃ | ||
┃ ┳┛ ┗┳ ┃ | ||
┃ ┻ ┃ | ||
┗━┓ ┏━┛ | ||
┃ ┗━━━┓ | ||
┃ 神兽保佑 ┣┓ | ||
┃ 永无BUG! ┏┛ | ||
┗┓┓┏━┳┓┏┛ | ||
┃┫┫ ┃┫┫ | ||
┗┻┛ ┗┻┛ | ||
""" | ||
|
||
import smtplib | ||
from email.mime.text import MIMEText | ||
|
||
# 第三方 SMTP 服务 | ||
mail_host = "smtp.163.com" # SMTP服务器 | ||
mail_user = "[email protected]" # 用户名 | ||
mail_pass = "sqm163" # 密码 | ||
|
||
sender = '[email protected]' # 发件人邮箱(最好写全, 不然会失败) | ||
receivers = ['[email protected]'] # 接收邮件,可设置为你的QQ邮箱或者其他邮箱 | ||
|
||
content = '过期教程害死人!' | ||
title = 'Python SMTP Mail Test' # 邮件主题 | ||
message = MIMEText(content, 'plain', 'utf-8') # 内容, 格式, 编码 | ||
message['From'] = "{}".format(sender) | ||
message['To'] = ",".join(receivers) | ||
message['Subject'] = title | ||
|
||
|
||
smtpObj = smtplib.SMTP_SSL(mail_host, 465) # 启用SSL发信, 端口一般是465 | ||
smtpObj.login(mail_user, mail_pass) # 登录验证 | ||
smtpObj.sendmail(sender, receivers, message.as_string()) # 发送 | ||
print("mail has been send successfully.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#coding=utf-8 | ||
|
||
import datetime | ||
|
||
print(str(datetime.date.today())) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
__title__ = '' | ||
__author__ = 'Administrator' | ||
__mtime__ = '2018-10-26' | ||
# code is far away from bugs with the god animal protecting | ||
I love animals. They taste delicious. | ||
┏┓ ┏┓ | ||
┏┛┻━━━┛┻┓ | ||
┃ ☃ ┃ | ||
┃ ┳┛ ┗┳ ┃ | ||
┃ ┻ ┃ | ||
┗━┓ ┏━┛ | ||
┃ ┗━━━┓ | ||
┃ 神兽保佑 ┣┓ | ||
┃ 永无BUG! ┏┛ | ||
┗┓┓┏━┳┓┏┛ | ||
┃┫┫ ┃┫┫ | ||
┗┻┛ ┗┻┛ | ||
""" | ||
|
||
import pymysql | ||
import datetime | ||
|
||
msg_context = """""" | ||
# 获取发送邮件内容 | ||
def get_context(): | ||
mysql_conn = pymysql.connect(host='localhost', port=3306, | ||
user='l', | ||
passwd='l@Mysql01', | ||
db='kapc_hk_cr' | ||
) | ||
mysql_cursor = mysql_conn.cursor() | ||
# 全部需要查询的sql语句 | ||
sqls = ["select count(*) from ods_hk_cr_vechile_rt"] | ||
for sql in sqls: | ||
mysql_cursor.execute(sql) | ||
results = mysql_cursor.fetchall() | ||
cnt = results[0][0] | ||
global msg_context | ||
msg_context = msg_context + "\n" + "当天卡口原始数据(ods_hk_cr_vechile_rt): " + str(cnt) | ||
mysql_cursor.close() | ||
mysql_conn.close() | ||
|
||
get_context() | ||
|
||
print(msg_context) |
Oops, something went wrong.