Monitor the performance of individual window service

你说的曾经没有我的故事 提交于 2019-12-07 05:45:14

问题


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?


回答1:


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.




回答2:


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'


来源:https://stackoverflow.com/questions/1187074/monitor-the-performance-of-individual-window-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!