将 PerfRawData 值转换为执行数据 -WMI

发布于 2024-09-24 22:26:55 字数 149 浏览 3 评论 0原文

我需要将 PagesPersec 值从 Win32_PerfRawData_PerfOS_Memory 转换为 PerfFormatted 数据值。如何将 PerfRaw 数据值从 WMI 性能计数器转换为 PerfFormatted 数据值。是否有 Windows 推荐的标准公式。

I need to convert PagesPersec value from Win32_PerfRawData_PerfOS_Memory to PerfFormatted Data value .How to convert PerfRaw data values from WMI Perfomance counters to PerfFormatted Data values .Is there Standard Formula available recommended by Windows.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

红玫瑰 2024-10-01 22:26:55

您需要的公式取决于 CounterType ...参见
http://msdn.microsoft.com/en- us/library/aa392761(v=VS.85).aspx

要开始使用,请查看

The formula you need depends on the CounterType ... see
http://msdn.microsoft.com/en-us/library/aa392761(v=VS.85).aspx

to get started, have a look at http://msdn.microsoft.com/en-us/library/aa394597.aspx

这里回答太长了。有一篇非常好的文章,其中包含示例 http://msdn.microsoft.com/en -us/library/ms974615.aspx

简而言之:这取决于计数器类型。对于某些计数器,我可以只读取(磁盘可用空间)并需要根据两个请求进行计算,一个请求比另一个请求晚一点,例如:

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
    ("Select * From Win32_PerfRawData_PerfOS_Processor Where Name = '0'")
For Each objItem in colItems
    CounterValue1 = objItem.InterruptsPerSec
    TimeValue1 = objItem.TimeStamp_PerfTime
    TimeBase = objItem.Frequency_PerfTime
Next
For i = 1 to 5
    Wscript.Sleep(1000)
    Set colItems = objWMIService.ExecQuery _
       ("Select * From Win32_PerfRawData_PerfOS_Processor Where Name = '0'")
    For Each objItem in colItems
        CounterValue2 = objItem.InterruptsPerSec
        TimeValue2 = objItem.TimeStamp_PerfTime
        If TimeValue2 - TimeValue1 = 0 Then
            Wscript.Echo "Interrupts Per Second = 0"
        Else
            intInterrupts = (CounterValue2 - CounterValue1) / _
                ( (TimeValue2 - TimeValue1) / TimeBase)
            Wscript.Echo "Interrupts Per Second = " & Int(intInterrupts)
        End if
        CounterValue1 = CounterValue2
        TimeValue1 = TimeValue2
    Next
Next

It is too long to answer here. There is a very good article with samples http://msdn.microsoft.com/en-us/library/ms974615.aspx

In a brief: it depends on the counter type. For some counters it can me just read (disk free space) and come require calculation based on two requests one a bit later than another, for example:

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
    ("Select * From Win32_PerfRawData_PerfOS_Processor Where Name = '0'")
For Each objItem in colItems
    CounterValue1 = objItem.InterruptsPerSec
    TimeValue1 = objItem.TimeStamp_PerfTime
    TimeBase = objItem.Frequency_PerfTime
Next
For i = 1 to 5
    Wscript.Sleep(1000)
    Set colItems = objWMIService.ExecQuery _
       ("Select * From Win32_PerfRawData_PerfOS_Processor Where Name = '0'")
    For Each objItem in colItems
        CounterValue2 = objItem.InterruptsPerSec
        TimeValue2 = objItem.TimeStamp_PerfTime
        If TimeValue2 - TimeValue1 = 0 Then
            Wscript.Echo "Interrupts Per Second = 0"
        Else
            intInterrupts = (CounterValue2 - CounterValue1) / _
                ( (TimeValue2 - TimeValue1) / TimeBase)
            Wscript.Echo "Interrupts Per Second = " & Int(intInterrupts)
        End if
        CounterValue1 = CounterValue2
        TimeValue1 = TimeValue2
    Next
Next
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文