免费的应用程序或脚本来监视应用程序池内存使用

我需要一个显示以下内容的应用程序或脚本:工作进程,应用程序池名称,内存使用情况以及可选的CPU使用情况。 我熟悉使用

%windir%\ system32 \ inetsrv \ appcmd.exe列表wp

但是这只是让我的工人进程ID和应用程序池名称。 然后我拿这个和交叉参考taskmanager。 这工作,但我希望更快 – 几乎像仪表板显示的信息。 我想,必须有某种解决scheme,显示信息,而不需要像过程浏览器一样点击。 任何人都有他们特别使用的东西? 这将是可能的PowerShell

如果您没有IIS 7和提供程序,则可以使用WMI。 附加的脚本适用于您的大部分需求,CPU使用率除外。 将下面的脚本保存为get-webserverapppoolstats.ps1(或任何你想要的)。

你可以运行脚本,然后:

./Get-WebServerAppPoolStats.ps1'Server1','Server2','Server3'-IntegratedAuthentication或Get-Content servers.txt | ./Get-WebServerAppPoolStats.ps1 – 集成身份validation

param ( $webserver = $null, $username, $password, [switch]$IntegratedAuthentication) BEGIN { $path = $MyInvocation.MyCommand.Path if ($webserver -ne $null) { if ($IntegratedAuthentication) { $webserver | &$path -IntegratedAuthentication } else { $webserver | &$path -username $username -password $password } } $OFS = ', ' $Fields = 'CommandLine', 'Name', 'CreationDate', 'ProcessID', 'WorkingSetSize', 'ThreadCount', 'PageFileUsage', 'PageFaults' $query = @" Select $fields From Win32_Process Where name = 'w3wp.exe' "@ $AppPool = @{Name='Application Pool';Expression={($_.commandline).split(' ')[-1]}} $Process = @{Name='Process';Expression={$_.name}} $RunningSince = @{Name='Running since';Expression={[System.Management.ManagementDateTimeconverter]::ToDateTime($_.creationdate)}} $Memory = @{Name='Memory Used';Expression={'{0:#,#}' -f $_.WorkingSetSize}} $Threads = @{Name='Thread Count';Expression={$_.threadcount}} $PageFile = @{Name='Page File Size';Expression={'{0:#,#}' -f $_.pagefileusage}} $PageFaults = @{Name='Page Faults';Expression={'{0:#,#}' -f $_.pagefaults}} } PROCESS { $server = $_ if ($server -ne $null) { if ($IntegratedAuthentication) { $result = Get-WmiObject -Query $query -ComputerName $server } else { $securepassword = ConvertTo-SecureString $password -AsPlainText -Force $cred = New-Object System.Management.Automation.PSCredential -ArgumentList $username, $securepassword $result = Get-WmiObject -Query $query -ComputerName $server -Credential $cred } $Server = @{Name='Server';Expression={$server}} $result | Select-Object $Server, $AppPool, $Process, $RunningSince, $Memory, $Threads, $PageFile, $pageFaults } } 

是的powershell可以做到这一点与新的PowerShell的IIS提供商很容易。 以下是运行时数据walkthru提供的一些示例:

AppPool状态

 PS IIS:\> cd AppPools PS IIS:\AppPools> Get-WebItemState DemoAppPool Started PS IIS:\AppPools> Stop-WebItem DemoAppPool PS IIS:\AppPools> Get-WebItemState DemoAppPool Stopped 

工作进程和请求get-process cmdlet无法帮助您计算出特定工作进程正在提供哪个应用程序池。 然而,这可以很容易地完成:

 PS IIS:\AppPools> dir DefaultAppPool\WorkerProcesses processId Handles state StartTime --------- ------- 6612 326 1 3/28/2008 12:20:27 PM 

请注意,一旦你有PID常规

  get-process -id pid 

会告诉你内存的使用情况

我不知道为什么这个脚本的服务器“名称”的一部分没有为我工作,但我想出了一个解决方法:

replace这一行:

$ Server = @ {Name ='Server'; Expression = {$ server}}

有这两行:

$ machine = New-Object system.string $ server

$ Server = @ {Name ='Server'; Expression = {$ machine}}

一旦我做到了这一点,它完美的工作。