快活林资源网 Design By www.csstdc.com

核心代码

'程序名称:      btlwchk_DiskIO.vbs
'版权信息:      Copyright (c)  2011 guangzhou bluetech technology Incorporated.All rights reserved
'程序用途:      监测windows主机IO利用率
'创建日期:      2011-08-10
'作者信息:      zhangkai
'运行环境:      vbs
'处理参数
MonSubject="DiskIO"
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次采样IO
Set colItems = objWMIService.ExecQuery("Select * from Win32_PerfRawData_PerfDisk_LogicalDisk where name='_Total' ",,48)
For Each objItem in colItems
     DiskTime1 = objItem.PercentDiskTime
     BaseTime1 = objItem.PercentDiskTime_Base
  DiskBytes1 = objItem.DiskBytesPerSec
  DiskReadBytes1 = objItem.DiskReadBytesPerSec
  DiskWriteBytes1 = objItem.DiskWriteBytesPerSec
  AvgDiskTransfer1 = objItem.AvgDiskSecPerTransfer
  AvgDiskTransferBase1 = objItem.AvgDiskSecPerTransfer_Base
  AvgDiskRead1 = objItem.AvgDiskSecPerRead
  AvgDiskReadBase1 = objItem.AvgDiskSecPerRead_Base
  AvgDiskWrite1 = objItem.AvgDiskSecPerWrite
  AvgDiskWriteBase1 = objItem.AvgDiskSecPerWrite_Base
  TimeValue1 = objItem.Timestamp_PerfTime
  TimeBase = objItem.Frequency_PerfTime

Next

'第2次采样IO
WScript.Sleep 1000
Set colItems = objWMIService.ExecQuery("Select * from Win32_PerfRawData_PerfDisk_LogicalDisk where name='_Total' ",,48)
For Each objItem in colItems
     DiskTime2 = objItem.PercentDiskTime
  BaseTime2 = objItem.PercentDiskTime_Base
  DiskBytes2 = objItem.DiskBytesPerSec
  DiskReadBytes2 = objItem.DiskReadBytesPerSec
  DiskWriteBytes2 = objItem.DiskWriteBytesPerSec
  AvgDiskTransfer2 = objItem.AvgDiskSecPerTransfer
  AvgDiskTransferBase2 = objItem.AvgDiskSecPerTransfer_Base
  AvgDiskRead2 = objItem.AvgDiskSecPerRead
  AvgDiskReadBase2 = objItem.AvgDiskSecPerRead_Base
  AvgDiskWrite2 = objItem.AvgDiskSecPerWrite
  AvgDiskWriteBase2 = objItem.AvgDiskSecPerWrite_Base
  TimeValue2 = objItem.Timestamp_PerfTime
        CurrentDiskQueueLength = objItem.CurrentDiskQueueLength
Next

'获取IO利用率
If BaseTime2 - BaseTime1 = 0 Then
 strio ="Name=_Toltal"  & ",PercentDiskTime=0%"
Else
 PercentDiskTime =(DiskTime2 - DiskTime1)/(BaseTime2 - BaseTime1)*100 
 strio = "Name=_Total"  & ",PercentDiskTime="  & PercentDiskTime
End If

'获取Disk Bytes/sec
If TimeValue2 - TimeValue1 = 0 Then
    strdiskbyte = ",DiskBytesPerSec=0"
Else
    DiskBytesPerSec = (DiskBytes2 - DiskBytes1) / ( (TimeValue2 - TimeValue1) / TimeBase)
    strdiskbyte = ",DiskBytesPerSec="  & DiskBytesPerSec
End If

'获取Disk Read Bytes/sec
If TimeValue2 - TimeValue1 = 0 Then
    strdiskreadbyte = ",DiskReadBytesPerSec=0"
Else
    DiskReadBytesPerSec = (DiskReadBytes2 - DiskReadBytes1) / ( (TimeValue2 - TimeValue1) / TimeBase)
    strdiskreadbyte = ",DiskReadBytesPerSec="  & DiskReadBytesPerSec
