示例#1
0
def getModmsg(cursor,mod_id):
    getRoleSql = "select mod_msg from monitor.TEST_arm_mod_conf where mod_id = " + str(mod_id)
    isErr = connectDb.executeSQL(cursor,getRoleSql)
    if type(isErr) is str:
        return "获得模块告警信息SQL执行异常" + isErr        
    role_name = connectDb.getSQLrst(cursor)
    return role_name[0]
示例#2
0
def getRoleName(cursor,mod_id):
    getRoleSql = "select role_name from monitor.T_role_prop where prop_name = (select mod_name from monitor.TEST_arm_mod_conf where mod_id = " + str(mod_id) +  ")"
    isErr = connectDb.executeSQL(cursor,getRoleSql)
    if type(isErr) is str:
        return "查询角色SQL执行异常" + isErr        
    role_name = connectDb.getSQLrst(cursor)
    return role_name
示例#3
0
def getArmConfId(cursor,arm_itv_ids):
    confId_sql = "select distinct mod_idvalue,mod_type,flag,arm_itv_id from monitor.T_ARM_MOD_ITV_CONF where flag <> '0' and arm_itv_id in(" + arm_itv_ids + ")"
    isErr = connectDb.executeSQL(cursor,confId_sql)
    if type(isErr) is str:
        return "查询告警模块ID Faild(T_ARM_MOD_ITV_CONF),执行语句失败,请查看DBLOG日志"
    confId_rsts = connectDb.getSQLrst(cursor)
    return confId_rsts
示例#4
0
def getArmMsgByConfId(cursor,confId,arm_range):
    armMsg_sql = "select to_char(insert_time,'YYYY-MM-DD hh24:mi:ss') || err_msg,role_name,arm_log_id from monitor.t_arm_log where arm_flag = '1' and arm_conf_id = '" + str(confId) + "' and insert_time >= sysdate - " + str(arm_range)
    isErr = connectDb.executeSQL(cursor,armMsg_sql)
    if type(isErr) is str:
        return "查询告警日志 Faild(T_ARM_LOG),执行语句失败,请查看DBLOG日志"
    armMsg_rsts = connectDb.getSQLrst(cursor)
    return armMsg_rsts
示例#5
0
def getHostInfoByid(cursor,host_id):
    host_sql = "select host_ip,port,log_user,passwd from monitor.T_host_conf where h_flag = '1' and h_id = " + str(host_id)
    
    isErr = connectDb.executeSQL(cursor,host_sql)
    if type(isErr) is str:
        return "查询主机信息SQL执行异常" + isErr        
    host_rsts = connectDb.getSQLrst(cursor)
    return host_rsts[0]
示例#6
0
def getphoneNumList(cursor,roleName):
    getphonSql = "select phone_no from monitor.t_role_phone where role_name = '" + str(roleName) +  "'"
    isErr = connectDb.executeSQL(cursor,getphonSql)
    if type(isErr) is str:
        return "查询号码列表失败:" + isErr        
    phones = connectDb.getSQLrst(cursor)
    phoneNumList = []
    for phone in phones:
        phoneNumList.append(phone[0])
    return phoneNumList
示例#7
0
def getAcqCMD(cursor):
    acq_itv_sql = '''
    select acq_itv_id from monitor.TEST_ACQ_INTERVAL_CONF t where (t.acq_type = '0' and t.acq_bg_time <= to_char(sysdate,'hh24miss') and t.acq_ed_time >= to_char(sysdate,'hh24miss')
    and (t.last_insert_time is null or sysdate - t.last_insert_time >= t.interval_value/60/24)
    )
    or 
    (nvl(t.last_insert_time,sysdate - 1) < trunc(sysdate) and 
     ((t.acq_type = '1' and to_char(sysdate,'hh24mi') >= t.interval_value)
       or (t.acq_type = '2' and trunc(sysdate,'iw') + substr(t.interval_value,1,1) -1 = trunc(sysdate) and to_char(sysdate,'hh24mi') >= substr(t.interval_value,3,4))
       or (t.acq_type = '3' and  to_char(sysdate,'dd') = decode(substr(t.interval_value,1,2),'00',to_char(last_day(sysdate),'dd'),substr(t.interval_value,1,2)) and to_char(sysdate,'hh24mi') >= substr(t.interval_value,4,4))
      )
    )
    '''

    
    isErr = connectDb.executeSQL(cursor,acq_itv_sql)
    if type(isErr) is str:
        return "查询采集频率SQL执行异常" + isErr
        
    itv_rsts = connectDb.getSQLrst(cursor)
    if type(itv_rsts) is str:
        return itv_rsts
    
    acq_itv = []
    cmddict = {}
    #    {[10.161.7.8]:[cmd,relation,key,arm_msg,alarm_type,mod_id]}
    for acq_rst in itv_rsts:
        acq_itv.append(acq_rst[0])
        arm_cmd_sql = "select host_id,m_cmd,relation,key,arm_msg,alarm_type,mod_id,m_id from monitor.TEST_arm_cmd_conf where m_flag = '1' and acq_itv_id = " + str(acq_rst[0]) 
        isErr = connectDb.executeSQL(cursor,arm_cmd_sql)
        if type(isErr) is str:
            return "查询监控项信息SQL执行异常" + isErr
        cmd_rsts = connectDb.getSQLrst(cursor)
        for cmd_rst in cmd_rsts:
            if cmddict.has_key(cmd_rst[0]):
                cmddict[cmd_rst[0]].append([cmd_rst[1],cmd_rst[2],cmd_rst[3],cmd_rst[4],cmd_rst[5],cmd_rst[6],cmd_rst[7]])
            else:
                cmddict[cmd_rst[0]] = [[cmd_rst[1],cmd_rst[2],cmd_rst[3],cmd_rst[4],cmd_rst[5],cmd_rst[6],cmd_rst[7]]]
    result = [acq_itv,cmddict]    
    return result
示例#8
0
def getArmItv(cursor):
    arm_itv_sql = '''
    select t.arm_itv_id,arm_range from monitor.T_ARM_INTERVAL_CONF t where (t.arm_type = '0' and t.arm_bg_time <= to_char(sysdate,'hh24miss') and t.arm_ed_time >= to_char(sysdate,'hh24miss')
        )
        or 
        (nvl(t.last_send_time,sysdate - 1) < trunc(sysdate) and 
         ((t.arm_type = '1' and to_char(sysdate,'hh24mi') >= t.interval_value)
           or (t.arm_type = '2' and trunc(sysdate,'iw') + substr(t.interval_value,1,1) -1 = trunc(sysdate) and to_char(sysdate,'hh24mi') >= substr(t.interval_value,3,4))
           or (t.arm_type = '3' and  to_char(sysdate,'dd') = decode(substr(t.interval_value,1,2),'00',to_char(last_day(sysdate),'dd'),substr(t.interval_value,1,2)) and to_char(sysdate,'hh24mi') >= substr(t.interval_value,4,4))
          )
        )
    '''

    
    isErr = connectDb.executeSQL(cursor,arm_itv_sql)
    if type(isErr) is str:
        return "查询告警时间段配置表T_ARM_INTERVAL_CONF,执行语句失败,请查看DBLOG日志"
    itv_rsts = connectDb.getSQLrst(cursor)
    return itv_rsts