代码之家  ›  专栏  ›  技术社区  ›  paxdiablo

来自wmi win32_perfrawdata_perfos_pagingfile percentusage图的可疑值

  •  2
  • paxdiablo  · 技术社区  · 15 年前

    我已经编写了一个小的vbscript程序来查询WindowsXP(最终也是2003/2008服务器)下的页面文件使用情况,但我得到的数据似乎很奇怪。

    这是程序:

    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
    

    输出:

    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
    

    关于msdn的doco声明:

    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.

    现在看来这是非常直接的。为什么我的3G页面文件使用21000%的分配空间?大约630克,但是 pagefile.sys 只有1.5克(我的整个硬盘只有186克)。


    更新:

    当我从同一个领域 Win32_PerfFormattedData_PerfOS_PagingFile ,我得到了一个更合理的值5,但这似乎仍然不符合任务管理器,它显示了1.06g的使用量超出了3g的最大值。

    1 回复  |  直到 15 年前
        1
  •  1
  •   arul    15 年前

    不能这样直接使用值进行操作。

    这个 CounterType ProcessUsage 财产是 537003008 哪一个 according to this table 对应于 PERF_RAW_FRACTION 计数器。根据第二个链接的公式,我们得到如下结果:

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