End If

'获取Disk Write Bytes/sec
If TimeValue2 - TimeValue1 = 0 Then
    strdiskwritebyte = ",DiskWriteBytesPerSec=0"
Else
    DiskWriteBytesPerSec = (DiskWriteBytes2 - DiskWriteBytes1) / ( (TimeValue2 - TimeValue1) / TimeBase)
    strdiskwritebyte = ",DiskWriteBytesPerSec="  & DiskWriteBytesPerSec
End If

'获取Avg. Disk sec/Transfer
If AvgDiskTransferBase2 - AvgDiskTransferBase1 = 0 Then
    stravgdisktran = ",AvgDiskSecPerTransfer=0"
Else
    AvgDiskSecPerTransfer = ((AvgDiskTransfer2 - AvgDiskTransfer1) / TimeBase) / (AvgDiskTransferBase2 - AvgDiskTransferBase1)
    stravgdisktran = ",AvgDiskSecPerTransfer="  & AvgDiskSecPerTransfer
End If

'获取Avg. Disk sec/Read
If AvgDiskReadBase2 - AvgDiskReadBase1 = 0 Then
    stravgdiskread = ",AvgDiskSecPerRead=0"
Else
    AvgDiskSecPerRead = ((AvgDiskRead2 - AvgDiskRead1) / TimeBase) / (AvgDiskReadBase2 - AvgDiskReadBase1)
    stravgdiskread = ",AvgDiskSecPerRead="  & AvgDiskSecPerRead
End If

'获取Avg. Disk sec/Write
If AvgDiskWriteBase2 - AvgDiskWriteBase1 = 0 Then
    stravgdiskwrite = ",AvgDiskSecPerWrite=0"
Else
    AvgDiskSecPerWrite = ((AvgDiskWrite2 - AvgDiskWrite1) / TimeBase) / (AvgDiskWriteBase2 - AvgDiskWriteBase1)
    stravgdiskwrite = ",AvgDiskSecPerWrite="  & AvgDiskSecPerWrite
End If

'获取Current Disk Queue Length
strdisklength = ",CurrentDiskQueueLength="  & CurrentDiskQueueLength

Wscript.Echo MonSubject & " 0:OK|" & strio & strdiskbyte & strdiskreadbyte & strdiskwritebyte & stravgdisktran & stravgdiskread & stravgdiskwrite & strdisklength

用到了WMI,需要的朋友可以参考一下

快活林资源网 Design By www.csstdc.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
快活林资源网 Design By www.csstdc.com

《魔兽世界》大逃杀!60人新游玩模式《强袭风暴》3月21日上线

暴雪近日发布了《魔兽世界》10.2.6 更新内容,新游玩模式《强袭风暴》即将于3月21 日在亚服上线,届时玩家将前往阿拉希高地展开一场 60 人大逃杀对战。

艾泽拉斯的冒险者已经征服了艾泽拉斯的大地及遥远的彼岸。他们在对抗世界上最致命的敌人时展现出过人的手腕,并且成功阻止终结宇宙等级的威胁。当他们在为即将于《魔兽世界》资料片《地心之战》中来袭的萨拉塔斯势力做战斗准备时,他们还需要在熟悉的阿拉希高地面对一个全新的敌人──那就是彼此。在《巨龙崛起》10.2.6 更新的《强袭风暴》中,玩家将会进入一个全新的海盗主题大逃杀式限时活动,其中包含极高的风险和史诗级的奖励。

《强袭风暴》不是普通的战场,作为一个独立于主游戏之外的活动,玩家可以用大逃杀的风格来体验《魔兽世界》,不分职业、不分装备(除了你在赛局中捡到的),光是技巧和战略的强弱之分就能决定出谁才是能坚持到最后的赢家。本次活动将会开放单人和双人模式,玩家在加入海盗主题的预赛大厅区域前,可以从强袭风暴角色画面新增好友。游玩游戏将可以累计名望轨迹,《巨龙崛起》和《魔兽世界:巫妖王之怒 经典版》的玩家都可以获得奖励。