码迷,mamicode.com
首页 > 其他好文 > 详细

ARR状态监控脚本

时间:2014-08-14 14:02:28      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:des   blog   http   os   io   for   ar   art   

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

ARR状态监控脚本,布布扣,bubuko.com

ARR状态监控脚本

标签:des   blog   http   os   io   for   ar   art   

原文地址:http://www.cnblogs.com/dreamer-fish/p/3912239.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!