I have 7 windows services. i want to monitor the performance of the individual services like the processor usage, memory usage etc.
If i use perfmon, it gives for the entire system but not the individual services. Can anyone please suggest how do i monitor the performance of individual services?
To start, hit Windows Key + R and type: perfmon and hit Enter or click OK. From the left pane of the Performance Monitor app, expand Data Collector Sets > System > System Performance. Then right-click on System Performance and click Start. That will kick off the test in Performance Monitor.
Go to Services and Processes tab. Click on Discover Services and Processes . This will discover the processes & services running in your Windows server. Select the service you wish to monitor and click Add Service and Process .
The Microsoft Windows Performance Monitor is a tool that administrators can use to examine how programs running on their computers affect the computer's performance. The tool can be used in real time and also be used to collect information in a log to analyze the data at a later time.
Perfmon can monitor individual processes! Just chose process in "Add counters/Performance objects" combo. For "quick" monitoring I have found that Sysinternals (now Microsoft) Process Explorer is easy and nice. Some services give you performance information (available by sockets/files etc) that can be displayed by tools such as MRTG or Cacti.
To check the memory of individual services, you will have to change the service types to "Own Process". This Gist show the complete code. The central idea is trying to change the service type from the least intrusive to the most intrusive way:
$win32Service = Get-CimInstance -ClassName Win32_Service -Filter "Name = '$ServiceName'" -Verbose:$false
if ($win32Service)
{
if (!(Set-ServiceTypeToOwnProcessByCim $win32Service))
{
if (!(Set-ServiceTypeToOwnProcessByWindowsRegistry $win32Service))
{
if (Grant-FullControlRightsOnServiceRegistryKeyToCurrentUser $win32Service)
{
Set-ServiceTypeToOwnProcessByWindowsRegistry $win32Service | Out-Null
}
}
}
}
else
{
Write-Warning "[$ServiceName] Service not found"
}
When putting the Set-ServiceTypeToOwnProcess.ps1
and Enable-Privilege.ps1
files in the same folder, you can execute the script like this:
.\Set-ServiceTypeToOwnProcess.ps1 -ServiceName 'Appinfo', 'gpsvc', 'Schedule', 'SENS', 'SessionEnv', 'wuauserv'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With