|  | @@ -43,12 +43,30 @@ def  requesl_url_list(apptype):
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      return  res
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +def produce_video_data():
 | 
	
		
			
				|  |  | +    start_time = (int(time.strftime("%Y%m%d%H%M", time.localtime())) - 30) * 100000000000
 | 
	
		
			
				|  |  | +    end_time = (int(time.strftime("%Y%m%d%H%M", time.localtime()))) * 100000000000
 | 
	
		
			
				|  |  | +    sum_sql = ("select count(*) as totalCount from"              
 | 
	
		
			
				|  |  | +              "(select t1.project_id, t1.produce_status "
 | 
	
		
			
				|  |  | +              "from produce_video_project t1 "
 | 
	
		
			
				|  |  | +              "left join produce_video_project_connect_time t2 on t1.project_id = t2.project_id "
 | 
	
		
			
				|  |  | +              " where t1.project_id > %s and t1.project_id < %s and t1.app_type not in (1,13,15)) s1) ss1"%(start_time,end_time)
 | 
	
		
			
				|  |  | +               )
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  if __name__ == '__main__':
 | 
	
		
			
				|  |  |      # with session_maker() as session:
 | 
	
		
			
				|  |  |      #     instance_info = session.query(InstanceList).filter(InstanceList.status==0).all()
 | 
	
		
			
				|  |  |      #     for index in range(len(instance_info)):
 | 
	
		
			
				|  |  |      #         print( instance_info[index].ipadd)
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +    HOST = 'rm-bp1k5853td1r25g3n690.mysql.rds.aliyuncs.com'
 | 
	
		
			
				|  |  | +    PORT = '3306'
 | 
	
		
			
				|  |  | +    DATABASE = 'devops'
 | 
	
		
			
				|  |  | +    USERNAME = 'devops'
 | 
	
		
			
				|  |  | +    PASSWORD = 'devops@123456'
 | 
	
		
			
				|  |  | +    conn = pymysql.connect(host=HOST, user=USERNAME, password=PASSWORD, database=DATABASE, charset="utf8")
 | 
	
		
			
				|  |  | +    cursor = conn.cursor()
 | 
	
		
			
				|  |  |      requestUri_list = [
 | 
	
		
			
				|  |  |          '/longvideoapi/sys/config',
 | 
	
		
			
				|  |  |          '/longvideoapi/video/played',
 | 
	
	
		
			
				|  | @@ -166,12 +184,9 @@ if __name__ == '__main__':
 | 
	
		
			
				|  |  |      #     if status == "running":
 | 
	
		
			
				|  |  |      # #         status = 1
 | 
	
		
			
				|  |  |      # for url in requestUri_list:
 | 
	
		
			
				|  |  | -    #     IntfaceInfo = None
 | 
	
		
			
				|  |  | -    #     IntfaceInfo = IntfaceList()
 | 
	
		
			
				|  |  | -    #     with session_maker() as session:
 | 
	
		
			
				|  |  | -    #             IntfaceInfo.app_type = "1"
 | 
	
		
			
				|  |  | -    #             IntfaceInfo.interface_url = url
 | 
	
		
			
				|  |  | -    #             session.add(IntfaceInfo)
 | 
	
		
			
				|  |  | +    #     sql = "UPDATE `reuqest_url_list`  set  `level`=0 WHERE `request_url` ='%s' and `apptype` in (1,13)"%(url)
 | 
	
		
			
				|  |  | +    #     cursor.execute(sql)
 | 
	
		
			
				|  |  | +    #     conn.commit()
 | 
	
		
			
				|  |  |      # #
 | 
	
		
			
				|  |  |      # c = pycurl.Curl()
 | 
	
		
			
				|  |  |      # c.setopt(pycurl.URL, "https://longvideoh5.piaoquantv.com/core/share?shareSource=customerMessage&fromAppType=0&qrAppType=0&versionCode=321&shareUid=12463024&shareMachineCode=weixin_openid_o0w175fPwp8yrtOGihYJhvnT9Ag4&h5WxrootPageSource=vlog-pages___category&videoId=2689415&isRecommendShare=1&h5ShareId=backend493cd67dd28f4ee395781d59881567211625976055926&shareDepth=0&state=/")
 | 
	
	
		
			
				|  | @@ -196,57 +211,108 @@ if __name__ == '__main__':
 | 
	
		
			
				|  |  |      # end_time = (int(time.strftime("%Y%m%d%H%M", time.localtime())) + 5) * 100000000000
 | 
	
		
			
				|  |  |      # print(start_time , end_time)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    HOST = 'rm-bp1k5853td1r25g3n690.mysql.rds.aliyuncs.com'
 | 
	
		
			
				|  |  | -    PORT = '3306'
 | 
	
		
			
				|  |  | -    DATABASE = 'devops'
 | 
	
		
			
				|  |  | -    USERNAME = 'devops'
 | 
	
		
			
				|  |  | -    PASSWORD = 'devops@123456'
 | 
	
		
			
				|  |  | -    conn = pymysql.connect(host=HOST, user=USERNAME, password=PASSWORD, database=DATABASE, charset="utf8")
 | 
	
		
			
				|  |  | -    cursor = conn.cursor()
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    appType = ['0', '4', '5', '6', '12' ,'15']
 | 
	
		
			
				|  |  | -    for index in range(len(appType)):
 | 
	
		
			
				|  |  | -        type = appType[index]
 | 
	
		
			
				|  |  | -        res = count_avg_max(type)
 | 
	
		
			
				|  |  | -        for i in range(len(res.body)):
 | 
	
		
			
				|  |  | -            url = res.body[i]["requestUri"]
 | 
	
		
			
				|  |  | -            cnt = res.body[i]["cnt"]
 | 
	
		
			
				|  |  | -            max_time = res.body[i]["max_time"]
 | 
	
		
			
				|  |  | -            avg_time = res.body[i]["avg_time"]
 | 
	
		
			
				|  |  | -            sql = "UPDATE `reuqest_url_list`  set `qps`=%s, `max_time`=%s, `avg_time`=%s WHERE `request_url` ='%s' and `apptype`=%s"%(cnt, max_time, avg_time, url, type)
 | 
	
		
			
				|  |  | -            cursor.execute(sql)
 | 
	
		
			
				|  |  | -            conn.commit()
 | 
	
		
			
				|  |  | -        for i in range(len(res.body)):
 | 
	
		
			
				|  |  | -            url = res.body[i]["requestUri"]
 | 
	
		
			
				|  |  | -            cnt = res.body[i]["cnt"]
 | 
	
		
			
				|  |  | -            sql = "UPDATE `reuqest_url_list`  set `rt_1`=%s WHERE `request_url` ='%s' and `apptype`=%s"%(cnt, url, type)
 | 
	
		
			
				|  |  | -            cursor.execute(sql)
 | 
	
		
			
				|  |  | -            conn.commit()
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        res = count_rt_less_time_count(type, 200, 500)
 | 
	
		
			
				|  |  | -        for i in range(len(res.body)):
 | 
	
		
			
				|  |  | -            url = res.body[i]["requestUri"]
 | 
	
		
			
				|  |  | -            cnt = res.body[i]["cnt"]
 | 
	
		
			
				|  |  | -            sql = "UPDATE `reuqest_url_list`  set `rt_2`=%s WHERE `request_url` ='%s' and `apptype`=%s" % (cnt, url, type)
 | 
	
		
			
				|  |  | -            cursor.execute(sql)
 | 
	
		
			
				|  |  | -            conn.commit()
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        res = count_rt_less_time_count(type, 500, 1000)
 | 
	
		
			
				|  |  | -        for i in range(len(res.body)):
 | 
	
		
			
				|  |  | -            url = res.body[i]["requestUri"]
 | 
	
		
			
				|  |  | -            cnt = res.body[i]["cnt"]
 | 
	
		
			
				|  |  | -            sql = "UPDATE `reuqest_url_list`  set `rt_3`=%s WHERE `request_url` ='%s' and `apptype`=%s" % (cnt, url, type)
 | 
	
		
			
				|  |  | -            cursor.execute(sql)
 | 
	
		
			
				|  |  | -            conn.commit()
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        res = count_rt_less_time_count(type, 1000, 10000)
 | 
	
		
			
				|  |  | -        for i in range(len(res.body)):
 | 
	
		
			
				|  |  | -            url = res.body[i]["requestUri"]
 | 
	
		
			
				|  |  | -            cnt = res.body[i]["cnt"]
 | 
	
		
			
				|  |  | -            sql = "UPDATE `reuqest_url_list`  set `rt_4`=%s WHERE `request_url` ='%s' and `apptype`=%s" % (cnt, url, type)
 | 
	
		
			
				|  |  | -            cursor.execute(sql)
 | 
	
		
			
				|  |  | -            conn.commit()
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    #
 | 
	
		
			
				|  |  | +    # appType = ['0', '4', '5', '6', '12' ,'15','1','13']
 | 
	
		
			
				|  |  | +    #
 | 
	
		
			
				|  |  | +    # #
 | 
	
		
			
				|  |  | +    # for index in range(len(appType)):
 | 
	
		
			
				|  |  | +    #     type = appType[index]
 | 
	
		
			
				|  |  | +    # #     res = requesl_url_list(type)
 | 
	
		
			
				|  |  | +    # #     for i in range(len(res.body)):
 | 
	
		
			
				|  |  | +    # #         url = res.body[i]["requestUri"]
 | 
	
		
			
				|  |  | +    # #         sql = "insert into  `reuqest_url_list`  (`apptype`, `request_url`) VALUES (%s, '%s')"%(type, url)
 | 
	
		
			
				|  |  | +    # #         print(sql)
 | 
	
		
			
				|  |  | +    # #         cursor.execute(sql)
 | 
	
		
			
				|  |  | +    # #         conn.commit()
 | 
	
		
			
				|  |  | +    #
 | 
	
		
			
				|  |  | +    #
 | 
	
		
			
				|  |  | +    #
 | 
	
		
			
				|  |  | +    #     res = count_avg_max(type)
 | 
	
		
			
				|  |  | +    #     for i in range(len(res.body)):
 | 
	
		
			
				|  |  | +    #         url = res.body[i]["requestUri"]
 | 
	
		
			
				|  |  | +    #         cnt = res.body[i]["cnt"]
 | 
	
		
			
				|  |  | +    #         max_time = res.body[i]["max_time"]
 | 
	
		
			
				|  |  | +    #         avg_time = res.body[i]["avg_time"]
 | 
	
		
			
				|  |  | +    #         sql = "UPDATE `reuqest_url_list`  set `qps`=%s, `max_time`=%s, `avg_time`=%s WHERE `request_url` ='%s' and `apptype`=%s"%(cnt, max_time, avg_time, url, type)
 | 
	
		
			
				|  |  | +    #         cursor.execute(sql)
 | 
	
		
			
				|  |  | +    #         conn.commit()
 | 
	
		
			
				|  |  | +    #     for i in range(len(res.body)):
 | 
	
		
			
				|  |  | +    #         url = res.body[i]["requestUri"]
 | 
	
		
			
				|  |  | +    #         cnt = res.body[i]["cnt"]
 | 
	
		
			
				|  |  | +    #         sql = "UPDATE `reuqest_url_list`  set `rt_1`=%s WHERE `request_url` ='%s' and `apptype`=%s"%(cnt, url, type)
 | 
	
		
			
				|  |  | +    #         cursor.execute(sql)
 | 
	
		
			
				|  |  | +    #         conn.commit()
 | 
	
		
			
				|  |  | +    #
 | 
	
		
			
				|  |  | +    #     res = count_rt_less_time_count(type, 200, 500)
 | 
	
		
			
				|  |  | +    #     for i in range(len(res.body)):
 | 
	
		
			
				|  |  | +    #         url = res.body[i]["requestUri"]
 | 
	
		
			
				|  |  | +    #         cnt = res.body[i]["cnt"]
 | 
	
		
			
				|  |  | +    #         sql = "UPDATE `reuqest_url_list`  set `rt_2`=%s WHERE `request_url` ='%s' and `apptype`=%s" % (cnt, url, type)
 | 
	
		
			
				|  |  | +    #         cursor.execute(sql)
 | 
	
		
			
				|  |  | +    #         conn.commit()
 | 
	
		
			
				|  |  | +    #
 | 
	
		
			
				|  |  | +    #     res = count_rt_less_time_count(type, 500, 1000)
 | 
	
		
			
				|  |  | +    #     for i in range(len(res.body)):
 | 
	
		
			
				|  |  | +    #         url = res.body[i]["requestUri"]
 | 
	
		
			
				|  |  | +    #         cnt = res.body[i]["cnt"]
 | 
	
		
			
				|  |  | +    #         sql = "UPDATE `reuqest_url_list`  set `rt_3`=%s WHERE `request_url` ='%s' and `apptype`=%s" % (cnt, url, type)
 | 
	
		
			
				|  |  | +    #         cursor.execute(sql)
 | 
	
		
			
				|  |  | +    #         conn.commit()
 | 
	
		
			
				|  |  | +    #
 | 
	
		
			
				|  |  | +    #     res = count_rt_less_time_count(type, 1000, 10000)
 | 
	
		
			
				|  |  | +    #     for i in range(len(res.body)):
 | 
	
		
			
				|  |  | +    #         url = res.body[i]["requestUri"]
 | 
	
		
			
				|  |  | +    #         cnt = res.body[i]["cnt"]
 | 
	
		
			
				|  |  | +    #         sql = "UPDATE `reuqest_url_list`  set `rt_4`=%s WHERE `request_url` ='%s' and `apptype`=%s" % (cnt, url, type)
 | 
	
		
			
				|  |  | +    #         cursor.execute(sql)
 | 
	
		
			
				|  |  | +    #         conn.commit()
 | 
	
		
			
				|  |  | +    #
 | 
	
		
			
				|  |  | +    #
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    # start_time = int(time.strftime("%Y%m%d%H%M", time.localtime())) * 100000000000
 | 
	
		
			
				|  |  | +    # end_time = (int(time.strftime("%Y%m%d%H%M", time.localtime())) + 5) * 100000000000
 | 
	
		
			
				|  |  | +    # query_sql = ("select round((successCount + processingCount1)/totalCount * 100,2) from  "
 | 
	
		
			
				|  |  | +    #             "(select count(*) as totalCount,"
 | 
	
		
			
				|  |  | +    #              "sum(case when produce_status in (5,6,7,8) then 1 else 0 end) as successCount,"
 | 
	
		
			
				|  |  | +    #              "sum(case when produce_status = 99 then 1 else 0 end) as failCount , "
 | 
	
		
			
				|  |  | +    #              "sum(case when produce_status in(0,1,2,3,4) then 1 else 0 end) as processingCount,"
 | 
	
		
			
				|  |  | +    #              "sum(case when produce_status in(0,1,2,3,4) and (rate < 1 or rate is null) then 1 else 0 end) processingCount1,"
 | 
	
		
			
				|  |  | +    #              "sum(case when produce_status in(0,1,2,3,4) and rate >= 1 then 1 else 0 end) processingCount2  from  "
 | 
	
		
			
				|  |  | +    #              "(select t1.project_id, t1.produce_status, round((t2.last_connect_timestamp - t1.submit_timestamp) / (t1.video_duration/1000), 1) as rate  from produce_video_project t1  "
 | 
	
		
			
				|  |  | +    #              "left join produce_video_project_connect_time t2 on t1.project_id = t2.project_id "
 | 
	
		
			
				|  |  | +    #              "where t1.project_id > %s and t1.project_id < %s and t1.app_type not in (1,13,15)) s1) ss1" %(start_time ,end_time)
 | 
	
		
			
				|  |  | +    #
 | 
	
		
			
				|  |  | +    #             )
 | 
	
		
			
				|  |  | +    # res = db_query(query_sql)
 | 
	
		
			
				|  |  | +    #
 | 
	
		
			
				|  |  | +    # if res[0] is not None:
 | 
	
		
			
				|  |  | +    #     print(res[0])
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    start_time = int(time.strftime("%Y%m%d", time.localtime())) * 1000000000000000
 | 
	
		
			
				|  |  | +    end_time = int(time.strftime("%Y%m%d%H%M", time.localtime())) * 100000000000
 | 
	
		
			
				|  |  | +    query_sql = ("select count(*) as totalCount,"
 | 
	
		
			
				|  |  | +                 "sum(case when produce_status in (5,6,7,8) then 1 else 0 end) as successCount,"
 | 
	
		
			
				|  |  | +                 "sum(case when produce_status = 99 then 1 else 0 end) as failCount , "
 | 
	
		
			
				|  |  | +                 "sum(case when produce_status in(5,6,7,8) then 1 else 0 end) as processingCount,"
 | 
	
		
			
				|  |  | +                 "sum(case when produce_status in(5,6,7,8) and (rate < 0.5 or rate is null) then 1 else 0 end) processingCount1,"
 | 
	
		
			
				|  |  | +                 "sum(case when produce_status in(5,6,7,8) and rate >= 0.5 and  rate < 0.7 then 1 else 0 end) processingCount2  ,"
 | 
	
		
			
				|  |  | +                 "sum(case when produce_status in(5,6,7,8) and rate >= 0.7 and  rate < 1 then 1 else 0 end) processingCount3 ,"
 | 
	
		
			
				|  |  | +                 "sum(case when produce_status in(5,6,7,8) and rate >= 1 and  rate < 1.5 then 1 else 0 end) processingCount4  ,"
 | 
	
		
			
				|  |  | +                 "sum(case when produce_status in(5,6,7,8) and rate >= 1.5 and  rate < 2 then 2 else 0 end) processingCount5 ,"
 | 
	
		
			
				|  |  | +                 "sum(case when produce_status in(5,6,7,8) and  rate >2  then 1 else 0 end) processingCount6  from  "
 | 
	
		
			
				|  |  | +                 "(select t1.project_id, t1.produce_status, round((t2.last_connect_timestamp - t1.submit_timestamp) / (t1.video_duration/1000), 1) as rate  from produce_video_project t1  "
 | 
	
		
			
				|  |  | +                 "left join produce_video_project_connect_time t2 on t1.project_id = t2.project_id "
 | 
	
		
			
				|  |  | +                 "where t1.project_id > %s and t1.project_id < %s and t1.app_type not in (1,13,15)) s1 " %(start_time ,end_time)
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                )
 | 
	
		
			
				|  |  | +    res = db_query(query_sql)
 | 
	
		
			
				|  |  | +    print(res)
 | 
	
		
			
				|  |  | +    if res[0] is not None:
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        print(res[0],res[1],res[2],res[3],res[4], res[5],res[6],res[7],res[8],res[9])
 | 
	
		
			
				|  |  | +    print(start_time, end_time)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 |