none
WMI returns different data than System Monitor

    Frage

  • I am using WMI to obtain performance data. I want to know how many requests per second are entering into the IIS. I am using the “WebService” object and the “Total methods requests per sec” performance counter.

    I have created a script in VB in order to obtain the data from Win32_PerfFormattedData_W3SVC_WebService.TotalMethodRequestsPerSec.

    I made several tests and I don’t know why I receive different results depending on having the counter running in the System Monitor or not. It seems that there is some kind of interaction with the System Monitor and I would like someone to explain me why this is happening.

    The script does the following process:
    •    Refresh the counter.
    •    Wait a second.
    •    Refresh the counter again.
    •    Read the counter data.

    The servers where I performed the tests are receiving an average of 200 requests per second all day long.

    If I execute the script every 30 seconds without the “System Monitor” running, it returns values in the range of 1200 - 1600 requests per second. If I open the System Monitor and load the same counter, the script retrieves values in the range of 180-200 requests per second. In this last case, the script and the System Monitor show the same values. If I close the “System Monitor” and I execute the script again, it starts to return bigger values like at the beginning.

    Does anyone have any idea about this behavior?

    This is the script:

    Set colitems = _
        objRefresher.AddEnum(objWMIService, _
        "Win32_PerfFormattedData_W3SVC_WebService").objectSet
    
    objRefresher.Refresh
    
    Wscript.Sleep 1000
    
    objRefresher.Refresh
    
    for each objitem in colitems
    	if objItem.Name="_Total" then
    		WScript.echo objItem.TotalMethodRequestsPersec & ":OK"
    	end if
    next

    Thanks in advance.

    Mittwoch, 8. Februar 2012 09:46