3

I'm using WMI to monitor Windows Server 2003 and Windows Server 2008 hosts. I got all the info I wanted but the disk I/O performance.

I've tried quering the "Win32_PerfFormattedData_PerfDisk_LogicalDisk" for the "AvgDiskQueueLength", but I always get "no key" result.

The WMI service is running on both systems and I can connect to it using wbemtest without any errors.

Have I missed something or am I doing something wrong?

Jorge
  • 33
  • 1
  • 3

1 Answers1

1

AvgDiskQueueLength is a property of the Win32_PerfFormattedData_PerfDisk_LogicalDisk class. Unless the "no key" result is something really funky, it sounds like you maybe trying to access it wrong. It should be simple property notation like

win32perf.AvgDiskQueueLength

The following code should work.

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colDisks = objRefresher.AddEnum _
    (objWMIService, "win32_perfformatteddata_perfdisk_physicaldisk"). _
        objectSet
objRefresher.Refresh
For Each objDisk in colDisks
        Wscript.Echo "Average Disk Queue Length: " & vbTab &  _
           objDisk.AvgDiskQueueLength
Next

The refresher portion is really only needed if you're going to make multiple calls. Avoids having to execute the GetObject code over and over again.

You may want to research average disk queue length a bit though. I remember there being something funky about the way it's collected or reported. I might be wrong, but thought I'd mention it.

Jeffery Smith
  • 374
  • 1
  • 5
  • Thanks for the answer. The "no key" is the output of thw WQL query `SELECT AvgDiskQueueLength FROM Win32_PerfFormattedData_PerfDisk_LogicalDisk` That code worked, but it always return 0. I've tried another properties with the same result, the only one that seems to return an actual value is the "Name" propertie. – Jorge Nov 08 '11 at 10:54
  • Yeah, that was one of the things I tend to remember about the average disk queue length. It really only shows up under extreme load. Not sure what type of load your current box is under. Are you accepting this answer or are you still looking for something else? – Jeffery Smith Nov 08 '11 at 13:28
  • I'll accept it. it already put me in a good track. Thanks – Jorge Nov 08 '11 at 13:40