微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

windows – 用于监视App池内存使用情况的免费应用程序或脚本

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

%windir%\system32\inetsrv\appcmd.exe list wp

但这只是获取了workerproces id和app pool名称.然后我接受并交叉引用任务管理器.这是有效的,但我想要一个更快 – 几乎仪表板显示信息.我想必须有某种解决方案来显示信息,而不需要像过程浏览器那样点击.有人特别喜欢他们使用的东西吗?在PowerShell中这是可能的吗?

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

您可以使用以下命令运行脚本:

./Get-WebServerAppPoolStats.ps1’Server1′,’Server2′,’Server3′-IntegratedAuthentication
要么
Get-Content servers.txt | ./Get-WebServerAppPoolStats.ps1-IntegratedAuthentication

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
    }
}

原文地址:https://www.jb51.cc/windows/368627.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