核心代码
'程序名称: 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,需要的朋友可以参考一下
标签:
VBS,磁盘,IO,利用率
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
暂无“磁盘IO利用率监控VBS脚本(windows)”评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。
更新动态
2024年11月23日
2024年11月23日
- 凤飞飞《我们的主题曲》飞跃制作[正版原抓WAV+CUE]
- 刘嘉亮《亮情歌2》[WAV+CUE][1G]
- 红馆40·谭咏麟《歌者恋歌浓情30年演唱会》3CD[低速原抓WAV+CUE][1.8G]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[320K/MP3][193.25MB]
- 【轻音乐】曼托凡尼乐团《精选辑》2CD.1998[FLAC+CUE整轨]
- 邝美云《心中有爱》1989年香港DMIJP版1MTO东芝首版[WAV+CUE]
- 群星《情叹-发烧女声DSD》天籁女声发烧碟[WAV+CUE]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[FLAC/分轨][748.03MB]
- 理想混蛋《Origin Sessions》[320K/MP3][37.47MB]
- 公馆青少年《我其实一点都不酷》[320K/MP3][78.78MB]
- 群星《情叹-发烧男声DSD》最值得珍藏的完美男声[WAV+CUE]
- 群星《国韵飘香·贵妃醉酒HQCD黑胶王》2CD[WAV]
- 卫兰《DAUGHTER》【低速原抓WAV+CUE】
- 公馆青少年《我其实一点都不酷》[FLAC/分轨][398.22MB]
- ZWEI《迟暮的花 (Explicit)》[320K/MP3][57.16MB]