How to introduce monitoring and automatic recovery of IIS application pools using Orchestrator
IIS Application Pools can fail and stop in case of exceptions or successive failures. When stopped, the IIS site using the pool will stop working and will no longer be available on the IIS server. Having an automatic recovery is feasible using IIS and this Wiki article shares another way to proceed with recovery: Orchestrator can be used to monitor and recover IIS application pools.
To configure Orchestrator for the monitoring and the automatic recovery of IIS application pools, you will need to create one Runbook and use five (5) activities:
- Monitor Data/Time: It will allow you to specify the time of when the Runbook need to start running
- Check Schedule: It allow you to specify the slot of days and hours when the Runbook can start running (By combining the settings in the activity and the ones from the previous activity, you will be able to precise the dates and times of when your runbook can start running)
- Run .Net Script: This activity will allow you to specify the server name and application pool name in variables. The variables will then used to specify the input of the Runbook.
- Execute PS Script: This activity will be available if you register and deploy Orchestrator Integration Pack for Powershell Script Execution (http://blogs.technet.com/b/orchestrator/archive/2013/10/02/the-orchestrator-integration-pack-for-powershell-script-execution-1-2-is-now-available.aspx). It will allow you to check the status of the application pool on the server using the following Powershell command: Import-module WebAdministration -Global;(Get-WebAppPoolState <ApplicationPool>).Value (<applicationPool> is the variable from Run .NET Script activity named applicationpool. The Host Name of the activity should be set to take as input the variable server from Run .NET Script activity)
- Execute PS Script: This activity will start the application pool if it is not already started using the following Powershell command: Import-module WebAdministration -Global;Start-WebAppPool <applicationpool> (<applicationPool> is the variable from Run .NET Script activity named applicationpool. The Host Name of the activity should be set to take as input the variable server from the Run .NET Script activity)
The link between both Execute PS Script need to be set with the following include condition: PS Execution 01 Results from Execute PS Script does not equal Started. This will allow checking the status of the application pool. If it is not started then the second Execute PS Script activity is invoked.
Below is a screen capture of all the activities included in the Runbook:
Using this method, Orchestrator will periodically monitor the application pool status and will start it if it was stopped. It is also possible to configure mail notifications using Send Email activity.