Website Monitoring Script

  • Thread starter Thread starter Aaron
  • Start date Start date
A

Aaron

Is there a script that monitor (ping) my website every hour and run iisreset
if it receives an error or no response.

Thanks
Aaron
 
I tried to install it, but it doesn;'t work on my win xp pro machine.
I want to test it before I run it on the production server
(windows 2003)
 
You can script whatever responses you want it to do for you. Check out the docs.
 
All these programs are too expensive for me.
Can I do this with DOS, I don't need anything complicated.

1.Download a file from a website
2. If the download fails run iisreset
*I'll just add this batch file to schedule tasks in windows.

Thanks.
A
 
Aaron said:
All these programs are too expensive for me.
Can I do this with DOS, I don't need anything complicated.

1.Download a file from a website
2. If the download fails run iisreset
*I'll just add this batch file to schedule tasks in windows.

I guess you could get a copy of wget and test with that but try WSH.
Goto http://www.paulsadowski.com/WSH/xmlhttp.htm and look at the
HTMLHead.vbs script and go from there.
 
Aaron said:
Is there a script that monitor (ping) my website every hour and run
iisreset
if it receives an error or no response.

Change URL and CMD strings to whatever you need.

'CheckServer.vbs
URL = http://localhost
CMD = "cscript c:\inetpub\adminscripts\iisreset.vbs"

Set WshShell = WScript.CreateObject("WScript.Shell")
Set http = CreateObject("Microsoft.XmlHttp")

on error resume next
http.open "HEAD", URL, FALSE
http.send ""
if http.Status <> "200" then
WshShell.Run CMD
end if

set http = nothing
set WshShell = nothing
 
If you can script in perl you can use the LWP module to pull the info and then
if the script runs on the local web server you can do an iisreset, otherwise you
can rcmd or telnet to the remote server and do the reset. However, you have to
have someone logged on all of the time or find some other way to run the monitor
script as a service.
 
Why don't you get hold of an evaluation copy of Windows Server 2003 from
Microsoft's web site to do your testing?

Oli
 
Thanks Paul this works great.
I want to add one more thing
if http.Status <> "200" and does not finish downloading in 10 sec.


URL = "http://localhost"
CMD = "c:\windows\system32\iisreset.exe"

Set WshShell = WScript.CreateObject("WScript.Shell")
Set http = CreateObject("Microsoft.XmlHttp")

on error resume next
http.open "GET", URL, FALSE
http.send ""
if http.Status <> "200" then <<<<<<<<<<<<<<<<<<
WshShell.Run CMD
else
WScript.Echo "OK"
end if

set http = nothing
set WshShell = nothing
 
Aaron said:
Thanks Paul this works great.
I want to add one more thing
if http.Status <> "200" and does not finish downloading in 10 sec.

Do you really mean that or do you mean if the status does not = 200 **OR**
the time for the head request to return is greater than 10 seconds? The
script below assumes my interpretation.

If you really mean your way then change this line
if http.Status <> "200" or DateDiff("s", StartTime, EndTime) > 10 then
to
if http.Status <> "200" and DateDiff("s", StartTime, EndTime) > 10 then

'CheckServer.vbs
URL = http://localhost
CMD = "cscript c:\inetpub\adminscripts\iisrestart.vbs"

Set WshShell = WScript.CreateObject("WScript.Shell")

on error resume next
Set http = CreateObject("Microsoft.XmlHttp")
http.open "HEAD", URL, FALSE
StartTime = Now
http.send ""
EndTime = Now

if http.Status <> "200" or DateDiff("s", StartTime, EndTime) > 10 then
WshShell.Run CMD
end if
set http = nothing
set WshShell = nothing
 
Oops, I pasted my test copy. The proper order is to create the Xml.Http
object before the error handling. Minor thing but we want to see if there's
a problem creating either object so they should come before the error
handling.

URL = "http://localhost"
CMD = "cscript c:\inetpub\adminscripts\iisrestart.vbs"

Set WshShell = WScript.CreateObject("WScript.Shell")
Set http = CreateObject("Microsoft.XmlHttp")

on error resume next

http.open "HEAD", URL, FALSE
StartTime = Now
http.send ""
EndTime = Now

if http.Status <> "200" or DateDiff("s", StartTime, EndTime) > 10 then
WshShell.Run CMD
end if

set http = nothing
set WshShell = nothing
 
This is awesome! thanks for your help

Paul R. Sadowski said:
Oops, I pasted my test copy. The proper order is to create the Xml.Http
object before the error handling. Minor thing but we want to see if there's
a problem creating either object so they should come before the error
handling.

URL = "http://localhost"
CMD = "cscript c:\inetpub\adminscripts\iisrestart.vbs"

Set WshShell = WScript.CreateObject("WScript.Shell")
Set http = CreateObject("Microsoft.XmlHttp")

on error resume next

http.open "HEAD", URL, FALSE
StartTime = Now
http.send ""
EndTime = Now

if http.Status <> "200" or DateDiff("s", StartTime, EndTime) > 10 then
WshShell.Run CMD
end if

set http = nothing
set WshShell = nothing
 
Back
Top