Esempio n. 1
0
def getAlert():
    '''获取所有异常数据'''
    log = []
    alert = []
    #节点数据
    for i in ['T', 'A', 'B']:
        log.append(getNodeData('pos_machine', i)[0]) #total
        log.extend(getNodeData('vpos', i))
        log.extend(getNodeData('mgw', i))
        log.extend(getNodeData('posp', i))
        log.extend(getNodeData('internal', i))       
        log.extend(getNodeData('mbp', i))
        log.append(getNodeData('tais', i)[0])        #total
        log.append(getNodeData('mas', i)[0])         #total
        log.extend(getNodeData('aps', i))
    #bgw数据
    for i in ['cups_cp', 'cups_cnp', 'cups_kj', 'icbc_sh_kj', 'abc_sz_kj']:
        log.extend(getBgwData(i))
    #SLA数据
    for i in ['mas', 'aps', 'cups_cp', 'cups_cnp', 'icbc_sh_kj', 'abc_sz_kj']:
        log.extend(getSlaData(i))
    #Queue数据
    for i in ['mas', 'internal', 'tais', 'cis', 'bgw']:
        for j in ['T', 'A', 'B']:
            log.extend(getQueueData(i, j))
    #YW数据
    log.extend(getYWData())
    for i in log:
        if i['alert_level'] == 'warning':
            alert.append(i)
    for i in log:
        if i['alert_level'] == 'critical':
            alert.append(i)
    return alert
Esempio n. 2
0
def getNodePic(node):
    """根据报警情况返回对应图片"""
    data = getNodeData(node, "T")
    data.extend(getNodeData(node, "A"))
    data.extend(getNodeData(node, "B"))
    data.extend(getQueueData(node, "T"))
    data.extend(getQueueData(node, "A"))
    data.extend(getQueueData(node, "B"))
    # YW系统数据筛选出确定节点的告警数据
    data_yw = getYWData()
    YWData = []
    for i in data_yw:
        if i["node"] == node:
            YWData.append(i)
    data.extend(YWData)
    number_critical = number_warning = 0
    # total
    if node in ["pos_machine", "tais", "mas"]:
        for i in range(len(data)):
            if data[i]["alert_level"] == "critical":
                number_critical += 1
            elif data[i]["alert_level"] == "warning":
                number_warning += 1
        if number_critical >= 1:
            return "./static/image/" + node + "_critical.jpg"
        elif number_warning >= 1:
            return "./static/image/" + node + "_warning.jpg"
        else:
            return "./static/image/" + node + "_normal.jpg"
    # single
    else:
        for i in range(len(data)):
            if data[i]["alert_level"] == "critical" and data[i]["type"] == "Queue监控":
                number_critical += 2
            elif data[i]["alert_level"] == "critical":
                number_critical += 1
            elif data[i]["alert_level"] == "warning" and data[i]["type"] == "Queue监控":
                number_warning += 2
            elif data[i]["alert_level"] == "warning":
                number_warning += 1
        if number_critical >= 2:
            return "./static/image/" + node + "_critical.jpg"
        elif number_critical == 1 or number_warning >= 2:
            return "./static/image/" + node + "_warning.jpg"
        else:
            return "./static/image/" + node + "_normal.jpg"
Esempio n. 3
0
def pos_machine_b():
    return render_template('./cps/pos_machine_b.html', pos_machine=getNodeData('pos_machine', 'B'))
Esempio n. 4
0
def aps_b():
    return render_template('./cps/aps_b.html', aps=getNodeData('aps', 'B'))
Esempio n. 5
0
def ip_tais_b():
    return render_template('./cps/ip_tais_b.html', tais=getNodeData('tais', 'B'))
Esempio n. 6
0
def tais_a():
    return render_template('./cps/tais_a.html', tais=getNodeData('tais', 'A'))
Esempio n. 7
0
def mas_b():
    return render_template('./cps/mas_b.html', mas=getNodeData('mas', 'B'))
Esempio n. 8
0
def mbp_b():
    return render_template('./cps/mbp_b.html', mbp=getNodeData('mbp', 'B'))
Esempio n. 9
0
def internal_b():
    return render_template('./cps/internal_b.html', internal=getNodeData('internal', 'B'))
Esempio n. 10
0
def posp_b():
    return render_template('./cps/posp_b.html', posp=getNodeData('posp', 'B'))
Esempio n. 11
0
def mgw_b():
    return render_template('./cps/mgw_b.html', mgw=getNodeData('mgw', 'B'))
Esempio n. 12
0
def vpos_b():
    return render_template('./cps/vpos_b.html', vpos=getNodeData('vpos', 'B'))