zoukankan      html  css  js  c++  java
  • ARR状态监控脚本

    #####################################################################################
    # THIS IS SAMPLE CODE AND IS ENTIRELY UNSUPPORTED. THIS CODE AND INFORMATION        #
    # IS PROVIDED "AS-IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,    #
    # INCLUDING BUT NOT LIMITED TO AN IMPLIED WARRANTY OF MERCHANTABILITY AND/OR        #
    # FITNESS FOR A PARTICULAR PURPOSE.                                                 #
    #####################################################################################
     
    # First add a reference to the MWA dll
    $dll=[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Administration")
     
    #Get the manager and config object
    $mgr = new-object Microsoft.Web.Administration.ServerManager
    $conf = $mgr.GetApplicationHostConfiguration()
     
    #Get the webFarms section
    $section = $conf.GetSection("webFarms")
    $webFarms = $section.GetCollection()
     
     
    foreach ($webFarm in $webFarms)
    {
        $Name= $webFarm.GetAttributeValue("name");
        #Get the servers in the farm
        $servers = $webFarm.GetCollection()
        Write-Host  "Farm Name: " $Name
        foreach($server in $servers)
        {
             $ip= $server.GetAttributeValue("address")
             #Get the ARR section
             $arr = $server.GetChildElement("applicationRequestRouting")
             $counters = $arr.GetChildElement("counters")
             $isHealthy=$counters.GetAttributeValue("isHealthy")
             $state= $counters.GetAttributeValue("state")
             switch ($state) 
             { 
                    0 {$state= "Available"} 
                    1 {$state= "Drain"} 
                    2 {$state= "Unavailable"} 
                    default {$state= "Non determinato"}
             }
     
            if( $isHealthy)
            {
                $isHealthy="Healthy"
            }
            else
            {
                $isHealthy="Not Healthy"
            }        
             Write-Host -NoNewLine $ip  " " $state " " $isHealthy
             #NEW LINE
             Write-Host
        }
        #NEW LINE
        Write-Host
    }

    Output shows all web farms installed on your server plus the status of each application server.

    From:http://blogs.msdn.com/b/carmelop/archive/2013/04/29/how-to-monitor-application-request-routing-via-powershell.aspx

  • 相关阅读:
    算法与时间复杂度
    Pandas库
    数据分析之Numpy、Matplotlib库
    增量式爬虫
    分布式爬虫
    scrapy框架之CrawlSpider全站自动爬取
    django 修改 request 对象中的请求参数, 并重新赋值给 request 对象
    nginx 请求文件 进行用户认证/鉴权: internal(限制为内部调用)
    Django 缓存配置的多种方式
    Python 加入类型检查
  • 原文地址:https://www.cnblogs.com/dreamer-fish/p/3912239.html
Copyright © 2011-2022 走看看