Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Disk IO performance counter

Tags:

powershell

I need to get Page Faults and Disk IO of system while a particular process is running.

I can get Page Faults but not able to get Disk 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
like image 413
Avadhani Y Avatar asked Feb 15 '23 19:02

Avadhani Y


1 Answers

Rather than Get-WMIObject, use the built-in command for getting performance data, Get-Counter:

Get-Counter '\Process(*)\IO Data Operations/sec'

Get-Counter '\Memory\Page Faults/sec'

like image 145
Adi Inbar Avatar answered Feb 23 '23 07:02

Adi Inbar