Options

SRST CHECK VBscript

LuckycharmsLuckycharms Member Posts: 267
So today i created a new VBscript that I figured some of you guys might be able to use. And some of you guys might be able to help add too. Below is a description of the script. Before you ask i used SecureCRT because I couldn't get Telnet.exe to scrap/parse more then the current line with out having it output to a file. (didn't want to go through the trouble.. I do have that script if you want it) And I am learning .Net... meaning I don't know it but i didn't want to mess with the whole .connect thing. Any ways ... Read on

YOU HAVE TO RUN THIS INSIDE SECURE-CRT
This script use's Un-Documented commands - I am not responsible for anything


Description: This script opens a predefined list of location/Ip's and logs into them. Then issues a test call ( now this doesn't test individual Dial-peers unless your design is setup with a single dial-peer that meets the criteria of the dialed phone number). It then parses the output to determine if the call was able to be placed and if so was there a setup failure ( line connection problem... so on ) or tone failure ( call was placed and dial-peers and line work correctly)... it then writes that output to a file for further interpretation.

I have an add-on's that I am working on but I am not done... ( e-mailing Output...etc...)

Once agein !!!!
This script use's Un-Documented commands - I am not responsible for anything

- Input file structure -


/---------------------------------------	
/	Created by:  Lucky 
/	
/	This file contains all the SRST Devices 
/  that need to be tested.  Add to this list 	
/  if additional SRST PSTN connections need 	
/  to be tested.  ( * do not add any more txt here)	
/----------------------------------------	
Location Name ,IPADDRESSS
TESTSITE ,127.0.0.1


- VBscript -

' Status  = Working ON
' |==================================================================================
' |    %%%% Created by :   Lucky 
' |    %%%% Version : 0.0(1) SecureCRT-version
' |     Description:  This script opens pre-defined files and attaches to devices found in these files.  It then sends 
' |                       a test call to a predefined location.   The output is analyzed and if call fail's then location is written
' |  		to a Failure.txt
' |       This script is open to any one that wants to use it, under the condition that I am not held responsible for any thing, EVER!!!
' |     Notes *  "C:\switch\SRST Check\Program\SRSTLocation.txt" is the folder where active clients are held.
' |    Notes*   "C:\switch\SRST Check\SRST Check.txt" is the file where Output is written.
' |===================================================================================

Dim objFSO, objTextFile, arrTextFile, DeviceIP, Location, Time 
Dim SRSToutputfile, row, screenrow, readline, index, arrFileLines
Dim QualifierCheck0, QualifierCheck1, QualifierCheck2, Qualifier

Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8


Const username = "******" ' Username to use for login
Const password = "******" ' Password for corresponding user
Const Phonenumber = "*******" ' Dialed Test Phone number
Const WorkingDirectory = "C:\switch\SRST Check\" ' Working Directory
Const Outputfilename = "SRST RESULTS.txt" ' name of SRST Check file
Const InputFile = "SRSTLocation.txt" ' The Input File for SRST Locations
	
Sub Main
	Set objFSO = CreateObject("Scripting.FileSystemObject")
	
	Call ClearOldSRSTFile
	Call OpenSRSTFile
	

End Sub

'| --------------------------------------------------------------------------------------------------------------------------------
'|  This clears the old SRST log file so that a new one can be create and no old data is proccessed.
'|    
	Function ClearOldSRSTFile
			If objFSO.FileExists(WorkingDirectory & Outputfilename) then
				objFSO.DeleteFile(WorkingDirectory & Outputfilename)
			End if
	End Function
'|_____________________________________________________________________________


