| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -12,7 +12,13 @@ from dashboard_data_conversion import adjust_times | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					from dataInterface.functions import CFunction | 
					 | 
					 | 
					 | 
					from dataInterface.functions import CFunction | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					from dataInterface.db.params import CPgSqlParam | 
					 | 
					 | 
					 | 
					from dataInterface.db.params import CPgSqlParam | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					from ext_logging import logger | 
					 | 
					 | 
					 | 
					from ext_logging import logger | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					from config import read_json_config | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					from collections import OrderedDict | 
					 | 
					 | 
					 | 
					from collections import OrderedDict | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					from urlparse import urlparse | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					from collections import defaultdict | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					from appsUtils import env | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					from ext_logging import logger_trace,APPFOLDERNAME | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					TABLE_NAME = "ueba_analysis_schema.logs" | 
					 | 
					 | 
					 | 
					TABLE_NAME = "ueba_analysis_schema.logs" | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -73,7 +79,7 @@ def get_interface_summary_data(startTime, endTime): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    result = OrderedDict() | 
					 | 
					 | 
					 | 
					    result = OrderedDict() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    sql = """select interface, sum(count) as count from {TABLE_NAME}  | 
					 | 
					 | 
					 | 
					    sql = """select interface, sum(count) as count from {TABLE_NAME}  | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                where logdate >= %s and logdate <= %s and data_type = %s  | 
					 | 
					 | 
					 | 
					                where logdate >= %s and logdate <= %s and data_type = %s  | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                group by interface order by count desc limit 20""".format(TABLE_NAME=TABLE_NAME) | 
					 | 
					 | 
					 | 
					                group by interface order by count desc limit 500""".format(TABLE_NAME=TABLE_NAME) | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    res = json.loads(CFunction.execute(CPgSqlParam(sql, params=(startTime, endTime, DATA_TYPE["INTERFACE"])))) | 
					 | 
					 | 
					 | 
					    res = json.loads(CFunction.execute(CPgSqlParam(sql, params=(startTime, endTime, DATA_TYPE["INTERFACE"])))) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if res: | 
					 | 
					 | 
					 | 
					    if res: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        for item in res: | 
					 | 
					 | 
					 | 
					        for item in res: | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -193,6 +199,12 @@ def interface_summary_calcule(startTime, endTime): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    res_data = [] | 
					 | 
					 | 
					 | 
					    res_data = [] | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    data = get_interface_summary_data(startTime=startTime,endTime=endTime) | 
					 | 
					 | 
					 | 
					    data = get_interface_summary_data(startTime=startTime,endTime=endTime) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    #获取黑名单url | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    APPHOME = env.get_isop_root() + "/apps/" + APPFOLDERNAME | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    config_path = os.path.normpath(APPHOME + "/conf/sys_config.json") | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    rule_data = read_json_config(config_path) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    black_url = rule_data["black_url"] | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    total_frequency = sum(data.itervalues()) | 
					 | 
					 | 
					 | 
					    total_frequency = sum(data.itervalues()) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    for key, value in data.iteritems(): | 
					 | 
					 | 
					 | 
					    for key, value in data.iteritems(): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        tmp={} | 
					 | 
					 | 
					 | 
					        tmp={} | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -204,8 +216,16 @@ def interface_summary_calcule(startTime, endTime): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            tmp["trend"]= round(safe_divide((value-pre_data[key]),pre_data[key]),4) | 
					 | 
					 | 
					 | 
					            tmp["trend"]= round(safe_divide((value-pre_data[key]),pre_data[key]),4) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        else: | 
					 | 
					 | 
					 | 
					        else: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            tmp["trend"]=0 | 
					 | 
					 | 
					 | 
					            tmp["trend"]=0 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					         | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        parsed_url = urlparse(key) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        url_path = parsed_url.path | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if url_path in black_url: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            continue | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        res_data.append(tmp) | 
					 | 
					 | 
					 | 
					        res_data.append(tmp) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    result = {"summary": {"interface": res_data}, "detail": {"interface": {}}} | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    sub_list_length = min(len(res_data), 20) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    sub_list = res_data[:sub_list_length] | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    result = {"summary": {"interface": sub_list}, "detail": {"interface": {}}} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    return result | 
					 | 
					 | 
					 | 
					    return result | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					#菜单维度汇总数据计算 | 
					 | 
					 | 
					 | 
					#菜单维度汇总数据计算 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -231,7 +251,10 @@ def menu_summary_calcule(startTime, endTime): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            tmp["trend"]=0 | 
					 | 
					 | 
					 | 
					            tmp["trend"]=0 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        res_data.append(tmp) | 
					 | 
					 | 
					 | 
					        res_data.append(tmp) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    logger.info("完成数据处理") | 
					 | 
					 | 
					 | 
					    logger.info("完成数据处理") | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    result = {"summary": {"menu": res_data}, "detail": {"menu": {}}} | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    sub_list_length = min(len(res_data), 50) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    sub_list = res_data[:sub_list_length] | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    result = {"summary": {"menu": sub_list}, "detail": {"menu": {}}} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    return result | 
					 | 
					 | 
					 | 
					    return result | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					#入口 | 
					 | 
					 | 
					 | 
					#入口 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |