def run(logfile, *args,**kwargs):
    "this function execute the check steps and return "
    loglines = file(logfile).readlines()
    result = ResultInfo(name)
    info = []
    error = ''
    
    # check the NG version first.
    ngversion=get_ng_version(logfile)

    if not ngversion:  # not version info found.
        #status = CheckStatus.UNKNOWN
        info.append("    - NG version can't be determindated.")
        #error = "NG version is not found."

    elif ngversion[0][:3] == '3.2':
        status,info,error = check_memory_fail_counter(loglines)
        if status == CheckStatus.FAILED and len(info)>0:
            result.status = status
    

    ## check function 2
    status,_info,error = check_memory_allocation(loglines)

    info.append(''.join(_info))
    #result.status = status

    result.update(status=status,info=info,error=error)
    return result
Example #2
0
def run(logfile):
    """module entry of S11 Throttling validation

    Parse the log file and return the result of the validation.

    Arguments:
        logfile { str } -- the name of the log file

    Returns:
        { libs.checker.ResultInfo }
    """
    result = ResultInfo(name,priority=priority)
    info = []
    errmsg = ''

    # MME version
    try:
        ns_version = ""
        ns_version = shareinfo.get('ELEMENT').version['BU']
        debugmsg("get the ns version [%s]" % ns_version)
        info.append(u"当前NS/MME软件版本是[%s]\n" % ns_version)
        if ns_version in target_versions:
            debugmsg("ns version is in the target versions")
            info.append(u"当前NS/MME软件版本存在Throttling功能开启风险\n")
        else:
            debugmsg("ns version is not in the target versions")
            info.append(u"当前NS/MME软件版本不存在Throttling功能开启风险\n")
            result.status = CheckStatus.PASSED
            result.update(info=info, error=errmsg)
            return result
    except Exception as e:
        debugmsg("Can not get a correct ns version info from log, only got [%s]" % ns_version)
        result.status = CheckStatus.UNKNOWN
        info.append(u"NS/MME软件版本是[%s],无法准确判断版本信息,请人工核实。\n" % ns_version)
        errmsg = u'无法获取软件版本信息'
        result.update(info=info, error=errmsg)
        return result

    # throttling feature checking
    try:
        logspt = LogSpliter()
        logspt.load(logfile)
        logs = logspt.get_log(
            "DDE:IPDUcat /opt/mme/conf/mmeGTPLBS-0x0968.ini", fuzzy=True)
    except Exception as e:
        info.append(u"日志文件无法加载,请检查命令参数是否正确!\n")
        errmsg = u"日志文件无法加载,请检查命令参数是否正确!"
        result.status = CheckStatus.UNKNOWN
    else:
        try:
            result.status, extra_info = is_throttling_on(logs)
            info.extend(extra_info)
        except Exception as e:
            info.append("%s\n" % e.args[0])
            errmsg = e.args[0]
            result.status = CheckStatus.UNKNOWN
    result.update(info=info, error=errmsg)
    return result
Example #3
0
def run(logfile):
    Ns_version_Patt = r"\s*\S+\s+BU\s+\S+\s+(\w+\d+\s*\S+)\s+Y\s+Y\s*$"
    version = Find_NS_MME_Patt_Return_Info_List(logfile, 'WQO:CR;',
                                                Ns_version_Patt, 1)[0]

    result = ResultInfo(name)
    info = []
    errmsg = ''

    # ns version checking
    if is_NS15_version_id(
            version, target_versions) > 0 or version_up_NS15_id(version) > 0:
        info.append(u"    - NS/MME软件版本是[%s]。" % version)
    else:
        m = re.search(know_version_identify_Patt, version)
        if m:
            result.status = CheckStatus.PASSED
            info.append(u"    - NS/MME软件版本是[%s],不存在该问题。" % version)
        else:
            result.status = CheckStatus.UNKNOWN
            info.append(u"    - NS/MME软件版本是[%s],无法准确判断版本信息,请人工核实。" % version)
            if version == '':
                errmsg = u'无法判断版本信息'
        result.update(info=info, error=errmsg)
        return result

    # throttling feature checking
    try:
        logspt = LogSpliter()
        logspt.load(logfile)
        logs = logspt.get_log("DDE:IPDUcat /opt/mme/conf/mmeGTPLBS-0x0968.ini",
                              fuzzy=True)
    except Exception as e:
        errmsg = "日志文件无法加载,请检查命令参数是否正确!"
        result.status = CheckStatus.UNKNOWN
    else:
        try:
            result.status, extra_info = is_throttling_on(logs)
            info.extend(extra_info)
        except Exception as e:
            errmsg = str(e)
            result.status = CheckStatus.UNKNOWN
    result.update(info=info, error=errmsg)
    return result
