예제 #1
0
    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')
예제 #2
0
    password = '******'
    mongos_host = '10.19.85.33'
    mongos_port = 34000
    db_name = 'test'
    coll_name = 'stat_excep'
    client = mongo_writer.auth(username, password, mongos_host, mongos_port)
    stat_db = "test"
    stat_coll = "stat_excepstat_in"
    path = '/Users/mtr/PycharmProjects/mongoQuery/resource/exception'
    regex = 'Emit'
    func_name = 'emit'
    before_day = 30
    # excep_load(client, db_name, coll_name, path, regex, func_name)

    logging.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)

    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)
        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)
    logging.info('exception_stat_load end')