'| --------------------------------------------------------------------------------------------------------------------------------
'|   This opens the CSV and parse's the file for Ip address, after which it kicks off Login/call Function
'| 	
	Function OpenSRSTFile
		Set objTextFile = objFSO.OpenTextFile(WorkingDirectory & InputFile, 1)
	' This is used to not read all the header information on the SRST txt file.
			objTextFile.Skipline
				objTextFile.Skipline
				objTextFile.Skipline
				objTextFile.Skipline
				objTextFile.Skipline
				objTextFile.Skipline
				objTextFile.Skipline
				objTextFile.Skipline
				objTextFile.Skipline
			Do Until objTextFile.AtEndofStream
				arrTextFile = split(objTextFile.Readline, ",") ' splits all data into array for parsing needs
				Location = arrTextFile(0)  ' Location Name
				DeviceIP = arrTextFile(1)  ' Device IP with no spaces in name
			Call Switchcommands(DeviceIP,Location)  ' Call's Switch Function and give variables
			loop
	End Function
'|_____________________________________________________________________________

'|---------------------------------------------------------------------------------------------------------------------------------------
'|   Login/Call function
'|         
	Function Switchcommands(DeviceIP,Location)
		Crt.screen.synchronous = True
			' This file is used for output of Location Pots checks.
			Set SRSToutputfile = objFSO.OpenTextFile(WorkingDirectory & Outputfilename, ForAppending, True)
			' Location Header Information - ( just to make the file look cleaner)
			SRSToutputfile.WriteLine(" ///-------------------------------------------\\\ ")
			SRSToutputfile.WriteLine("            ----@ " & Location & " ----               ")
			SRSToutputfile.WriteLine(" ///---------------------------------------------\\\ ")
						
			crt.Session.Connect "/Telnet " & DeviceIP & " 23" ' Telnets to device that was input into the Swtichcommand
			index = crt.Screen.WaitForStrings("Username:", "Password:")  ' Used the Predefined Username and Password listed in Const.
							
			If index = 1 Then 
				crt.Screen.Send username & vbCr	
				crt.Screen.WaitForString "Password:"
				 crt.Screen.Send password & vbCr
			End If
			
			' These are line commands sent to device.
			crt.Screen.WaitForString "#"  ' All cisco switch/routers have enable mode that send # as a string
			crt.Screen.Send vbCr ' this is just used to clean everything up (cosmetics)
			crt.Screen.WaitForString "#"
			crt.Screen.Send "! Start Test !" & vbCr ' Starts phone call script (cosmetics)  
			crt.Screen.WaitForString "#"
			crt.Screen.Send "csim start " & Phonenumber & vbCr ' sends Test Call command ( Phonenumber is a Const stated above)
			crt.Screen.WaitForString "#"
			crt.Screen.Send "! Finished Test !" & vbCr
				
				' Screen scrap - CRT 
				screenrow = crt.screen.CurrentRow - 2
				readline = crt.screen.Get(screenrow, 1, screenrow, 80)
			msgbox  "this is the readline output = " & readline  ' Used for testing
			
						Qualifier = split(readline, ",") 
						' Qualifier(0) =  csime: call attempted = X
						' Qualifier(1) = setup failed = x
						' Qualifier(2) = tone failed = x
			msgbox " This is Qualifier(0) " & Qualifier(0)  ' Used for testing
			msgbox " This is Qualifier(1) " & Qualifier(1)   ' Used for testing
			msgbox " This is Qualifier(2) " & Qualifier(2)   ' Used for testing
				QualifierCheck0 = InStr(Qualifier(0), "csim: call attempted = 1") 
				On Error Resume Next
					QualifierCheck1 = InStr(Qualifier(1), " setup failed = 1")
				On Error Resume Next
					QualifierCheck2 = InStr(Qualifier(2), " tone failed = 1") 
				On Error Resume Next 
			msgbox " This is QualifierCheck0 =  " & QualifierCheck0   ' Used for testing
			msgbox " This is QualifierCheck1 =  " & QualifierCheck1    ' Used for testing
			msgbox " This is QualifierCheck2 =  " & QualifierCheck2   ' Used for testing
				' If the Test is matched with the InStr then a number greate then 0 is given and you are able to match based on that.  
				if QualifierCheck0 => 1 then
								' Used for writing if the Location was checked or not
								SRSToutputfile.Write Location & " Test was Performed Correctly" & vbCrLf


								If QualifierCheck1 => 1 then
									' Setup Failure is due usally to misconfiguration or PhoneLine unplugged.
									SRSToutputfile.Write "SETUP FAILED --> CHECK POTS LINES" & vbCrLf
								ElseIf QualifierCheck2 => 1 then
									' Tone Failure  represents that the call was able to be completed and Pots lines work correctly
									SRSToutputfile.Write "LOCATION IS WORKING CORRECTLY" & vbCrLf
								End if
				ElseIf QualifierCheck =0 then
								SRSToutputfile.Write Location & " Test was NOT Performed " & vbCrLf
				End if 
						   
				
	'|----------------------------------------------------------------------------------------------------------------------------------
				
				crt.Screen.Send "Exit" & vbCr
				crt.Session.disconnect
				SRSToutputfile.close
	End function
'|________________________________________________________________________________
	

	
	
[/b]
The quality of a book is never equated to the number of words it contains. -- And neither should be a man by the number of certifications or degree's he has earned.

Comments

  • Options
    LuckycharmsLuckycharms Member Posts: 267
    wow 54 view and no comments... I guess this is the wrong place or crowd for this kind of stuff..
    The quality of a book is never equated to the number of words it contains. -- And neither should be a man by the number of certifications or degree's he has earned.
  • Options
    mikej412mikej412 Member Posts: 10,086 ■■■■■■■■■■
    Well yeah -- Voice is kind of a tough crowd. Wait until they get a few beers in them this weekend. :D

    So.... what else ya got?

    Oh -- got any sample output of the run?
    :mike: Cisco Certifications -- Collect the Entire Set!
  • Options
    LuckycharmsLuckycharms Member Posts: 267
    True...

    Last night I got bored.. ( i usually take a break from studying the day before a test anyways) And finished up the E-mailing part of the script...

    Next i will make it so that it runs off of .Net so that you don't need the SecureCRT. ( but that will take alittle while..)


    But as for Output the file looks like this..
     ///-------------------------------------------\\\ 
                ----@ Location1  ----               
     ///---------------------------------------------\\\ 
    Location1  Test was Performed Correctly
    SETUP FAILED --> CHECK POTS LINES
     ///-------------------------------------------\\\ 
                ----@ Location2  ----               
     ///---------------------------------------------\\\ 
    Location2  Test was NOT Performed 
     Check to make sure that Dial-Peers or hardware has not changed from original build. 
     ///-------------------------------------------\\\ 
                ----@ Location3  ----               
     ///---------------------------------------------\\\ 
    Location3  Test was Performed Correctly
    SETUP FAILED --> CHECK POTS LINES
     ///-------------------------------------------\\\ 
                ----@ Location4 ----               
     ///---------------------------------------------\\\ 
    Location4 Test was Performed Correctly
    LOCATION IS WORKING CORRECTLY
     ///-------------------------------------------\\\ 
                ----@ Location5----               
     ///---------------------------------------------\\\ 
    Location5 Test was Performed Correctly
    SETUP FAILED --> CHECK POTS LINES
     ///-------------------------------------------\\\ 
                ----@ Location6 ----               
     ///---------------------------------------------\\\ 
    Location6 Test was NOT Performed 
     Check to make sure that Dial-Peers or hardware has not changed from original build. 
     ///-------------------------------------------\\\ 
                ----@ Location7  ----               
     ///---------------------------------------------\\\ 
    Location7  Test was Performed Correctly
    SETUP FAILED --> CHECK POTS LINES
     ///-------------------------------------------\\\ 
                ----@ Location8  ----               
     ///---------------------------------------------\\\ 
    Location8  Test was Performed Correctly
    SETUP FAILED --> CHECK POTS LINES
     ///-------------------------------------------\\
    
    

    I also have alot of other scripts... ( mass changes /snmp or other things... Backup scripts that either kick off TFTP or screenScrap'... I actually automate alot of the stuff that I need to do to fix problem... never know when it might come in handy when you walk into a place..)
    The quality of a book is never equated to the number of words it contains. -- And neither should be a man by the number of certifications or degree's he has earned.
Sign In or Register to comment.