Example #4
0
def run(logfile):
    result = ResultInfo(name)
    info = []
    errmsg = ''

    version = get_ng_version(logfile)
    #version(version,release,hw_ver) -> ('3.1_1.0', '235397', '2')

    if version and version[0] in target_versions:
        result.status = CheckStatus.PASSED
        info.append("    - NG%s_r%s_AB%s" % version)
    elif version and version[0] not in target_versions:
        result.status = CheckStatus.FAILED
        info.append("    - NG%s_r%s_AB%s" % version)
    else:
        result.status = CheckStatus.UNKNOWN

    result.update(info=info, error=errmsg)
    return result
Example #5
0
def run(logfile, *args, **kwargs):
    "this function execute the check steps and return "
    loglines = file(logfile).readlines()
    result = ResultInfo(name, priority=priority)
    info = []
    error = ''

    ng = shareinfo['ELEMENT']
    debugmsg("NG info:%s" % ng)
    # check the NG version first.
    if not ng.version:  # not version info found.
        #status = CheckStatus.UNKNOWN
        info.append(logline_format % "NG version can't be determindated.")

    else:
        match = ng.match_version(major=target_version)

        if match['major']:
            status, info, error = check_memory_fail_counter(loglines)
            if status == CheckStatus.FAILED and len(info) > 0:
                result.status = status
        else:
            major_version = ng.version['major']
            info.append(logline_format %
                        ("this NG version is `%s`, not affected by this TN." %
                         major_version))

    ## check function 2
    status, _info, error = check_memory_allocation(loglines)
    info.append(''.join(_info))

    ## check Hicut setting
    #hicut = ng.config.get('hicut')
    hicut = hicut_setting(loglines)
    if hicut == '1':
        status = CheckStatus.FAILED
        error = '- The Hicut feature is still enable: fngDpiHicut=1'
    else:
        info.append("- The Hicut feature is disable: fngDpiHicut=0")
    result.update(status=status, info=info, error=error)
    return result
Example #6
0
import re
from libs.checker import ResultInfo, CheckStatus
from libs.infocache import shareinfo
from libs.flexing import FlexiNG

__author__ = '*****@*****.**'

## Mandatory variables
##--------------------------------------------
module_id = 'tn_ts_sw0081'
tag = ['flexing', 'china']
priority = 'critical'
name = "Check PCC rule filter in disabled state"
desc = __doc__
criteria = u"There is PCC rule filter in DISABLE status"
result = ResultInfo(name, priority=priority)
error = ''
##--------------------------------------------

##--------------------------------------------
## Optional variables
target_version = ['3.2', '15']
## first get the block of each 'filter-state'

pats_stat = {
    'pcc-rule-cmd': re.compile(r"show ng service-awareness pcc-rule"),
    'pcc-rule-name': re.compile(r"pcc-rule-name = (.*)"),
    'filter-state-disable': re.compile(r"filter-state = disable"),
    'filter-state-enable': re.compile(r"filter-state = enable")
}
charging-profile = charging-profile-1
other cc=1,2,3,5,6,7,9 can use the same way.
"""
import re
from libs.checker import ResultInfo, CheckStatus
from libs.flexing import get_ng_version

## Mandatory variables
##--------------------------------------------
module_id = '20160304.01'
tag = ['flexing', 'china']
priority = 'critical'
name = u"校验Session Profile中的Charging character配置"
desc = __doc__
criteria = u"NG Charging character configuration have problem "
result = ResultInfo(name)
error = ''
##--------------------------------------------

##--------------------------------------------
## Optional variables
target_version = ['3.1_1.0', '3.2', '15']

## first get the block of each 'show session-profile'
## from each block we will get the session-profile 's name and charging-index config
pats_charchar = {
    'session-profile-block':
    re.compile(r"show ng session-profile (.*)\n(.* = .*(\n)+)+"),
    'session-profile-name':
    re.compile(r"session-profile-name = (.*)"),
    'charchar-index':
def run(logfile):
	result = ResultInfo(name)
	info   = []
	errmsg = ''
	Ns_version_Patt=r"\s*\S+\s+BU\s+\S+\s+(\w+\d+\s*\S+)\s+Y\s+Y\s*$"
	try :
		version = Find_NS_MME_Patt_Return_Info_List(logfile,'WQO:CR;',Ns_version_Patt,1)[0]
	except IndexError:
		version = ''
##	print "\n****Find version id is : ",version
	if is_NS15_version_id(version,target_versions)>0 or version_up_NS15_id(version)>0:
		result.status = CheckStatus.PASSED
		info.append(u"    - 检查到 NS/MME 软件版本为:'%s' ,它属于或者高于NS15版本." % version)
	else:
		m=re.search(know_version_identify_Patt,version)
		if m:
			result.status = CheckStatus.FAILED
			info.append(u"    - 检查到 NS/MME 软件版本为:'%s' ,它不属于或者低于NS15版本." % version)
		else:
			result.status = CheckStatus.UNKNOWN
			info.append(u"    - 检查到 NS/MME 软件版本为:'%s' ,它不属于NS/MME主流版本,请手动确认版本信息." % version)
			if version == '':
				errmsg = ' Have not find NS Version release identification !!'
		result.update(info=info,error=errmsg)
		return result
	
	InfoPatt_mapping=r"\s*02244\s+MME_CC_MAPPING_ENABLED\s+(\S+)\s+YESs*$"
	try:
		MME_CC_MAPPING_ENABLED_Value = int(Find_NS_MME_Patt_Return_Info_List(logfile,'WOI:;',InfoPatt_mapping,1)[0],16)
	except IndexError:
		MME_CC_MAPPING_ENABLED_Value = None
##	print "MME_CC_MAPPING_ENABLED_Value = ",MME_CC_MAPPING_ENABLED_Value
	if MME_CC_MAPPING_ENABLED_Value == 1:
		result.status = CheckStatus.PASSED
		info.append(u"    - 检查到 NS/MME 功能开关PRFILE002:2244-MME_CC_MAPPING_ENABLED已开启.")
	else:
		result.status = CheckStatus.FAILED
		info.append(u"    - 检查到 NS/MME 功能开关PRFILE002:2244-MME_CC_MAPPING_ENABLED未开启.")
		result.update(info=info,error=errmsg)
		return result
	EPCEMM_Patt = r"\s*(\S*)\s+EMM\s*$"
	EPCESM_Patt = r"\s*(\S*)\s+ESM\s*$"
	Cause_code_set_EMM_Name_List = Find_NS_MME_Patt_Return_Info_List(logfile,'KAL:;',EPCEMM_Patt,1)
	Cause_code_set_ESM_Name_List = Find_NS_MME_Patt_Return_Info_List(logfile,'KAL:;',EPCESM_Patt,1)
	Cause_code_set_EPCEMM = returnNotMatchItemInList(Cause_code_set_EMM_Name_List,'EMMDEF')
	Cause_code_set_EPCESM = returnNotMatchItemInList(Cause_code_set_ESM_Name_List,'ESMDEF')

##	print "Cause_code_set_EPCEMM = ",Cause_code_set_EPCEMM
##	print "Cause_code_set_EPCESM = ",Cause_code_set_EPCESM
	
	EmmIntcause142_Patt = r"\s*EXTERNAL\s+CAUSE\s+:\s+(\d+)\s*$"
	EmmIntcause96_Patt = r"\s*EXTERNAL\s+CAUSE\s+:\s+(\d+)\s*$"
	EsmIntcause165_Patt = r"\s*EXTERNAL\s+CAUSE\s+:\s+(\d+)\s*$"
	
	EmmIntcause142_Command = 'KAL:NAME=%s,TYPE=EMM,PROC=ATTREJ,INTCAUSE=142:;' % (Cause_code_set_EPCEMM)
	EmmIntcause96_Command = 'KAL:NAME=%s,TYPE=EMM,PROC=ATTREJ,INTCAUSE=96:;' % (Cause_code_set_EPCEMM)
	EsmIntcause165_Command = 'KAL:NAME=%s,TYPE=ESM,PROC=PDNCR,INTCAUSE=165:;' % (Cause_code_set_EPCESM)
	
	try:
		EmmExternal142 = int(Find_NS_MME_Patt_Return_Info_List(logfile,EmmIntcause142_Command,EmmIntcause142_Patt,1)[0])
	except IndexError:
		EmmExternal142 = None
	try:
		EmmExternal96= int(Find_NS_MME_Patt_Return_Info_List(logfile,EmmIntcause96_Command,EmmIntcause96_Patt,1)[0])
	except IndexError:
		EmmExternal96 = None
	try:
		EsmExternal165 = int(Find_NS_MME_Patt_Return_Info_List(logfile,EsmIntcause165_Command,EsmIntcause165_Patt,1)[0])
	except IndexError:
		EsmExternal165 = None

##	print "EmmExternal142 = ",EmmExternal142
##	print "EmmExternal96 = ",EmmExternal96
##	print "EsmExternal165 = ",EsmExternal165

	EmmExternal142_info_str = u"    - 检查到 NS/MME 的CAUSE CODE SETS: %s,TYPE=EMM,PROC=ATTREJ,INTCAUSE=142 To EXTERNAL CAUSE=%s" % (Cause_code_set_EPCEMM,EmmExternal142)
	EmmExternal96_info_str = u"    - 检查到 NS/MME 的CAUSE CODE SETS: %s,TYPE=EMM,PROC=ATTREJ,INTCAUSE=96 To EXTERNAL CAUSE=%s" % (Cause_code_set_EPCEMM,EmmExternal96)
	EsmExternal165_info_str = u"    - 检查到 NS/MME 的CAUSE CODE SETS: %s,TYPE=ESM,PROC=PDNCR,INTCAUSE=165 To EXTERNAL CAUSE=%s" % (Cause_code_set_EPCESM,EsmExternal165)
	info_dic = {'EmmExternal142':[15,EmmExternal142,EmmExternal142_info_str],
		'EmmExternal96':[7,EmmExternal96,EmmExternal96_info_str],
		'EsmExternal165':[33,EsmExternal165,EsmExternal165_info_str]
		}
	for check_Items in info_dic:
		print check_Items,info_dic[check_Items][1]
		if info_dic[check_Items][0] == info_dic[check_Items][1]:
			info.append(info_dic[check_Items][2])
		else:
			info.append(info_dic[check_Items][2].replace('- ','- !'))
			result.status = CheckStatus.FAILED

	info.append("\n")
	result.update(info=info,error=errmsg)
	return result
Example #9
0
def run(logfile):
    result = ResultInfo(name)
    info = []
    errmsg = ''
    Ns_version_Patt = r"\s*\S+\s+BU\s+\S+\s+(\w+\d+\s*\S+)\s+Y\s+Y\s*$"
    abnormal_flag = 0

    try:
        version = Find_NS_MME_Patt_Return_Info_List(logfile, 'WQO:CR;',
                                                    Ns_version_Patt, 1)[0]
    except IndexError:
        version = ''
##	print "\n****Find version id is : ",version
    if is_NS15_version_id(
            version, target_versions) > 0 or version_up_NS15_id(version) > 0:
        result.status = CheckStatus.PASSED
        info.append("    - 检查到 NS/MME 软件版本为:'%s' ,它属于或者高于NS15版本." % version)
    else:
        m = re.search(know_version_identify_Patt, version)
        if m:
            result.status = CheckStatus.FAILED
            info.append("    - 检查到 NS/MME 软件版本为:'%s' ,它不属于或者低于NS15版本." %
                        version)
        else:
            result.status = CheckStatus.UNKNOWN
            info.append(
                "    - 检查到 NS/MME 软件版本为:'%s' ,它不属于NS/MME主流版本,请手动确认版本信息." %
                version)
            if version == '':
                errmsg = ' Have not find NS Version release identification !!'
        result.update(info=info, error=errmsg)
        return result

#条件一 IPDU FREE MEMORY >20%
    #ZDOI:IPDU,0:M;
    #FREE MEMORY 2265 39
    CommandPatt = r"DOI:IPDU,\d{1}:M:+;"

    InfoPatt1 = r"^\s*FREE MEMORY\s+\S+\s+(\S+)\s*$"
    InfoPatt2 = r""

    try:
        MME_Usage = F_MME_Patt_Return_Info_List(logfile, CommandPatt,
                                                InfoPatt1, 0, InfoPatt2, 1, 0)
    except IndexError:
        MME_Usage[0][0] = "Unkown Error!"
        MME_Usage[0][1] = -1

    if MME_Usage[0][0] == "HIT":
        if float(MME_Usage[1][1]) < 20:
            abnormal_flag = 1
            info.append("    - 检查到 NS/MME IPDU 空闲内存存量过低 ." + MME_Usage[1][1])
        else:
            info.append("    - 检查到 NS/MME IPDU 空闲内存存量在门限范围: " +
                        MME_Usage[1][1])
    elif MME_Usage[0][0] == "UNHIT":

        info.append("    - 没有检查到特征字符串.")
    else:
        abnormal_flag = -1
        info.append("    - 检查过程中异常错误,结果未知。 Unknown Result.")

#条件二 ,IPDU 告警1143
    """
        <HIST> SHMME03BNK IPDU-0 SWITCH 2015-11-01 02:13:02.99
        * DISTUR IPDU-0 1A001-00-5 CPUPRO
        (6270) 1143 AMOUNT OF FREE MEMORY REDUCED
        00000000 00032000 00031A4C 00593DD0
        """

    InfoPatt_mapping1 = r"\s*1143\s+AMOUNT OF FREE MEMORY REDUCED"
    InfoPatt_mapping2 = r"IPDU-"
    try:
        MME_Alarm_1143 = F_MME_Patt_Return_Info_List(logfile, 'AHO:;',
                                                     InfoPatt_mapping1, -1,
                                                     InfoPatt_mapping2)
    except IndexError:
        MME_Alarm_1143[0][0] = "Unkown Error!"
        MME_Alarm_1143[0][1] = -1

    if MME_Alarm_1143[0][0] == "HIT":

        abnormal_flag = 1
        info.append("    - 检查到 NS/MME 1143 AMOUNT OF FREE MEMORY REDUCED 告警.")
    elif MME_Alarm_1143[0][0] == "UNHIT":

        info.append("    - 检查到 NO Alarm 1143.")
    else:
        abnormal_flag = -1
        info.append("    - 检查到过程中异常错误,结果未知。 Unknown Result.")

#条件三 IPDU lnx-mmeGTPLBS 进程内存利用 < 20%
    CommandPatt = r"DDE:IPDU,\d{1}:\"top -n1\",;"

    #11965 root 20 0 554m 231m 3500 S 9.9 4.0 3476:31 lnx-mmeGTPLBS
    InfoPatt1 = r"^.*\s+(\S+)\s+\S+\s+lnx-mmeGTPLBS"
    InfoPatt2 = r""
    try:
        MME_Usage = F_MME_Patt_Return_Info_List(logfile, CommandPatt,
                                                InfoPatt1, 0, InfoPatt2, 1, 0)
    except IndexError:
        MME_Usage[0][0] = "Unkown Error!"
        MME_Usage[0][1] = -1

    if MME_Usage[0][0] == "HIT":
        if float(MME_Usage[1][1]) > 20:
            abnormal_flag = 1
            info.append("    - 检查到 NS/MME slnx-mmeGTPLBS 内存占用过高 ." +
                        MME_Usage[1][1])
        else:
            info.append("    - 检查到 NS/MME slnx-mmeGTPLBS 内存占用在门限范围: " +
                        MME_Usage[1][1])
    elif MME_Usage[0][0] == "UNHIT":

        info.append("    - 没有检查到特征字符串.")
    else:
        abnormal_flag = -1
        info.append("    - 检查过程中异常错误,结果未知。 Unknown Result.")

    if abnormal_flag == -1:
        result.status = CheckStatus.UNKNOWN

    elif abnormal_flag == 1:

        result.status = CheckStatus.FAILED
    else:
        result.status = CheckStatus.PASSED

    info.append("\n")
    result.update(info=info, error=errmsg)
    return result