You are on page 1of 6

Case "VERIFY MIPS FILE IN STATISTICS"

returnResult = fnVerifyMIPSfileInStatistics(rsTestData)
Case "VERIFY NDS FILE"
returnResult = fnverifyNDSfile(rsTestData)
Case "VERIFY MBMON"
returnResult = fnverifyMBMON(rsTestData)

'##################################################################################
##########
'Function Name: fnVerifyMIPSfileInStatistics
'Purpose: This function will navigate to Statistics directory and verify patern
'Input Parameters: rsTestData
'Output Parameters: Pass/Fail
'Date: 25-April-2016
'Author/POC: Manoja
'##################################################################################
##########

Function fnVerifyMIPSfileInStatistics(rsTestData)

ON Error Resume Next


args = rsTestData("COMMAND_ARGUMENTS").Value
strUnit = rsTestData("UNIT_NAME").Value
If Ucase(strUnit) = "UNIT FROM LAST OPERATION" Then
If strUnitIPForGroup = "" Then
UpdateLog"Machine IP from last Unix Operation has not been updated
successfully."
fnVerifyMIPSfileInStatistics = False
Else
strMachineIP = strUnitIPForGroup
End If
ElseIf not IsNumeric(right(strUnit,1)) Then
UpdateLog "Please provide specific machine in the cluster rather than unit
type which represents the multiple machines. eg. dsu1 rather than dsu"
fnVerifyMIPSfileInStatistics = False
Else
strMachineIP = GetMachineIP(strUnit)
End If
cmd = "VERIFYMIPSFILEINSTATISTICS"
If
fnAccessUnixSystem(strMachineIP,strUnixUid,strUnixPwd,strRootUnixPath,cmd,args)
Then
UpdateLog "Verification of MIPS message count is successful"
fnVerifyMIPSfileInStatistics = True
Else
UpdateLog "Verification of MIPS message count is unsuccessful"
fnVerifyMIPSfileInStatistics = False
Exit Function
End If

End Function

'##################################################################################
##########
'Function Name: fnverifyNDSfile
'Purpose: This function is used to verify NDS file created or not.
'Input Parameters: rsTestData
'Output Parameters: Pass/Fail
'Date: 06-May-2016
'Author/POC: Manoja
'##################################################################################
##########
Function fnverifyNDSfile(rsTestData)

On Error Resume Next


args = rsTestData("COMMAND_ARGUMENTS").Value
strUnit = rsTestData("UNIT_NAME").Value
If Ucase(strUnit) = "UNIT FROM LAST OPERATION" Then
If strUnitIPForGroup = "" Then
UpdateLog"Machine IP from last Unix Operation has not been updated
successfully."
fnverifyNDSfile = False
Else
strMachineIP = strUnitIPForGroup
End If
ElseIf not IsNumeric(right(strUnit,1)) Then
UpdateLog "Please provide specific machine in the cluster rather than unit
type which represents the multiple machines. eg. dsu1 rather than dsu"
fnverifyNDSfile = False
Else
strMachineIP = GetMachineIP(strUnit)
End If
cmd = "VERIFYNDSFILE"
If
fnAccessUnixSystem(strMachineIP,strUnixUid,strUnixPwd,strRootUnixPath,cmd,args)
Then
UpdateLog "Verification of NDS File is successful"
fnverifyNDSfile = True
Else
UpdateLog "Verification of NDS File is unsuccessful"
fnverifyNDSfile = False
Exit Function
End If
End Function

'##################################################################################
##########
'Function Name: fnverifyMBMON
'Purpose: This function is used to verify MBMON file
'Input Parameters: rsTestData
'Output Parameters: Pass/Fail
'Date: 06-May-2016
'Author/POC: Manoja
'##################################################################################
##########
Function fnverifyMBMON(rsTestData)

On Error Resume Next


args = rsTestData("COMMAND_ARGUMENTS").Value
strUnit = rsTestData("UNIT_NAME").Value
If Ucase(strUnit) = "UNIT FROM LAST OPERATION" Then
If strUnitIPForGroup = "" Then
UpdateLog"Machine IP from last Unix Operation has not been updated
successfully."
fnverifyMBMON = False
Else
strMachineIP = strUnitIPForGroup
End If
ElseIf not IsNumeric(right(strUnit,1)) Then
UpdateLog "Please provide specific machine in the cluster rather than unit
type which represents the multiple machines. eg. dsu1 rather than dsu"
fnverifyMBMON = False
Else
strMachineIP = GetMachineIP(strUnit)
End If
cmd = "VERIFYMBMON"
If
fnAccessUnixSystem(strMachineIP,strUnixUid,strUnixPwd,strRootUnixPath,cmd,args)
Then
UpdateLog "Verification of MBMON File is successful"
fnverifyMBMON = True
Else
UpdateLog "Verification of MBMON File is unsuccessful"
fnverifyMBMON = False
Exit Function
End If
End Function

------------------------------------------------------------

Python
--------------------------------------------------------------

In in UnixSystem.py
--------------------------

if sys.argv[1].upper() == "VERIFYMIPSFILEINSTATISTICS":
resultFlag = commonLib.fnVerifyMIPSfileInStatistics(ArgStr)

if sys.argv[1].upper() == "VERIFYNDSFILE":
resultFlag = commonLib.fnverifyNDSfile(ArgStr)

if sys.argv[1].upper() == "VERIFYMBMON":
resultFlag = commonLib.fnVerifyMBMON(ArgStr)

In commonLib.py
-----------------------

'''****************************************************
Function Name: fnVerifyMIPSfileInStatistics
Purpose: This function will navigate to Statistics directory and take latest MIPS
file and search patern
Input Parameters: N/A
Output Parameters: True/False
Date: 25-April-2016
Author/POC: Manoja
****************************************************'''

def fnVerifyMIPSfileInStatistics(ArgStr):
sFile = "cd /opt/criticalpath/global/statistics/ && ls MIPS_Statistics*|
tail -1"

p=subprocess.Popen(sFile,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
errStr = p.stderr.read()
out_p = p.stdout.read()
out_put= out_p[:-1]
if errStr !="":
fnlogs("Command: "+ sFile + " is not executed successfully.\n")
fnlogs("Error: \n" + errStr + "\n")
return False
else:
cmd = "grep " + "\"" + ArgStr + "\" " +
"/opt/criticalpath/global/statistics/"+out_put

p=subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
err_Str = p.stderr.read()
if err_Str !="":
fnlogs("Command: "+ cmd + " is not executed successfully.\n")
fnlogs("Error: \n" + err_Str + "\n")
return False
else:
output = p.stdout.read()
if output != "":
fnlogs("Statistics Record is Correct !!!\n")
return True
else:
fnlogs("Statistics Record does'nt Exist!!!\n")
return False

'''****************************************************
Function Name: fnverifyNDSfile
Purpose: The function is used to verify NDS file
Input Parameters: N/A
Output Parameters: True/False
Date: 06-May-2016
Author/POC: Manoja
****************************************************'''

def fnverifyNDSfile(ArgStr):
cmd = "cd /var/cti/logs/nds/ && ls access_log_nds.* | tail -1"

p=subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
errStr = p.stderr.read()
out_p = p.stdout.read()
out_put= out_p[:-1]
if errStr !="":
fnlogs("Command: "+ cmd + " is not executed successfully.\n")
fnlogs("Error: \n" + errStr + "\n")
return False
else:
cmds = "grep " + "\"" + ArgStr + "\" " +
"/var/cti/logs/nds/"+out_put

p=subprocess.Popen(cmds,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
time.sleep(2)
err_Str = p.stderr.read()
if err_Str !="":
fnlogs("Command: "+ cmds + " is not executed successfully.\n")
fnlogs("Error: \n" + err_Str + "\n")
return False
else:
output = p.stdout.read()
if output != "":
fnlogs("NDS Record is Correct !!!\n")
return True
else:
fnlogs("NDS Record does'nt Exist!!!\n")
return False

'''****************************************************
Function Name: fnVerifyMBMON
Purpose: This function will navigate to MBMON directory and take latest file and
search patern
Input Parameters: N/A
Output Parameters: True/False
Date: 25-April-2016
Author/POC: Manoja
****************************************************'''

def fnVerifyMBMON(ArgStr):
sList1 = ArgStr[0]
sList2 = ArgStr[1]
mFile = "cd /opt/MIPS/logs/dsu3/mbmon && ls|tail -1"

p=subprocess.Popen(mFile,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
errStr = p.stderr.read()
out_p = p.stdout.read()
out_put= out_p[:-1]
if errStr !="":
fnlogs("Command: "+ mFile + " is not executed successfully.\n")
fnlogs("Error: \n" + errStr + "\n")
return False
else:
cmd = "grep " + "\"" +sList1 + "\" " +
"/opt/MIPS/logs/dsu3/mbmon/"+out_put

p=subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
err_Str = p.stderr.read()
if err_Str !="":
fnlogs("Command: "+ cmd + " is not executed successfully.\n")
fnlogs("Error: \n" + err_Str + "\n")
return False
else:
output = p.stdout.read()
if output != "":
fnlogs("MBMON Record is Correct !!!\n")
else:
fnlogs("MBMON Record does'nt Exist!!!\n")
return False
cmd = "grep " + "\"" + sList2 + "\" " +
"/opt/MIPS/logs/dsu3/mbmon/"+out_put

p=subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
err_Str = p.stderr.read()
if err_Str !="":
fnlogs("Command: "+ cmd + " is not executed successfully.\n")
fnlogs("Error: \n" + err_Str + "\n")
return False
else:
output = p.stdout.read()
if output != "":
fnlogs("MBMON Record is Correct !!!\n")
return True
else:
fnlogs("MBMON Record does'nt Exist!!!\n")
return False

You might also like