Tablets How to monitor and start App Pools automatically via VBScript on Windows 2008 | BLOG IT

How to monitor and start App Pools automatically via VBScript on Windows 2008


The following VBScript helps on monitor App Pools State and if it is Stopped it automatically starts, also it sends an email informing you about that situation, email only needs a valid SMTP server in order to deliver the email. You only need to configure a Schedule Task wich start the following script, you need to save as Filename.vbs.


Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")
Set oAppPools = oWebAdmin.InstancesOf("ApplicationPool")
'Search in all App Pools
For Each oAppPool In oAppPools
 
IF oAppPool.GetState= 1 Then
'wscript.echo "App Pool Started"

ElseIF  oAppPool.GetState= 3 Then
'wscript.echo "App Pool Stopped"
' Following command Starts App Pool
oAppPool.Start

Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Monitoreo APP POOLS:" &" " &oAppPool.Name
objMessage.From = "monitoreo@mydomain.com"
objMessage.To = "myemail@mydomain.com"
objMessage.TextBody = "Monitorinig Message, App Pool:"  &" " &oAppPool.Name &" " &"was down and automatically was started"

'==This section provides the configuration information for the remote SMTP server.
'==Normally you will only change the server name or IP.
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.mydomain.com"

'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

objMessage.Configuration.Fields.Update

'==End remote SMTP server configuration section==

objMessage.Send

End if



Next

set oWebAdmin = nothing
Set oAppPools = nothing
Set objMessage = nothing
SHARE

About Robert SA

    Blogger Comment
    Facebook Comment

0 comentarios: