开发者

Suspicious value from WMI Win32_PerfRawData_PerfOS_PagingFile PercentUsage figure

开发者 https://www.devze.com 2022-12-19 10:36 出处:网络
I\'ve written a little VBScript program to query the page file usage under Windows XP (eventually 2003/2008 Server as well) but the figures I seem to be getting are bizarre.

I've written a little VBScript program to query the page file usage under Windows XP (eventually 2003/2008 Server as well) but the figures I seem to be getting are bizarre.

This is the program:

Set wmi = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
for i = 1 to 10
    Set qry1 = wmi.ExecQuery ("Select * from Win32_PageFileSetting")
    Set qry2 = wmi.ExecQuery ("Select * from Win32_PerfRawData_PerfOS_PagingFile")
    initial = 0
    maximum = 0
    For Each obj in qry1
        initial = initial + obj.InitialSize
        maximum = maximum + obj.MaximumSize
    Next
    For Each obj in qry2
        if obj.Name = "_Total" then
            Wscript.Echo _
                " Initial size: " & initial & _
                " Maximum size: " & maximum & _
                " Percent used: " & obj.PercentUsage & _
                ""
        end if
    Next
    qry1 = none
    qry2 = none
    WScript.sleep (1000)
Next

which outputs:

Initial size: 1512 Maximum size: 3024 Percent used: 21354
Initial size: 1512 Maximum size: 3024 Percent used: 21354
Initial size: 1512 Maximum size: 3024 Percent used: 21354
Initial size: 1512 Maximum size: 3024 Percent used: 21354
Initial size: 1512 Maximum size: 3024 Percent used: 21354
Initial size: 1512 Maximum size: 3024 Percent used: 21354
Initial size: 1512 Maximum size: 3024 Percent used: 21354
Initial size: 1512 Maximum size: 3024 Percent used: 21354
Initial size: 1512 Maximum size: 3024 Percent used: 21354
Initial size: 1512 Maximum size: 3024 Percent used: 21354

The doco on MSDN states:

PercentUsage

    Data type: uint32

    Access type: Read-only

    Qualifiers:

        DisplayName ("% Usage")

        CounterType (537003008)

        DefaultScale (0)

        开发者_开发问答PerfDetail (200)

    Percentage of the page file instance in use. For more information,

    see the PageFileBytes property in Win32_PerfRawData_PerfProc_Process.

Now that seems pretty straight-forward. Why is my 3G page file using 21000% of it's allocated space? That would be about 630G but pagefile.sys is only about 1.5G (and my entire hard disk is only 186G).


Update:

When I get the same field from Win32_PerfFormattedData_PerfOS_PagingFile, I get a more reasonable value of 5 but that still doesn't seem to coincide with Task Manager, which shows 1.06G usage out of the 3G maximum.


You can't operate with the value directly like that.

The CounterType of the ProcessUsage property is 537003008, which according to this table corresponds to the PERF_RAW_FRACTION counter. Given the formula from the second link, we end up with something like this:

" Percent used: " & ((obj.PercentUsage * 100) / obj.PercentUsage_Base) & _
0

精彩评论

暂无评论...
验证码 换一张
取 消