DX Unified Infrastructure Management

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

    Posted Aug 13, 2009 08:55 PM
    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


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

    Posted Aug 13, 2009 09:19 PM
    Chris,

    I think the following components would work together:
    • ntevl watcher that matches the event log message and generates alarm
    • NAS AO profile that matches alarm from ntevl and runs a script
    • NAS script that reads the alarm message, parses out the pool name, and issues callback to nexec probe on IIS host
    • nexec profile that runs your VBScript command with one argument
    I am not 100% sure how you provide an argument to a command using the nexec probe with a callback.  I know you can configure the command to have variables and get the option of specifying the values in the GUI when firing the command manually, so I would expect you could do the same when using the callback directly.

    Make sense?

    -Keith


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

    Posted Aug 13, 2009 10:03 PM
    The easiest way I can think of doing this is executing your script through the NAS via an AutoOperator using the Command option.

    You should think of running the script through psexec, to work around the issue of passing the right pool name, you should work that into the alarm as a specific variable that you can scrape via the Command field, hit the $ sign and you'll see your options for this.

    Let me know if you need further explanation, I'm glad to help!

    Dustin


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

    Posted Aug 13, 2009 10:06 PM
    I had my "Respond" window open too long and Keith beat me to the punch here! :smileywink:

    Dustin


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

    Posted Aug 14, 2009 02:19 AM
    Thank to both of you.

    Dustin,
    When you say "you should work that into the alarm as a specific variable that you can
    scrape via the Command field, hit the $ sign and you'll see your
    options for this", I see how to expose the variables in the Command section of the AO profile, but any advice on how to "work  into the alarm as a specific variable"?

    Keith,
    Is there an example somewhere of how I can "issues callback to nexec probe on IIS host"?

    Thanks,
    Chris


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

    Posted Aug 14, 2009 03:35 AM
    Chris,

    Are you monitoring the App Pool via the Logmon Probe? Let's say "Yes" though this example is basically applicable for of the other probes too.

    You could take the Pool Name from the log, use the pool name as the alarm message, then send that to the NAS. Once the NAS intercepts it, the AutoOperator, using the Command Option, could remotely call your script using PSExec and the $MESSAGE variable which would reference your Pool Name.

    Or something similar - does that make sense?

    Dustin


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

    Posted Aug 14, 2009 03:58 AM
    It looks to me like this is coming from the event log, and the ntevl probe does not have the ability to parse out part of the event log message string.  The good news is that you would be able to do this in Lua fairly easily.  (I have used Lua to parse the CPU utilization percentage out of cdm alarms.)

    It looks like the VBScript can be run directly on the host running the NAS, a fact that I missed but I think Dustin caught.  (I will blame that on the fact that the script came through on the forum with poor formatting, so I had a hard time seeing exactly what it does.)  If that is the case, you would not need the nexec probe.  That probe would be needed if the script had to be run on the IIS server directly.  It would be simpler to run the script on the NAS host; use the Lua action.command() function to run the script after getting the pool name.

    -Keith