Richard Gamberg's ASP SERVER OUTAGE REPORTER
Back      808hi.com     808news.com

If you have a website and want to know when it goes down, here's how to do it:

Requirements: 
Hosting service account that includes NT/IIS, ASP support.
You must have a directory that has write permission for scripts (IIS user) - Some services provide you with one, others allow you to set permissions, and still others require you contact support to have them set permissions.

Limitations:
An ASP page must be accessed from your site after the server restarts for the log entry to occur.
The date & time logged will be that of the first such access, not the actual restart time.
Depending upon the traffic to your site, the server could go down and back up without it being logged before it goes down and up again.

The logging is accomplished by the special global.asa file. If your site already has a global.asa file, you will need to edit it, inserting the code between the SUB and END SUB sections in existing Application_OnStart section of your file. If your site doesn't already have a global.asa file, you can create a file with just the code below, and add it to your root virtual web.

<SCRIPT LANGUAGE="VBScript" RUNAT="Server">

Sub Application_OnStart
whichfile=server.mappath("/cgi-bin/server.txt")
On Error Resume Next
Set fs = CreateObject("Scripting.FileSystemObject")
Set thisfile = fs.OpenTextFile(whichfile, 8,0)
if err then
Set thisfile = fs.OpenTextFile(whichfile, 8,1)
thisfile.writeline "Date & Time of Server Restart"
end if

logwrite= formatdatetime(now(),0)
thisfile.writeline logwrite

thisfile.close
set thisfile = nothing
set fs = nothing

End Sub
</SCRIPT>

To read your log file, simply FTP to your virtual server's cgi-bin directory, and grab server.txt.

Or, you can create a web page (log.asp) to display the log. The basic code to do this:

 

To test the script on your server, create a test.asp file without the Sub and EndSub, load and run it. If the server.txt file doesn't appear in your /cgi-bin directory, you can remove the OnErrorResume next, create an empty server.txt file in the cgi-bin directory, and run the .asp file to see what error you get (probably permissions...). If your host gives write access to a different directory, you can simply change the line that specifies /cgi-bin/server.txt to the desired path.

BACK

Site 1999 - 2003 Richard Gamberg  Contact Info