def armErr(cursor,Errdict): sql_err = '' for err_key in Errdict.keys(): if err_key == 'sqlErr' or err_key == 'host': ###插入采集日志 isErr = dealSql.insertSql(cursor,err_key,'','',Errdict[err_key],'1',err_key) if type(isErr) is str: sql_err = sql_err + "【异常信息告警" + isErr + "】" else: role_names = dealSql.getRoleName(cursor,err_key) mod_msg = dealSql.getModmsg(cursor,err_key) if type(mod_msg) is str: if type(mod_msg) is str: sql_err = sql_err + "【异常信息告警" + mod_msg + "】" mod_msg = '' if type(role_names) is str: sql_err = sql_err + "【异常信息告警" + role_names + "】" role_names = '' if len(role_names) == 0: isErr = dealSql.insertSql(cursor,err_key,'',Errdict[err_key],mod_msg[0] + Errdict[err_key],'1','') if type(isErr) is str: sql_err = sql_err + "【异常信息告警" + isErr + "告警信息:" + Errdict[err_key] + "模块" + mod_msg[0] + "】" for role_name in role_names: isErr = dealSql.insertSql(cursor,err_key,'',Errdict[err_key],mod_msg[0] + Errdict[err_key],'1',role_name[0]) if type(isErr) is str: sql_err = sql_err + "【异常信息告警" + isErr + "告警信息:" + Errdict[err_key] + "模块" + mod_msg[0] + "】" return sql_err
def insert(cursor,mod_id,msgdict): rstlist = [] role_names = dealSql.getRoleName(cursor,mod_id) if type(role_names) is str: rstlist.append(role_names) role_names = '' for v_key in msgdict.keys(): if v_key == '0' or v_key == '1': for msdlist in msgdict[v_key]: if len(role_names) == 0: isErr = dealSql.insertSql(cursor,mod_id,msdlist[0],msdlist[2],msdlist[1] + msdlist[2],v_key,'') if type(isErr) is str: rstlist.append(isErr) for role_name in role_names: isErr = dealSql.insertSql(cursor,mod_id,msdlist[0],msdlist[2],msdlist[1] + msdlist[2],v_key,role_name[0]) if type(isErr) is str: rstlist.append(isErr) elif v_key == '2' or v_key == '3': mod_msg = dealSql.getModmsg(cursor,mod_id) if type(mod_msg) is str: rstlist.append(mod_msg) mod_msg = '' CMD_VALUE = '' for msdlist in msgdict[v_key]: CMD_VALUE = CMD_VALUE + '【' + msdlist[1] + msdlist[2] + '】' if len(role_names) == 0: isErr = dealSql.insertSql(cursor,mod_id,'',CMD_VALUE,mod_msg[0] + CMD_VALUE,v_key,'') if type(isErr) is str: rstlist.append(isErr) for role_name in role_names: isErr = dealSql.insertSql(cursor,mod_id,'',CMD_VALUE,mod_msg[0] + CMD_VALUE,v_key,role_name[0]) if type(isErr) is str: rstlist.append(isErr) return rstlist