|
cisco 设备巡检脚本 share
巡检脚本.bat
#$language = "VBScript"
#$interface = "1.0"
'深圳巡检和log记录,包括GSR、7600、7500,每种类型设备生成两个文件
Sub main
crt.Screen.Synchronous = True
crt.Session.Log false
Dim fso, f, str,path_command,logfile
Const ForReading = 1
Set fso = CreateObject("Scripting.FileSystemObject")
d_date = right("00" & Month(Now()),2)&right("00" & Day(Now()),2)
Hours = right("00" & Hour(Time()),2)
min = right("00" & Minute(Time()),2)
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FolderExists( d_date )) <> True Then
Set f = fso.CreateFolder( d_date )
CreateFolderDemo = f.Path
End If
If (fso.FolderExists( d_date & "\深圳\")) <> True Then
Set f = fso.CreateFolder( d_date & "\深圳\")
CreateFolderDemo = f.Path
End If
logpath = d_date & "\深圳\"
logtime = Hours & min
Set f = fso.OpenTextFile("深圳巡检设备地址.txt", ForReading, 0)
Do While f.AtEndOfStream <> True
str = f.Readline
If Trim(str)=";GSR" Then
path_command = "巡检脚本\深圳GSR巡检命令.txt"
logfile = "深圳GSR-"
logfile = logpath & logfile & logtime & ".log" 'GSR巡检记录成一个文件
crt.Session.LogFileName = logfile
crt.Session.Log True
end if
If Trim(str)=";SR" Then
crt.Session.Log false
logfile = "深圳SR-"
logfile = logpath & logfile & logtime & ".log" 'GSR巡检记录成一个文件
crt.Session.LogFileName = logfile
crt.Session.Log True
path_command = "巡检脚本\深圳SR巡检命令.txt"
end if
If Trim(str)=";75设备" Then
crt.Session.Log false
logfile = "深圳75-"
logfile = logpath & logfile & logtime & ".log" 'GSR巡检记录成一个文件
crt.Session.LogFileName = logfile
crt.Session.Log True
path_command = "巡检脚本\深圳75巡检命令.txt"
end if
If Trim(str)=";access 二层65设备" Then
crt.Session.Log false
logfile = "深圳65二层-"
logfile = logpath & logfile & logtime & ".log" 'GSR巡检记录成一个文件
crt.Session.LogFileName = logfile
crt.Session.Log True
path_command = "巡检脚本\65_二层巡检脚本.txt"
end if
If Trim(str)=";45" Then
crt.Session.Log false
logfile = "深圳45-"
logfile = logpath & logfile & logtime & ".log" 'GSR巡检记录成一个文件
crt.Session.LogFileName = logfile
crt.Session.Log True
path_command = "巡检脚本\45巡检脚本.txt"
end if
if IsNumeric(left(Trim(str),2)) then
crt.Screen.Send "telnet " & Trim(Left(Str,15)) & chr(13)
If crt.Screen.WaitForString("sername:",10) <> True Then
crt.Screen.Send Chr(3)
crt.Screen.WaitForString "$"
Else
crt.Screen.Send "qware" & chr(13)
crt.Screen.WaitForString "assword:"
crt.Screen.Send "szguoliang" & chr(13)
crt.Screen.WaitForString ">"
Set file = fso.OpenTextFile(path_command, ForReading, 0)
Do While file.AtEndOfStream <> True
str = file.Readline
crt.Screen.Send str & chr(13)
'if crt.Screen.Get (crt.Screen.CurrentRow,3,crt.Screen.CurrentRow,6) = "More" then
' crt.Screen.Send " " & chr(13)
'end if
if crt.Screen.WaitForString (">",30) <> true then
crt.Screen.Send Chr(3)
crt.Screen.WaitForString "$"
exit do
else
crt.Screen.Send chr(13)
crt.Screen.WaitForString ">"
end if
Loop
file.close()
crt.Screen.Send "exit" & chr(13)
End If
End If
crt.Screen.Send Chr(3)
crt.Screen.WaitForString "$"
Loop
crt.Session.Log false
f.close()
'所有设备的log信息采集
Set f = fso.OpenTextFile("深圳巡检设备地址.txt", ForReading, 0)
Do While f.AtEndOfStream <> True
str = f.Readline
If Trim(str)=";GSR" Then
logfile = "深圳GSR-loginfo-"
logfile = logpath & logfile & logtime & ".log" 'GSR巡检记录成一个文件
crt.Session.LogFileName = logfile
crt.Session.Log True
end if
If Trim(str)=";SR" Then
crt.Session.Log false
logfile = "深圳SR-loginfo-"
logfile = logpath & logfile & logtime & ".log" 'GSR巡检记录成一个文件
crt.Session.LogFileName = logfile
crt.Session.Log True
end if
If Trim(str)=";75设备" Then
crt.Session.Log false
logfile = "深圳75-loginfo-"
logfile = logpath & logfile & logtime & ".log" '75巡检记录成一个文件
crt.Session.LogFileName = logfile
crt.Session.Log True
end if
If Trim(str)=";access 二层65设备" Then
crt.Session.Log false
logfile = "深圳65二层-loginfo-"
logfile = logpath & logfile & logtime & ".log" '65巡检记录成一个文件
crt.Session.LogFileName = logfile
crt.Session.Log True
end if
If Trim(str)=";45" Then
crt.Session.Log false
logfile = "深圳45-loginfo-"
logfile = logpath & logfile & logtime & ".log" '45巡检记录成一个文件
crt.Session.LogFileName = logfile
crt.Session.Log True
end if
if IsNumeric(left(Trim(str),2)) then
crt.Screen.Send "telnet " & Trim(Left(Str,15)) & chr(13)
If crt.Screen.WaitForString("sername:",10) <> True Then
crt.Screen.Send Chr(3)
crt.Screen.WaitForString "$"
Else
crt.Screen.Send "qware" & chr(13)
crt.Screen.WaitForString "assword:"
crt.Screen.Send "szguoliang" & chr(13)
crt.Screen.WaitForString ">"
crt.Screen.Send "terminal length 0" & chr(13)
crt.Screen.WaitForString ">"
crt.Screen.Send "show logging | include Aug" & chr(13)
crt.Screen.WaitForString ">"
crt.Screen.Send "show logg buffer -100" & chr(13)
crt.Screen.WaitForString ">"
crt.Screen.Send "exit" & chr(13)
End If
End If
crt.Screen.Send Chr(3)
crt.Screen.WaitForString "$"
Loop
crt.Session.Log false
f.close()
crt.Screen.Synchronous = false
End Sub
==============================================================
深圳巡检设备地址.txt
;GSR 以下为GSR地址
1.1.1.1 r1-r-gdsz
;SR 以下为SR地址
2.2.2.2 65-3
;75设备
3.3.3.3 75-1-sz
;45
4.4.4.4 45-1-sz
’210.22.30.50
;access 二层65设备
5.5.5.5 65-1-sz
===============================================================
深圳GSR巡检命令.txt
terminal length 0
show version
show led
show red st
show red
show gsr
sh redun states
sh diag | in SLOT | crash
sh contr fia
sh contr err
sh contr pos
show proce me | in Free|Dead
show proce cpu | exclude 0.00
show context all
sh buff | in free | hits
sh int | in line | errors
show env
show power |
|