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