Esempio n. 1
0
def init_log(service_name):
    # 初始化log组件
    import log_helper
    logPath = GLOBAL_CONFIG.get('flask').get(service_name).get('logPath')
    logLevel = GLOBAL_CONFIG.get('flask').get(service_name).get('logLevel')
    handler = log_helper.addTimedRotatingFileHandler(logPath,logLevel = logLevel)
    return handler
Esempio n. 2
0
            report_db(i[0], i[1], LOCAL_IP)
            data_report_with_sysv.set(i[0], 0)
    except sysv_ipc.BusyError:
        semaphore.release()
        logging.debug("busy error")
    except:
        semaphore.release()
        logging.error(traceback.format_exc())


def report_db(itil_id, itil_value, itil_ip):  # params = {
    #这里上报数据
    pass
    return
    #     'itil_id' : itil_id,
    #     'itil_value' : itil_value,
    #     'itil_ip' : itil_ip,
    # }
    # rs = http_helper.request_service('/itil/insert_data', params)
    # if rs.get('code') != 0:
    #     logging.error("itil_id:%s insert_data ret:%s",itil_id,rs.get('code'))
    # return rs


if __name__ == '__main__':
    LOG_PATH = './collect_itil_value.log'
    log_helper.addTimedRotatingFileHandler(LOG_PATH, '', logLevel='INFO')
    stime = time.time()
    logging.info('start')
    read()
    logging.info('end,cost:%.3f seconds', time.time() - stime)
Esempio n. 3
0
def init_log():
    import log_helper
    handler = log_helper.addTimedRotatingFileHandler(config.LOG_PATH,
                                                     logLevel=logging.DEBUG)
    return handler
Esempio n. 4
0
        for i in key_value_dict.items():
            report_db(i[0], i[1] , LOCAL_IP)
            data_report_with_sysv.set(i[0],0)
    except sysv_ipc.BusyError:
        semaphore.release()
        logging.debug("busy error")
    except:
        semaphore.release()
        logging.error(traceback.format_exc())


def report_db(itil_id, itil_value, itil_ip): # params = {
    #这里上报数据
    pass
    return
    #     'itil_id' : itil_id,
    #     'itil_value' : itil_value,
    #     'itil_ip' : itil_ip,
    # }
    # rs = http_helper.request_service('/itil/insert_data', params)
    # if rs.get('code') != 0:
    #     logging.error("itil_id:%s insert_data ret:%s",itil_id,rs.get('code'))
    # return rs

if __name__ == '__main__':
    LOG_PATH = './collect_itil_value.log'
    log_helper.addTimedRotatingFileHandler(LOG_PATH,'',logLevel='INFO')
    stime = time.time()
    logging.info('start')
    read()
    logging.info('end,cost:%.3f seconds', time.time() - stime)
Esempio n. 5
0
def init_log():
    import log_helper
    handler = log_helper.addTimedRotatingFileHandler(config.LOG_PATH, logLevel = logging.DEBUG)
    return handler