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?

0

1 Answer 1

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.

3
  • 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 8, 2011 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? Nov 8, 2011 at 13:28
  • I'll accept it. it already put me in a good track. Thanks
    – Jorge
    Nov 8, 2011 at 13:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .