我有7个windows服务。我想监控各个服务的性能,比如处理器使用率、内存使用率等。
如果我使用perfmon,它会提供整个系统,而不是单个服务。有没有人可以建议我如何监控单个服务的性能?
发布于 2009-07-27 08:59:44
Perfmon可以监控单独的进程!刚刚在“添加计数器/性能对象”组合框中选择了进程。为了“快速”监控,我发现Sysinternals (现在的Microsoft) Process Explorer很简单,也很好用。一些服务为您提供性能信息(通过套接字/文件等提供),这些信息可以由MRTG或Cacti等工具显示。
发布于 2018-03-17 23:21:10
要检查单个服务的内存,您必须将服务类型更改为"Own“。This Gist显示了完整的代码。核心思想是尝试将服务类型从侵入性最小的方式更改为侵入性最强的方式:
$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"
}将Set-ServiceTypeToOwnProcess.ps1和Enable-Privilege.ps1文件放在同一文件夹中时,可以像这样执行脚本:
.\Set-ServiceTypeToOwnProcess.ps1 -ServiceName 'Appinfo', 'gpsvc', 'Schedule', 'SENS', 'SessionEnv', 'wuauserv'https://stackoverflow.com/questions/1187074
复制相似问题