gpt4 book ai didi

powershell - 获取磁盘 IO 性能计数器

转载 作者:行者123 更新时间:2023-12-03 23:35:18 24 4
gpt4 key购买 nike

我需要在特定进程运行时获取系统的页面错误和磁盘 IO。

我可以获得页面错误但无法获得磁盘 IO:

 $arrayDIO = @()
$arrayPf = @()
$cmdProcess = start-process cmd -passthru
while (-not $cmdProcess.HasExited) {
$arrayDIO += %{ (Get-WmiObject Win32_PerfFormattedData_PerfProc_Process).IOWriteOperationsPerSec }
$arrayPf += %{ (Get-WmiObject Win32_PerfFormattedData_PerfOS_memory).PageFaultsPerSec }
sleep 2
}
$arrayPf | Measure-Object -Average -Maximum -Minimum | Out-File -Filepath C:\Details.txt
$arrayDIO | Measure-Object -Average -Maximum -Minimum | Out-File -Filepath C:\Details.txt -append

最佳答案

而不是 获取-WMIObject ,使用内置命令获取性能数据,获取计数器 :
Get-Counter '\Process(*)\IO Data Operations/sec'Get-Counter '\Memory\Page Faults/sec'

关于powershell - 获取磁盘 IO 性能计数器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17853946/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com