db_name = 'aihc' coll_name = 'stat_excep' client = mongo_writer.auth(username, password, mongos_host, mongos_port) stat_db = "aihc_stat" stat_coll = "stat_excepstat_in" path = '/data/mongo/docker_mnt/log_recv/' regex = 'recv' func_name = 'recv' before_day = 1 # excep_load(client, db_name, coll_name, path, regex, func_name) logger.info(f'exception_stat_load start, path is {path}, regex is {regex}') file_info_dic_from_path = tool_util.get_file_info(path, regex, before_day) deal_file_dic = tool_util.get_deal_file_dic(client, stat_db, stat_coll, file_info_dic_from_path, roboter.getNodeIp()) for name, num in deal_file_dic.items(): file_modify_time = file_info_dic_from_path.get(name) stat_util.insert_stat(mongo_writer, client, stat_db, stat_coll, name, file_modify_time, roboter.getNodeIp()) exceptinfo_list = tool_util.read_stat_info(name, num) combine_excep_stat(client, db_name, coll_name, func_name, exceptinfo_list, name) stat_util.update_stat(mongo_writer, client, stat_db, stat_coll, name, num + len(exceptinfo_list), file_modify_time, roboter.getNodeIp()) result = {"recv_exception_in": "succeed"} roboter.setContent(JSON.dumps(result)) logger.info('recv_exception_in end')
# test() # 数据库认证 username = '******' password = '******' mongos_host = '10.19.85.33' mongos_port = 34000 db_name = 'test' coll_name = 'stat_service' client = mongo_writer.auth(username, password, mongos_host, mongos_port) stat_db = "test" stat_coll = "service_stat_in" path = '/Users/mtr/PycharmProjects/mongoQuery/resource/xdr_service' regex = 'service' func_name = 'xdr_service' day_before = 1 file_info_dic_from_path = tool_util.get_file_info(path, regex, day_before) deal_file_dic = tool_util.get_deal_file_dic(client, stat_db, stat_coll, file_info_dic_from_path) for name, num in deal_file_dic.items(): file_modify_time = file_info_dic_from_path.get(name) stat_util.insert_stat(mongo_writer, client, stat_db, stat_coll, name, file_modify_time) service_log_list = tool_util.read_stat_info(name, num) combine_service_stat(client, db_name, coll_name, func_name, service_log_list, name) stat_util.update_stat(mongo_writer, client, stat_db, stat_coll, name, num + len(service_log_list), file_modify_time) logging.info(f'service stat load end')