首页 > 代码库 > ARR状态监控脚本
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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。