如何使用 PowerShell 获取进程性能计数器?
要获取所有与进程相关的计数器,你需要使用以下命令。
示例
Get-Counter -ListSet "*Processor*" | Select CounterSetName
输出
CounterSetName -------------- Processor Information Per Processor Network Activity Cycles Per Processor Network Interface Card Activity Hyper-V Worker Virtual Processor Hyper-V Hypervisor Virtual Processor Hyper-V Hypervisor Root Virtual Processor Hyper-V Hypervisor Logical Processor Processor Processor Performance
现在假设我们需要处理器性能计数器集,那么我们可以使用以下命令来检索其所有计数器。
PS C:\> Get-Counter -ListSet "Processor Performance" | Select -ExpandProperty Counter \Processor Performance(*)\Processor Frequency \Processor Performance(*)\% of Maximum Frequency \Processor Performance(*)\Processor State Flags
假设我们需要其中的处理器最大频率计数器,然后,
示例
Get-Counter -Counter '\Processor Performance(*)\% of Maximum Frequency'
输出
要连续运行性能计数器,请使用,
示例
Get-Counter -Counter '\Processor Performance(*)\% of Maximum Frequency' -Continuous
要检索特定时间间隔的特定数量的样本,
示例
Get-Counter -Counter '\Processor Performance(*)\% of Maximum Frequency' -SampleInterval 2 -MaxSamples 3
广告