Automated VB script to check the web application status and send mail to stakeholders when app is down

 VB script code:

Dim waittime : waittime = 60000

do

Set objOutlook = CreateObject("Outlook.Application")

set objMail = objOutlook.CreateItem(0)

Dim strWebsite

strWebsite = "vnothperformancetesting.blogspot.com"

MailSubject = "Application Status on" & " " & Now & " is down"

If PingSite( strWebsite ) Then

    WScript.Echo "Application" & strWebsite & " is up and running!"

Else

    WScript.Echo "Application" & strWebsite & " is down!!!"

objMail.Display

objMail.To = "katXXXu@gmail.com"

ObjMail.Recipients.Add("katXXXu@gmail.com")

objMail.cc = "katXXXu@gmail.com"

objMail.Subject = MailSubject

objMail.Body = "Hi, Ping status to application shows that application is Down!. Pls look into it."

objMail.Send

objOutlook.Quit

set objMail = Nothing

Set objOutlook = Nothing

End If

WScript.Sleep(waittime)

loop

Function PingSite( myWebsite )

    Dim intStatus, objHTTP

    Set objHTTP = CreateObject( "WinHttp.WinHttpRequest.5.1" )

    objHTTP.Open "GET", "http://" & myWebsite & "/", False

    objHTTP.SetRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MyApp 1.0; Windows NT 5.1)"

On Error Resume Next

objHTTP.Send

intStatus = objHTTP.Status

On Error Goto 0

If intStatus = 200 Then

PingSite = True

Else

PingSite = False

End If

Set objHTTP = Nothing

End Function

2 comments:

  1. Hi, Thanks for sharing the blog, Explore more aout one of the best Website Performance Testing Company​in the USA & India.

    ReplyDelete
  2. Hi Could you please post how to automate load runner analysis file after test executions are completed. Manually we can copy all analysis data and graphs into the excel and prepare the report. Instead of that will it possible to automate analysis file.

    ReplyDelete