Checking web server is up......

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Checking web server is up......

Post by Dorian (MJT support) » Fri Feb 27, 2004 5:50 pm

In my attept to "give a little back"........

Not sure if this is the *best* way to do this, but I just put together a little script which checks a webpage every 5 minutes. If it can't reach the page it will retry every minute for 15 minutes, and if it is still unsuccessful will send an email to me, my cellphone, and the support department where my server is housed. You can certainly improve on this script if you like, but I thought it might be useful to someone. Amend as required so it works for you.

let>a=1
label>start
HTTPRequest>http://www.SITE.com,,GET,,HTMLResponse
MidStr>%HTMLResponse%,2,4,somevalue
if>somevalue=HTML,writelog
WAIT>60
let>a=a+1
if>a=15,email
goto>start

label>writelog

GetDate>date
GetTime>time
WriteLn>c:\http-request-log.txt,result,%date% %time% SERVER RESPONSE OK
goto>end

label>email

Let>SENDMAIL_STATUS=1
Let>subject=SITE.COM RaQ4 server has not responded in 20 minutes
Let>me=[email protected]
Let>myname=SITE.com
Let>recipients=[email protected];[email protected]
Let>body=SITE.com RaQ4 has not been responding for 15 minutes and may need to be rebooted. This is an automatic email generated by my monitoring macro.
SMTPSendMail>recipients,smtp.SITE.COM,me,myname,subject,body,
REMARK>Message>Result of SendMail: %SMTP_RESULT%
GetDate>date
GetTime>time
WriteLn>c:\http-request-log.txt,result,%date% %time% !!! NO RESPONSE - EMAIL SENT
WriteLn>c:\http-request-log.txt,result,%date% %time% !!! Result of SendMail: %SMTP_RESULT%
messagemodal>server has not responded for 20 minutes - please check

label>end

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts