AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 28100
Accepted
notandy
notandy
Asked: 2009-06-19 07:47:49 +0800 CST2009-06-19 07:47:49 +0800 CST 2009-06-19 07:47:49 +0800 CST

免费应用程序或脚本来监控应用程序池内存使用情况

  • 772

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

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

但这只是让我得到workerproces id和应用程序池名称。然后我把它和交叉引用任务管理器。这可行,但我想要一个更快的 - 几乎像仪表板一样的信息显示。我想一定有某种解决方案可以显示信息,而无需像流程资源管理器那样单击。任何人都有他们特别使用的东西吗?这在powershell中可能吗?

windows windows-server-2008 powershell iis-7
  • 3 3 个回答
  • 8713 Views

3 个回答

  • Voted
  1. Best Answer
    Steven Murawski
    2009-06-19T10:46:44+08:002009-06-19T10:46:44+08:00

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

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

    ./Get-WebServerAppPoolStats.ps1 'Server1', 'Server2', 'Server3' -IntegratedAuthentication OR 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
        }
    }
    
    • 4
  2. Jim B
    2009-06-19T08:36:45+08:002009-06-19T08:36:45+08:00

    是的,powershell 可以使用新的 IIS PowerShell 提供程序来做到这一点,这很容易。以下是提供的运行时数据演练中的一些示例:

    应用池状态

    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
    

    会告诉你内存使用情况

    • 3
  3. user55148
    2010-09-24T19:43:29+08:002010-09-24T19:43:29+08:00

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

    替换这一行:

    $Server = @{Name='Server';表达式={$server}}

    用这两行:

    $machine = 新对象 system.string $server

    $Server = @{Name='Server';表达式={$machine}}

    一旦我这样做了,它就完美地工作了。

    • 1

相关问题

  • Vanilla Powershell 是否足以成为 Windows 和 DB 服务器管理员的语言?

  • 为什么添加新驱动器后我的磁盘驱动器访问速度如此之慢?

  • 在 Windows Server 2003 下使用 wscipt 从 .asp 文件运行 .exe

  • 最佳混合环境(OS X + Windows)备份?[关闭]

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    从 IP 地址解析主机名

    • 8 个回答
  • Marko Smith

    如何按大小对 du -h 输出进行排序

    • 30 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    Windows 中执行反向 DNS 查找的命令行实用程序是什么?

    • 14 个回答
  • Marko Smith

    如何检查 Windows 机器上的端口是否被阻塞?

    • 4 个回答
  • Marko Smith

    我应该打开哪个端口以允许远程桌面?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    MikeN 在 Nginx 中,如何在维护子域的同时将所有 http 请求重写为 https? 2009-09-22 06:04:43 +0800 CST
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    0x89 bash中的双方括号和单方括号有什么区别? 2009-08-10 13:11:51 +0800 CST
  • Martin Hope
    kch 如何更改我的私钥密码? 2009-08-06 21:37:57 +0800 CST
  • Martin Hope
    Kyle Brandt IPv4 子网如何工作? 2009-08-05 06:05:31 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve