Beispiel #1
0
def get_loading_param_values(request):
    filters_map = get_default_values_from_cookie(request)
    service_type = request.GET.get("service_type",
                                   filters_map["st"]).encode("utf-8")
    device_type = request.GET.get("device_type",
                                  filters_map["dt"]).encode("utf-8")
    version = request.GET.get("version", filters_map["vt"]).encode("utf-8")
    begin_date = request.GET.get("begin_date",
                                 filters_map["begin"]).encode("utf-8")
    end_date = request.GET.get("end_date", filters_map["end"]).encode("utf-8")
    min_rec = request.GET.get("min_rec", '300')
    if not min_rec:
        min_rec = 300
    else:
        min_rec = int(min_rec)

    if begin_date == str(today()) and end_date == str(today()):
        begin_date_temp = str(get_day_of_day(-1))
        end_date_temp = begin_date_temp
    else:
        begin_date_temp = begin_date
        end_date_temp = end_date

    device_types = get_device_types1(service_type, begin_date_temp,
                                     end_date_temp, min_rec)
    if len(device_types) == 0:
        device_types = [""]
        device_type = ""

    if device_type not in device_types:
        device_type = device_types[0]

    versions = []
    try:
        versions = get_versions1(service_type, device_type, begin_date_temp,
                                 end_date_temp, min_rec)
    except:
        logger.info("get_versions({0}, {1}, {2}, {3}) failed.".format(
            service_type, device_type, begin_date, end_date))

    if len(versions) == 0:
        versions = [""]
        version = ""
    if version not in versions:
        version = versions[0]

    return service_type, device_type, device_types, version, \
        versions, begin_date, end_date, min_rec
Beispiel #2
0
def show_ms_error(request, dev=""):
    context = {}

    date = request.GET.get("date", str(get_day_of_day(-1)))

    table = HtmlTable()
    table.mtitle = "ms_error信息"
    table.mheader = [
        "响应码", "ClientIP", "省份", "运营商", 'ServerIP', '省份', '运营商', '次数',
        'Content_len', 'url'
    ]
    table.msub = []

    sql = "select Resp, ClientIP, ClientISP, ClientArea, ServIP, \
            ServISP, ServArea, Count, ContentLen, URL  \
            from ms_error_info where Date='%s'" % date

    logger.debug("Server List SQL - %s" % sql)

    mysql_cur = connection.cursor()
    begin_time = current_time()
    mysql_cur.execute(sql)
    results = mysql_cur.fetchall()
    logger.info("execute sql:  %s, cost: %s" % (sql,
                                                (current_time() - begin_time)))
    subs = []
    for row in results:
        sub = []
        for i in range(9):
            sub.append(row[i])
        sub.append('''<a href="%s" target="_blank">%s</a>''' %
                   (row[9], row[9]))
        subs.append(sub)

    table.msub = subs

    context['table'] = table
    context['default_date'] = date

    return render_to_response('show_ms_error.html', context)
Beispiel #3
0
def show_tsdelay(request, dev=""):
    context = {}

    date = request.GET.get("date", str(get_day_of_day(-1)))

    table = HtmlTable()
    table.mtitle = "CDN信息"
    table.mheader = ["ServerIP", "省份", "运营商", '流量(G)', '内网流量占比(%)', '详情']
    table.msub = []

    sql = "select ServIP, ServArea, ServISP, Flow, InnerFlow, ServiceType \
            from ts_delay where Date='%s'" % date

    logger.debug("Server List SQL - %s" % sql)

    mysql_cur = connection.cursor()
    begin_time = current_time()
    mysql_cur.execute(sql)
    results = mysql_cur.fetchall()
    logger.info("execute sql:  %s, cost: %s" % (sql,
                                                (current_time() - begin_time)))
    subs = []
    for row in results:
        sub = []
        for i in range(3):
            sub.append(row[i])
        sub.append("%.3f" % (float(row[3]) / 1024 / 1024 / 1024))
        sub.append("%.1f" % (float(row[4] * 1.0 / row[3] * 100)))
        #sub.append("%s"%"详情")
        sub.append("<a href='/show_cdn_detail?ip=%s&date=%s&servicetype=%s' \
            target='main'>%s</a>" % (row[0], date, row[5], u"详情"))
        subs.append(sub)
    table.msub = subs

    context['table'] = table
    context['default_date'] = date

    return render_to_response('show_tsdelay.html', context)
Beispiel #4
0
def show_cdn_detail(request, dev=""):
    context = {}
    date = request.GET.get("date", str(get_day_of_day(-1)))
    servicetype = request.GET.get("servicetype", 'B2B')
    servip = request.GET.get("ip", "127.0.0.1")
    sql = "select ServArea, ServISP, Flow, InnerFlow, Info \
            from ts_delay where ServIP='%s' and ServiceType='%s' \
            and Date='%s'" % (servip, servicetype, date)

    mysql_cur = connection.cursor()
    begin_time = current_time()
    mysql_cur.execute(sql)
    results = mysql_cur.fetchall()
    logger.info("execute sql:  %s, cost: %s" % (sql,
                                                (current_time() - begin_time)))
    if len(results) <= 0:
        return render_to_response('bestv_servers_map.html', context)

    row = results[0]
    area = row[0]
    isp = row[1]
    tflow = row[2]
    context['title'] = '服务器信息: 速率KBps'
    context['subtitle'] = '%s-%s-%s' % (area, isp, date)
    context['legendTxt'] = servip

    item = {}
    item["title"] = '%s-%s-%s' % (servip, area, isp)
    info = row[4]
    context["pie_contents"] = make_pie_items(info)

    # maps
    item["geos"] = get_china_geos(area, isp, info, tflow, 0.02)
    item["rates"] = make_rates(area, isp, info, tflow, 0.02)
    item["flows"] = make_flows(info, tflow, 0.02)

    context['item'] = item
    return render_to_response('bestv_servers_map.html', context)
Beispiel #5
0
    response = render_to_response('show_dbuffer.html', context)
    set_default_values_to_cookie(response, context)
    return response


def get_device_type1(request):
    service_type = request.GET.get('service_type', "B2C")
    begin_date = request.GET.get('begin_date', str(today()))
    end_date = request.GET.get('end_date', str(today()))
    try:
        min_rec = int(request.GET.get("min_rec", '300'))
    except Exception, e:
        min_rec = 300

    if begin_date == str(today()) and end_date == str(today()):
        begin_date = str(get_day_of_day(-1))
        end_date = begin_date

    device_types = get_device_types1(service_type, begin_date, end_date,
                                     min_rec)
    resp_str = json.dumps({"device_types": device_types})

    return HttpResponse(resp_str, content_type="text/json")


def get_version1(request):
    service_type = request.GET.get('service_type', "B2C")
    device_type = request.GET.get('device_type', "")
    begin_date = request.GET.get('begin_date', str(today()))
    end_date = request.GET.get('end_date', str(today()))
    min_rec = request.GET.get("min_rec", '300')