今天窝了一天,只接见一个人,京东送快递的。。。不过收到的可不是什么礼物啊,是大前天车上回来时下的订单,今天才到。。。
煮个瘦肉鸡蛋粥,外加一个苹果,就可以呆上一天。。。
期间接了几个电话,打几个电话,远程几次公司电脑,如果以后工作都可以这样,就好了。。。
好了,说下今天的主要成果,改造编写了VBScript, 在CRT用来自动登陆交换机,将N个交换机的MAC、CPU、内存等等信息采集出来,放到文本中,这东西早就应该弄出来了,交换机没网管,网管必备啊。。。
过段时间要弄个V2版本出来,与EXCEL链接,从EXCEL表中读取交换机IP等数据,然后登陆交换机,采集数据,再写入到EXCEL表中。
明天的计划,继续窝宿舍,尽量不外出。。。要初七才骑车逛~
#$language = "VBScript"
#$interface = "1.0"
'===================================================================================================
'何*****@chinaunicom** QQ:805450107 2013.02.14 Version 1.0
'===================================================================================================
strFileName=crt.Dialog.Prompt("将在D盘根目录生成交换机信息的TXT文本","输入文件名","NewFile")
strSwitchList=""
intQuit=0
if trim(strFileName)="" then strFileName="D:\123.txt" else strFileName="D:\" & strFileName & ".txt" end if
intMin=0
SwitchIP=Array("172.19.0.36","172.19.0.85","172.19.0.232","172.17.1.244","172.19.0.170")
intMax=UBound(SwitchIP)-LBound(SwitchIP)+1
if intMax>0 then
for i= intMin to intMax-1
funMain(SwitchIP(i))
next
strTxt="交换机总数:" & intMax & Chr(13) & Chr(10) &_
"交换机登陆不上个数: " & intQuit & Chr(13) & Chr(10)
strTxt=strTxt & "-------------------------------------------------------------------------------------------------------------------------------------------------" & Chr(13) & Chr(10)
strTxt=strTxt & "IP" & Chr(9) & Chr(9) & "SwitchName" & Chr(9) & Chr(9) & Chr(9) & "MAC" & Chr(9) & Chr(9) &_
"MODEL" & Chr(9) & Chr(9) & Chr(9) & "SerialNumber" & Chr(9) & "MANUFACTURED DATE" & Chr(9) &_
"CPU" & Chr(9) & "Memory" & Chr(9) & "PowerT1" & Chr(9) & "PowerT2" & Chr(13) & Chr(10)
strTxt=strTxt & "-------------------------------------------------------------------------------------------------------------------------------------------------" & Chr(13) & Chr(10)
strTxt=strTxt & strSwitchList
strTxt=strTxt & "-------------------------------------------------------------------------------------------------------------------------------------------------" & Chr(13) & Chr(10)
Set myFSO = CreateObject("Scripting.FileSystemObject")
'Set WriteStuff = myFSO.CreateTextFile(strFileName,8,ture)
Set WriteStuff = myFSO.OpenTextFile(strFileName, 8, True)
WriteStuff.WriteLine(strTxt)
WriteStuff.Close
msgbox("完成!" & chr(13) & chr(13) & "路径:" & strFileName)
set ws=createobject("wscript.shell")
ws.run strFileName,3,ture
else
crt.Dialog.MessageBox "没有交换机IP,退出!"
end if
Function funMain(i)
dim SwitchKey
crt.Screen.Send "telnet " & i & chr(13)
SwitchKey = crt.Screen.WaitForStrings("Username:","Can't connect to the remote host!",10)
select case SwitchKey
case 1
crt.Screen.Send "dgcnc"& chr(13)
crt.Screen.WaitForString("Password:")
crt.Screen.Send "dgcnc"& chr(13)
crt.Screen.WaitForString("login",10)
crt.Screen.Send "disp device manuinfo"& chr(13)
crt.Screen.WaitForString(">")
crt.Screen.Synchronous = True
screenrow=crt.screen.CurrentRow
screencolumn=crt.screen.CurrentColumn
strName=crt.Screen.Get( screenrow, 0, screenrow, screencolumn )
strMac=crt.Screen.Get( screenrow-3, 24, screenrow-3, 37 )
strModel=crt.Screen.Get( screenrow-5, 24, screenrow-5, 42 )
strSerial=crt.Screen.Get( screenrow-4, 24, screenrow-4, 43 )
strDate=crt.Screen.Get( screenrow-2, 24, screenrow-2, 33 )
crt.Screen.Send "disp cpu"& chr(13)
crt.Screen.WaitForString(">")
screenrow=crt.screen.CurrentRow
screencolumn=crt.screen.CurrentColumn
strCPU=crt.Screen.Get( screenrow-1, 5, screenrow-1, 7 )
crt.Screen.Send "disp memory"& chr(13)
crt.Screen.WaitForString(">")
screenrow=crt.screen.CurrentRow
screencolumn=crt.screen.CurrentColumn
strMemory=crt.Screen.Get( screenrow-1, 12, screenrow-1, 14 )
crt.Screen.Send "disp environment"& chr(13)
crt.Screen.WaitForString(">")
screenrow=crt.screen.CurrentRow
screencolumn=crt.screen.CurrentColumn
strPower1=crt.Screen.Get( screenrow-2, 18, screenrow-2, 23 )
strPower2=crt.Screen.Get( screenrow-1, 18, screenrow-1, 23 )
strSwitchList= strSwitchList & i & chr(9) & strName & chr(9) & _
strMac & chr(9) & strModel & Chr(9) & strSerial & Chr(9) & strDate & Chr(9) &_
strCPU & Chr(9) & strMemory & Chr(9) & strPower1 & Chr(9) & strPower2 & Chr(9) & Chr(13) & Chr(10)
crt.Screen.Send "quit"& chr(13)
crt.Screen.WaitForString("-JX>")
case else
crt.Screen.Send chr(3)
intQuit=intQuit+1
strSwitchList= strSwitchList & i & chr(9) & "登陆失败!" & Chr(13) & Chr(10)
crt.Screen.WaitForString("-JX>")
end select
end Function
去年今日,白天发生什么全忘记了,下班后骑车回来在加乐福那里收到玫瑰花,和陈兵一起在新中银打球,花放到椅子那里,901的同事也过来。