神剑山庄资源网 Design By www.hcban.com
复制代码 代码如下:
'程序名称: btlwchk_netinterface.vbs
'程序用途: 监测windows主机网络接口利用率
'创建日期: 2011-09-1
'作者信息: zhangkai
'运行环境: vbs
'处理参数
MonSubject="NetInterface"
Set Args=WScript.Arguments
If (Args.Count<1) 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
'装载公共库
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
'计算利用率
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)
'计算BytesReceivedPerSec
BytesReceivedPerSec(j) = (BytesReceivedPerSec2(j) - BytesReceivedPerSec1(j)) / ((TimeValue2(j) - TimeValue1(j)) / TimeBase)/1024
BytesReceivedPerSec(j) = round(BytesReceivedPerSec(j),2)
'计算BytesSentPerSec
BytesSentPerSec(j) = (BytesSentPerSec2(j) - BytesSentPerSec1(j)) / ((TimeValue2(j) - TimeValue1(j)) / TimeBase)/1024
BytesSentPerSec(j) = round(BytesSentPerSec(j),2)
'计算PacketsReceivedPerSec
PacketsReceivedPerSec(j) = (PacketsReceivedPerSec2(j) - PacketsReceivedPerSec1(j)) / ((TimeValue2(j) - TimeValue1(j)) / TimeBase)
PacketsReceivedPerSec(j) = round(PacketsReceivedPerSec(j),2)
'计算PacketsSentPerSec
PacketsSentPerSec(j) = (PacketsSentPerSec2(j) - PacketsSentPerSec1(j)) / ((TimeValue2(j) - TimeValue1(j)) / TimeBase)
PacketsSentPerSec(j) = round(PacketsSentPerSec(j),2)
'计算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
'程序名称: btlwchk_netinterface.vbs
'程序用途: 监测windows主机网络接口利用率
'创建日期: 2011-09-1
'作者信息: zhangkai
'运行环境: vbs
'处理参数
MonSubject="NetInterface"
Set Args=WScript.Arguments
If (Args.Count<1) 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
'装载公共库
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
'计算利用率
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)
'计算BytesReceivedPerSec
BytesReceivedPerSec(j) = (BytesReceivedPerSec2(j) - BytesReceivedPerSec1(j)) / ((TimeValue2(j) - TimeValue1(j)) / TimeBase)/1024
BytesReceivedPerSec(j) = round(BytesReceivedPerSec(j),2)
'计算BytesSentPerSec
BytesSentPerSec(j) = (BytesSentPerSec2(j) - BytesSentPerSec1(j)) / ((TimeValue2(j) - TimeValue1(j)) / TimeBase)/1024
BytesSentPerSec(j) = round(BytesSentPerSec(j),2)
'计算PacketsReceivedPerSec
PacketsReceivedPerSec(j) = (PacketsReceivedPerSec2(j) - PacketsReceivedPerSec1(j)) / ((TimeValue2(j) - TimeValue1(j)) / TimeBase)
PacketsReceivedPerSec(j) = round(PacketsReceivedPerSec(j),2)
'计算PacketsSentPerSec
PacketsSentPerSec(j) = (PacketsSentPerSec2(j) - PacketsSentPerSec1(j)) / ((TimeValue2(j) - TimeValue1(j)) / TimeBase)
PacketsSentPerSec(j) = round(PacketsSentPerSec(j),2)
'计算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
标签:
网络接口,利用率
神剑山庄资源网 Design By www.hcban.com
神剑山庄资源网
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
神剑山庄资源网 Design By www.hcban.com
暂无网络接口利用率监控VBS脚本代码(Windows)的评论...
《魔兽世界》大逃杀!60人新游玩模式《强袭风暴》3月21日上线
暴雪近日发布了《魔兽世界》10.2.6 更新内容,新游玩模式《强袭风暴》即将于3月21 日在亚服上线,届时玩家将前往阿拉希高地展开一场 60 人大逃杀对战。
艾泽拉斯的冒险者已经征服了艾泽拉斯的大地及遥远的彼岸。他们在对抗世界上最致命的敌人时展现出过人的手腕,并且成功阻止终结宇宙等级的威胁。当他们在为即将于《魔兽世界》资料片《地心之战》中来袭的萨拉塔斯势力做战斗准备时,他们还需要在熟悉的阿拉希高地面对一个全新的敌人──那就是彼此。在《巨龙崛起》10.2.6 更新的《强袭风暴》中,玩家将会进入一个全新的海盗主题大逃杀式限时活动,其中包含极高的风险和史诗级的奖励。
《强袭风暴》不是普通的战场,作为一个独立于主游戏之外的活动,玩家可以用大逃杀的风格来体验《魔兽世界》,不分职业、不分装备(除了你在赛局中捡到的),光是技巧和战略的强弱之分就能决定出谁才是能坚持到最后的赢家。本次活动将会开放单人和双人模式,玩家在加入海盗主题的预赛大厅区域前,可以从强袭风暴角色画面新增好友。游玩游戏将可以累计名望轨迹,《巨龙崛起》和《魔兽世界:巫妖王之怒 经典版》的玩家都可以获得奖励。
更新日志
2024年11月17日
2024年11月17日
- 【雨果唱片】中国管弦乐《鹿回头》WAV
- APM亚流新世代《一起冒险》[FLAC/分轨][106.77MB]
- 崔健《飞狗》律冻文化[WAV+CUE][1.1G]
- 罗志祥《舞状元 (Explicit)》[320K/MP3][66.77MB]
- 尤雅.1997-幽雅精粹2CD【南方】【WAV+CUE】
- 张惠妹.2007-STAR(引进版)【EMI百代】【WAV+CUE】
- 群星.2008-LOVE情歌集VOL.8【正东】【WAV+CUE】
- 罗志祥《舞状元 (Explicit)》[FLAC/分轨][360.76MB]
- Tank《我不伟大,至少我能改变我。》[320K/MP3][160.41MB]
- Tank《我不伟大,至少我能改变我。》[FLAC/分轨][236.89MB]
- CD圣经推荐-夏韶声《谙2》SACD-ISO
- 钟镇涛-《百分百钟镇涛》首批限量版SACD-ISO
- 群星《继续微笑致敬许冠杰》[低速原抓WAV+CUE]
- 潘秀琼.2003-国语难忘金曲珍藏集【皇星全音】【WAV+CUE】
- 林东松.1997-2039玫瑰事件【宝丽金】【WAV+CUE】