Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

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.

share|improve this answer
    
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 '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 8 '11 at 13:28
    
I'll accept it. it already put me in a good track. Thanks –  Jorge Nov 8 '11 at 13:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.