christopher.harris

How to: catch an event and restart an IIS app pool?

Discussion created by christopher.harris on Aug 14, 2009
Latest reply on Aug 14, 2009 by keith_k
I need to monitor for an event from IIS, grab the Application pool name (19189 below) then start the app pool with that name after waiting 5 minutes.

We already have a vbscript that will restart the app pool (below), but I'm not sure what the best way is to hook these things together.

Is there a straightforward way to do this?

The event looks like this:
************


Event Type:        Error



Event Source:    W3SVC



Event
Category:               
None



Event
ID:             
1002



Date:                    
8/12/2009



Time:                    
1:43:06 PM



User:                    
N/A



Computer:         
NCHWEB11



Description:



Application pool '19189' is being automatically disabled due
to a series of failures in the process(es) serving that application pool.



************

Here is the script that will restart an app pool:
************


Option Explicit

 

 



 

 

 



Dim oAppPool, oArgs,
sComputer,
sSiteID



 

 

 



Set oArgs = WScript.Arguments

 

 



sSiteID = oArgs(0)

 

 



sComputer = oArgs(1)

 

 



 

 

 



StopAppPool(sComputer, sSiteID)

 

 






 

 

 

 

Sub StopAppPool(sComputer, sSiteID)

 

 





 

 

               
Set oAppPool = GetObject("IIS://" & sComputer &
"/W3SVC/AppPools/" & sSiteID)

 

 



               
oAppPool.Start()

 

 





 

 

End Sub

 

 



************

Thanks,
Chris

Outcomes