I would like to know it there is a way to get access to the data displayed in the Monitoring and Management page of a server farm. Specifically I'd like to get access to the Availability and Health Status columns. On the documentation site there are some
examples to setup the config but nothing to display that data. So can we get access to that data using APPCMD or PS or any other technology? Our goal here is to use this data to monitor the farm.
I would also like to know if there is a way to invoke the actions below on a server again using APPCMD or PS or anything else. In that case our goal would be to schedule application restarts and maintenance.
"Make Server Unavailable Gracefully"
"Make Server Unavailable Immediately"
"Disallow New Connections" ... etc.
Thank you;
Pascal
P.S. I must add that I really enjoy that new extension. It opens up a lot of new possibilities without having to get into fancy/costly equipment/software. Good work!
It is definitely possible to do those actions using AHAdmin/MWA (probably the powershell provider, but I have not experimented with it) - I will post some sample scripts to my blog and link back to this thread.
Anil Ruia
Software Design Engineer
IIS Core Server
7 Posts
Access "Monitoring and Management" data from APPCMD or PS
Apr 02, 2009 05:44 PM|PascalN|LINK
Hello,
I would like to know it there is a way to get access to the data displayed in the Monitoring and Management page of a server farm. Specifically I'd like to get access to the Availability and Health Status columns. On the documentation site there are some examples to setup the config but nothing to display that data. So can we get access to that data using APPCMD or PS or any other technology? Our goal here is to use this data to monitor the farm.
I would also like to know if there is a way to invoke the actions below on a server again using APPCMD or PS or anything else. In that case our goal would be to schedule application restarts and maintenance.
"Make Server Unavailable Gracefully"
"Make Server Unavailable Immediately"
"Disallow New Connections" ... etc.
Thank you;
Pascal
P.S. I must add that I really enjoy that new extension. It opens up a lot of new possibilities without having to get into fancy/costly equipment/software. Good work!
Application Request Routing
2343 Posts
Microsoft
Re: Access "Monitoring and Management" data from APPCMD or PS
Apr 02, 2009 05:54 PM|anilr|LINK
It is definitely possible to do those actions using AHAdmin/MWA (probably the powershell provider, but I have not experimented with it) - I will post some sample scripts to my blog and link back to this thread.
Software Design Engineer
IIS Core Server
7 Posts
Re: Access "Monitoring and Management" data from APPCMD or PS
Apr 03, 2009 11:20 AM|PascalN|LINK
Hello,
based on your comment I was able to get to that information using MWA on IronPython and PS. Here is how I did it for PS.
# First add a reference to the MWA dll
PS> [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Administration")
#Get the manager and config object
PS> $mgr = new-object Microsoft.Web.Administration.ServerManager
PS> $conf = $mgr.GetApplicationHostConfiguration()
#Get the webFarms section
PS> $section = $conf.GetSection("webFarms")
PS> $webFarms = $section.GetCollection()
#Get the first web farm for simplicity but can be selected
#using $webFarm.GetAttributeValue("name")
PS> $webFarm = $webFarms[0]
#Get the servers in the farm
PS> $servers = $webFarm.GetCollection()
#Select the first server
PS> $server = $servers[0]
#Just to display the server selected
PS> $server.GetAttributeValue("address")
#Get the ARR section
PS> $arr = $server.GetChildElement("applicationRequestRouting")
PS> $counters = $arr.GetChildElement("counters")
We now have everything we need to have some real fun!
To get the health status of the server we can do
PS> $counters.GetAttributeValue("isHealthy")
To get the availibility or state of the server
PS> $counters.GetAttributeValue("state")
Here are the values I discovered for this field
0 = Available
1 = Drain
2 = Unavailable
#All the counters can be listed with that
PS> $counters.Attributes | Format-List
That is all real cool but we also want to change the health status of a server
#Get the method we want there is also SetUnhealthy
PS> $method = $arr.Methods["SetHealthy"]
#Get the instance of the method
PS> $methodInstance = $method.CreateInstance()
#Execute the method
PS> $methodInstance.Execute()
We can also change the state of the server
#Get the method we want
PS> $method = $arr.Methods["SetState"]
#Get the instance of the method
PS> $methodInstance = $method.CreateInstance()
#Set the input value
PS> $methodInstance.Input.Attributes[0].Value = 0
#Execute the method
PS> $methodInstance.Execute()
So far I've seen that these input values yields to
0 -> Available
1 -> Drain
2 -> Unavailable
3 -> Unavailable
2 and 3 yields to Unavailable so I guess one is for "Make Server Unavailable Gracefully" and the other is for Make Server Unavailable Immediately"
Anil could you please confirm what does what?
Thanks
Application Request Routing PowerShell
2343 Posts
Microsoft
Re: Access "Monitoring and Management" data from APPCMD or PS
Apr 03, 2009 12:49 PM|anilr|LINK
Look in %windir%\system32\inetsrv\config\schema\arr_schema.xml - it has the details you need.
Software Design Engineer
IIS Core Server
7 Posts
Re: Access "Monitoring and Management" data from APPCMD or PS
Apr 03, 2009 02:21 PM|PascalN|LINK
That is perfect!
Thank you