Ejemplo n.º 1
0
def stat_kpi_info(req_date):
    """
    统计 KPI 相关指标
    """
    stat_data = dict()

    query_sql = "select type, error_id, poiThrow, widgetStats, hasTimeOut from ppview_kpi_log where type = 'ssv005' and date = '%s'" % req_date
    try:
        result = db_monitor.QueryBySQL(query_sql, db_name="ppview")
    except:
        return stat_dict

    # 失败原因统计
    error_rate_info = dict()
    error_rate_stat_data = dict()
    for each_data in result:
        try:
            error_id = int(each_data.get("error_id", "NULL"))
            req_type = each_data.get("type", "NULL")
        except Exception, e:
            print str(e)
            continue

        if error_id == 0:
            continue

        req_key = "_".join([req_type, str(error_id), error_dict.get(int(error_id), "NULL")])
        if req_key not in error_rate_stat_data:
            error_rate_stat_data[req_key] = 1
        else:
            error_rate_stat_data[req_key] += 1
Ejemplo n.º 2
0
def analyze_error_data(req_date):
    """
    0 成功
    1 验证无交通
    2 库里无酒店
    3 验证无酒店
    """
    query_sql = "select * from "

    error_dict = {1: "验证无交通", 2: "库里无酒店", 3: "验证无酒店"}

    stat_data = dict()
    pie_data = dict()
    error_data = dict()
    item_list = ["库里无交通", "验证无交通", "库里无酒店", "验证无酒店"]
    pie_data["item_list"] = item_list

    original_format = "%Y%m%d"
    new_format = "%Y-%m-%d"
    req_date = utils.date_formatter(req_date, original_format, new_format)
    query_sql = "select error_type, qid from verify_log where local_test = 1 and req_time like '%s%%%%';" % req_date

    try:
        query_result = db_monitor.QueryBySQL(query_sql, db_name="monitor")
    except Exception, e:
        query_result = []
Ejemplo n.º 3
0
def load_error_data(stat_date, env_name):
    """
    根据统计日期和开发环境名称,load 错误的数据
    """
    sql = "select * from ppview_chat_%s_log where date = '%s';" % (env_name,
                                                                   stat_date)
    result = db_monitor.QueryBySQL(sql, db_name="ppview")

    return result
Ejemplo n.º 4
0
def load_error_dict():
    """
    从数据库中 load ppview 项目的错误代码对应关系
    """

    sql = "select * from ppview_error_reason;"
    result = db_monitor.QueryBySQL(sql, db_name="ppview")

    error_dict = dict()
    for each_error in result:
        error_dict[int(each_error["error_id"])] = each_error["error_reason"]

    return error_dict
Ejemplo n.º 5
0
def load_data(db_name, dept_time, dest_time):
    """
    :param db_name: 数据库名称
    :param dept_time:  开始时间
    :param dest_time:  截止时间
    :return:
    """

    query_sql = "select * from verify_num where local_test != 0 and req_time > '%s' and req_time < '%s'" % (
        dept_time, dest_time)
    query_result = db_monitor.QueryBySQL(query_sql, db_name=db_name)

    return query_result
Ejemplo n.º 6
0
def analyze_kpi_data(kpi_time):
    """
    0 成功
    1 验证无交通
    2 库里无酒店
    3 验证无酒店
    """

    stat_data = dict()

    query_sql = "select * from ppview_kpi_summary where type = 'ssv005' and date like '%s%%%%';" % kpi_time
    try:
        query_result = db_monitor.QueryBySQL(query_sql, db_name="ppview")
    except Exception, e:
        return stat_data
Ejemplo n.º 7
0
def load_stat_data(db_name, stat_start_time, stat_end_time, env_name):
    """
    :param db_name: 数据库名称
    :param stat_time:  需要统计的日期
    :param env_name: 测试环境/正式环境
    :return:
    """

    if stat_start_time != stat_end_time:
        query_sql = "select error_id, date from ppview_chat_%s_log where date >= '%s' and date <= '%s'" % (
            env_name, stat_start_time, stat_end_time)
    else:
        query_sql = "select error_id, date from ppview_chat_%s_log where date = '%s'" % (
            env_name, stat_start_time)

    query_result = db_monitor.QueryBySQL(query_sql, db_name=db_name)

    return query_result
Ejemplo n.º 8
0
def load_data(db_name, api_type, dept_time, dest_time):
    """
    :param api_type: API 请求类型
    :param dept_time:  开始时间
    :param dest_time:  截止时间
    :return:
    """

    if api_type == "all":
        query_sql = "SELECT * FROM `ppscore_monitor` WHERE req_time > '%s 00:00:00' AND req_time < '%s 23:59:59'" % (
            dept_time, dest_time)
    else:
        query_sql = "SELECT * FROM `ppscore_monitor` WHERE rq_type = '%s' AND req_time > '%s 00:00:00' AND req_time < '%s 23:59:59'" % (
            api_type, dept_time, dest_time)

    query_result = db_monitor.QueryBySQL(query_sql, db_name=db_name)

    return query_result