<% ' Web Site Status Monitor ' Copyright 2014 angells.com, free to distribute, do not alter or remove this introduction. ' ' Save this file to a server capable of running .ASP pages. ' The system this file is to run on is not to be the server monitored. ' Ideally it should be a system on a different internet provider. ' Save it as WebMonitor.asp, specific name not critical but the extension is. ' Change the details below to match your system and other configuration information. ' Open the web page (WebMonitor.asp) in your preferred browser. ' If you want the recipient to receive notices via text message, add the supported text email to the recipient list ' Here is the list of popular carrier supported addresses: ' Alltel: [10 digit phone number]@message.alltel.com ' AT&T: [10 digit phone number]@txt.att.net ' Nextel: [10 digit phone number]@messaging.nextel.com ' Sprint: [10 digit phone number]@messaging.sprintpcs.com ' SunCom: [10 digit phone number]@tms.suncom.com ' T-mobile: [10 digit phone number]@tmomail.net ' Verizon: [10 digit phone number]@vtext.com ' VoiceStream: [10 digit phone number]@voicestream.net strDomain = "Domain.com" 'Friendly name of URL to be tested url = "http://www.domain.com/default.asp" 'Specific URL to test strFrom = "name@domain.com" 'Email address of report sender strTo = "name@domain.com, name@domain2.com, 9999999999@carrier.xxx" 'Email address(s) of individuals to receive status report GmailAccount = "email.address@gmail.com" 'gmail account to use to send report GmailPassword = "password" 'gmail account password StatusRPD = True 'Send nightly testing status report (True or False) TestInterval = 300 'seconds between tests if site is responding FailureInterval = 60 'seconds between tests if site is not responding ReportTime = "7:45:00 AM" 'Time to run daily status report OpeningText = "" function TestText If TestInterval < 60 then TestText = TestInterval & " seconds" else if TestInterval < 3600 then mins = int(TestInterval/60) secs = TestInterval - (mins * 60) TestText = mins & " minutes and " & secs & " seconds" else hrs = int(TestInterval/3600) mins = int((TestInterval - (hrs * 3600))/60) secs = TestInterval - (hrs * 3600) - (mins * 60) TestText = hrs & " hours, " & mins & " minutes and " & secs & " seconds" end if end if end function Sub sendemail (strSubject, strMessage, strError) Set Mail = CreateObject("CDO.Message") Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="smtp.gmail.com" Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1 Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60 Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = GmailAccount Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = GmailPassword Mail.Configuration.Fields.Update Mail.Subject=strSubject Mail.From=strFrom Mail.To=strTo Mail.TextBody=strMessage Mail.Send Set Mail = Nothing end sub On Error Resume Next Set http = Server.CreateObject("MSXML2.ServerXMLHTTP.3.0") http.open "GET", url, true http.send If http.readyState <> 4 then http.waitForResponse 10 If Err.Number = 0 AND http.Status = 200 then 'Good page strStatus ="up" AlertColor = "Black" CurrentTime = time StartTime = DateAdd("s", (-1) * cint(TestInterval/2), ReportTime) EndTime = DateAdd("s", cint(TestInterval/2), ReportTime) if StatusRPD and CurrentTime >= StartTime and CurrentTime <= EndTime then strSubject = "Site Good" strMessage = strDomain & " is currently online and tested every " & TestText & ". " & time & " on " & date & "." sendemail strSubject, strMessage, strError OpeningText = OpeningText & "Status report sent." else if StatusRPD then OpeningText = OpeningText & "Daily status report will be sent each " & ReportTime & "." else OpeningText = OpeningText & "Daily status report is not scheduled to be sent." end if end if else strSubject = "Site Down" strMessage = strDomain & " is currently down. " & time & " on " & date & "." sendemail strSubject, strMessage, strError TestInterval = FailureInterval strStatus = "down" AlertColor = "Red" end if set http = nothing %> Web Site Monitor

<%=OpeningText%>

<%=strDomain%> is currently <%=strStatus%>.

Next check at <%=DateAdd("s", TestInterval, time)%> (every <%=TestText%>).

Closing this browser session will terminate site monitoring.