Commit f7146700 by zhaihuitao

create

parents
# Default ignored files
/shelf/
/workspace.xml
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/monitor.iml" filepath="$PROJECT_DIR$/.idea/monitor.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.6" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
# -*- coding: utf-8 -*-
import pymysql
class MysqlCon(object):
conn = None
def __init__(self, host, username, password, db, charset='utf8', port=3306):
self.host = host
self.username = username
self.password = password
self.db = db
self.charset = charset
self.port = port
def connect(self):
self.conn = pymysql.connect(host=self.host, port=self.port, user=self.username, password=self.password,
db=self.db,
charset=self.charset)
self.cursor = self.conn.cursor()
def close(self):
self.cursor.close()
self.conn.close()
def get_one(self, sql):
result = None
try:
self.connect()
self.cursor.execute(sql)
result = self.cursor.fetchone()
self.close()
except Exception as e:
print(e)
return result
def get_all(self, sql, params=()):
list_data = ()
try:
self.connect()
self.cursor.execute(sql, params)
list_data = self.cursor.fetchall()
self.close()
except Exception as e:
print(e)
return list_data
def insert(self, sql, params=()):
return self.__edit(sql, params)
def update(self, sql, params=()):
return self.__edit(sql, params)
def delete(self, sql, params=()):
return self.__edit(sql, params)
def __edit(self, sql, params):
count = 0
try:
self.connect()
count = self.cursor.execute(sql, params)
self.conn.commit()
self.close()
except Exception as e:
print(e)
return count
# -*- coding: utf-8 -*-
import random
import requests
import time
import socket, struct
from dbConfig.dbConn import MysqlCon
# host = "10.3.20.32"
host = "etl.cma5jkozme68.rds.cn-north-1.amazonaws.com.cn"
# username = "root"
username = "rytestalarm"
# password = "reyun.123"
password = "rytestalarm234"
db = "tkio_stream"
sql = "select num_click from tkio_rpt_source_analysis_day where appid ='b563860ef7f3400a5fe7c0a05f4523e6';"
# URL = 'http://10.3.20.42:8083/tkio/Bzq2aua'
URL = 'http://uri6.com/tkio/ziQ7Jza'
i = ''.join(str(random.choice(range(10))) for _ in range(12))
ip = socket.inet_ntoa(struct.pack('>I', random.randint(1, 0xffffffff)))
param = {
"imei": i,
"ip": ip,
"deviceid": i
}
mysqlCon = MysqlCon(host=host, username=username, password=password, db=db)
r = mysqlCon.get_one(sql=sql)
count = r[0]
p = requests.get(url=URL, params=param, timeout=30, verify=False)
time.sleep(360)
mysqlCon = MysqlCon(host=host, username=username, password=password, db=db)
r = mysqlCon.get_one(sql=sql)
num = r[0]
if count + 1 == num:
print("指标确认正常")
else:
print("指标异常,请关注")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment