主頁(yè) > 知識(shí)庫(kù) > 網(wǎng)絡(luò)接口利用率監(jiān)控VBS腳本代碼(Windows)

網(wǎng)絡(luò)接口利用率監(jiān)控VBS腳本代碼(Windows)

熱門(mén)標(biāo)簽:外呼營(yíng)銷(xiāo)下單系統(tǒng) 海外美發(fā)店地圖標(biāo)注 前鋒辦理400電話(huà)申請(qǐng) 陜西高頻外呼回?fù)芟到y(tǒng)哪家好 加盟電銷(xiāo)機(jī)器人好的品牌 辦理膠州400電話(huà)財(cái)稅 百度地圖標(biāo)注怎么卸載 新密防封卡外呼系統(tǒng)違法嗎 打電話(huà)的外呼系統(tǒng)貴不貴
復(fù)制代碼 代碼如下:

'程序名稱(chēng): btlwchk_netinterface.vbs
'程序用途: 監(jiān)測(cè)windows主機(jī)網(wǎng)絡(luò)接口利用率
'創(chuàng)建日期: 2011-09-1
'作者信息: zhangkai
'運(yùn)行環(huán)境: vbs
'處理參數(shù)

MonSubject="NetInterface"
Set Args=WScript.Arguments
If (Args.Count1) Then
Wscript.Echo MonSubject " -1:command line error"
WScript.Quit(3)
End If
strcid=Args(0)
'獲取工作目錄
tmparr=Split(Wscript.ScriptFullName,"\",-1)
g_strworkdir=tmparr(0)
narr=UBound(tmparr,1)
For i=1 to narr-3
g_strworkdir=g_strworkdir "\" tmparr(i)
Next
'裝載公共庫(kù)
set g_fileSys = createObject ("Scripting.FileSystemObject")
Sub includeFile (fSpec)
dim file, fileData
set file = g_fileSys.openTextFile (fSpec)
fileData = file.readAll ()
file.close
executeGlobal fileData
set file = nothing
end sub
includeFile g_strworkdir "\nagios\libexec\libcomm.vbs"


'輸出版本和幫助信息
getverhelp strcid,"v1.00"," cid>"

strComputer = "."
Set objWMIService = GetObject("winmgmts:" "{impersonationLevel=impersonate}!\\" strComputer "\root\cimv2")

'第1次采樣
Set colItems = objWMIService.ExecQuery("Select * from Win32_PerfRawData_Tcpip_NetworkInterface",,48)
Dim BytesTotalPersec1(20),TimeValue1(20),Name1(20),CurrentBandwidth(20),BytesReceivedPerSec1(20),BytesSentPerSec1(20),PacketsReceivedPerSec1(20),PacketsSentPerSec1(20),_
BytesTotalPersec(20),PercentNetwork(20),BytesReceivedPerSec(20),BytesSentPerSec(20),PacketsReceivedPerSec(20),PacketsSentPerSec(20)
n=0
For Each objItem in colItems
Name1(n) = objItem.Name
BytesTotalPersec1(n) = objItem.BytesTotalPersec
BytesReceivedPerSec1(n) = objItem.BytesReceivedPerSec
BytesSentPerSec1(n) = objItem.BytesSentPerSec
PacketsReceivedPerSec1(n) = objItem.PacketsReceivedPerSec
PacketsSentPerSec1(n) = objItem.PacketsSentPerSec
TimeValue1(n) = objItem.Timestamp_PerfTime
CurrentBandwidth(n) = objItem.CurrentBandwidth
TimeBase = objItem.Frequency_PerfTime
n=n+1
Next

'第2次采樣
WScript.Sleep 1000
Set colItems = objWMIService.ExecQuery("Select * from Win32_PerfRawData_Tcpip_NetworkInterface",,48)
Dim BytesTotalPersec2(20),TimeValue2(20),Name2(20),BytesReceivedPerSec2(20),BytesSentPerSec2(20),PacketsReceivedPerSec2(20),PacketsSentPerSec2(20)
k=0
For Each objItem in colItems
Name2(k) = objItem.Name
BytesTotalPersec2(k) = objItem.BytesTotalPersec
BytesReceivedPerSec2(k) = objItem.BytesReceivedPerSec
BytesSentPerSec2(k) = objItem.BytesSentPerSec
PacketsReceivedPerSec2(k) = objItem.PacketsReceivedPerSec
PacketsSentPerSec2(k) = objItem.PacketsSentPerSec
TimeValue2(k) = objItem.Timestamp_PerfTime
k=k+1
Next

j=0
For i=0 to n-1
If TimeValue2(j) - TimeValue1(j) = 0 Then
strnetwork = "BytesTotalPersec=0"
Else
'帶寬利用率= (BytesReceivedPerSec + BytesSentPerSec)*8*100/ CurrentBandwidth
'計(jì)算利用率
BytesTotalPersec(j) = (BytesTotalPersec2(j) - BytesTotalPersec1(j)) / ((TimeValue2(j) - TimeValue1(j)) / TimeBase)
PercentNetwork(j) = BytesTotalPersec(j)*8*100 / CurrentBandwidth(j)
PercentNetwork(j) = round(PercentNetwork(j),2)

'計(jì)算BytesReceivedPerSec
BytesReceivedPerSec(j) = (BytesReceivedPerSec2(j) - BytesReceivedPerSec1(j)) / ((TimeValue2(j) - TimeValue1(j)) / TimeBase)/1024
BytesReceivedPerSec(j) = round(BytesReceivedPerSec(j),2)

'計(jì)算BytesSentPerSec
BytesSentPerSec(j) = (BytesSentPerSec2(j) - BytesSentPerSec1(j)) / ((TimeValue2(j) - TimeValue1(j)) / TimeBase)/1024
BytesSentPerSec(j) = round(BytesSentPerSec(j),2)

'計(jì)算PacketsReceivedPerSec
PacketsReceivedPerSec(j) = (PacketsReceivedPerSec2(j) - PacketsReceivedPerSec1(j)) / ((TimeValue2(j) - TimeValue1(j)) / TimeBase)
PacketsReceivedPerSec(j) = round(PacketsReceivedPerSec(j),2)

'計(jì)算PacketsSentPerSec
PacketsSentPerSec(j) = (PacketsSentPerSec2(j) - PacketsSentPerSec1(j)) / ((TimeValue2(j) - TimeValue1(j)) / TimeBase)
PacketsSentPerSec(j) = round(PacketsSentPerSec(j),2)

'計(jì)算CurrentBandwidth
CurrentBandwidth(j) = CInt(CurrentBandwidth(j)/1000/1000)
End If
If j = 0 Then
Wscript.Echo MonSubject " 0:OK|Name=" Name1(j) ",PercentNetwork=" PercentNetwork(j) ",BytesReceivedPerSec=" BytesReceivedPerSec(j) ",BytesSentPerSec=" BytesSentPerSec(j) _
",PacketsReceivedPerSec=" PacketsReceivedPerSec(j) ",PacketsSentPerSec=" PacketsSentPerSec(j) ",CurrentBandwidth=" CurrentBandwidth(j)
End If
'Wscript.Echo MonSubject " 0:OK|" Name1(j) ",PercentNetwork=" PercentNetwork
j=j+1
Next
您可能感興趣的文章:
  • vbs定期監(jiān)控 值個(gè)班,定期瞄一下
  • 磁盤(pán)IO利用率監(jiān)控VBS腳本(windows)
  • VBScript 監(jiān)控并結(jié)束指定進(jìn)程的代碼
  • VBScript 監(jiān)控磁盤(pán)更改事件實(shí)現(xiàn)代碼
  • VBS監(jiān)控CPU的使用率(如占用率一直維持在80%超過(guò)30秒則運(yùn)行某程序)
  • 進(jìn)程監(jiān)控實(shí)現(xiàn)代碼[vbs+bat]
  • 用VBS調(diào)用程序并對(duì)程序的運(yùn)行情況進(jìn)行監(jiān)控的兩個(gè)代碼
  • 如何使用vb 監(jiān)控電腦活動(dòng)記錄

標(biāo)簽:梅州 伊春 阜陽(yáng) 武威 河南 牡丹江 咸陽(yáng) 四平

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《網(wǎng)絡(luò)接口利用率監(jiān)控VBS腳本代碼(Windows)》,本文關(guān)鍵詞  網(wǎng)絡(luò),接口,利用率,監(jiān)控,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《網(wǎng)絡(luò)接口利用率監(jiān)控VBS腳本代碼(Windows)》相關(guān)的同類(lèi)信息!
  • 本頁(yè)收集關(guān)于網(wǎng)絡(luò)接口利用率監(jiān)控VBS腳本代碼(Windows)的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章