Command Line utility to see list of tasks CPU Usage, Memory, and execute
You can use the tool typeperf
.
To list all processes:
typeperf "\Process(*)\% Processor Time" -sc 1
List all processes, take 5 samples at 10 second intervals:
typeperf "\Process(*)\% Processor Time" -si 10 -sc 5
If you want a specific process, node for example:
typeperf "\Process(node)\% Processor Time" -si 10 -sc 5
You also can dump it to a csv file and filter in a spreadsheet to remotely diagnose issues.
The following gives me 5 minutes (at 10 second intervals) of all processes. The data includes not just % Processor Time, but IO, memory, paging, etc.
typeperf -qx "\Process" > config.txt
typeperf -cf config.txt -o perf.csv -f CSV -y -si 10 -sc 60
More info: https://technet.microsoft.com/en-us/library/bb490960.aspx
Without dependence on system localization:
typeperf "\238(*)\6" -sc 1
typeperf "\238(*)\6" -si 10 -sc 5
typeperf "\238(_Total)\6" -si 10 -sc 5
typeperf has two drawbacks:
-
typeperf
with arguments as english names won't work on non-english machines, and -
typeperf
with arguments as numbers will break because those numbers vary by machine. (Source: https://stackoverflow.com/a/39650695)
To avoid those drawbacks, you can use powershell's Get-WmiObject
cmdlet. It uses different names compared to typeperf, but you can get the same information, as far as I can tell.
I think that running these commands in powershell will give you what you want:
echo 'Map of process ID to command line:'
Get-WmiObject -Query "Select * from Win32_Process" | Select-Object -Property ProcessId,ExecutablePath,CommandLine | ConvertTo-Csv -NoTypeInformation
echo 'Map of process ID to memory usage:'
Get-WmiObject -Query "Select * from Win32_PerfFormattedData_PerfProc_Process" | Select-Object -Property IDProcess,Name,PageFileBytes,PoolNonpagedBytes,PoolPagedBytes,PrivateBytes,VirtualBytes,WorkingSet | ConvertTo-Csv -NoTypeInformation
echo 'Map of process ID to CPU usage:'
Get-WmiObject -Query "Select * from Win32_PerfFormattedData_PerfProc_Process" | Select-Object -Property IDProcess,Name,PercentProcessorTime | ConvertTo-Csv -NoTypeInformation
echo 'Many people want to do some massaging of the "PercentProcessorTime" numbers above,'
echo 'because in their raw form those numbers (for a single process) can be over 100 percent.'
echo 'So divide all of the "PercentProcessorTime" numbers by this number:'
Get-WmiObject -Query "Select * from Win32_ComputerSystem" | Select-Object -Property NumberOfLogicalProcessors | ConvertTo-Csv -NoTypeInformation